[jboss-user] [EJB 3.0] - Re: Doing BMP with EJB3. JNDI problems?

JGF1 do-not-reply at jboss.com
Fri Mar 7 12:42:16 EST 2008


I have already had to modify the source of StockClient to conform
to the JBoss way in the getStockList method.

1) I am really surprised JBoss doesn't use the method that is commented out because the current method could lead to class name conflicts if you don't use package prefix...

  |  private StockList getStockList() {
  |     StockList stockList = null;
  |     try {
  |     // Get a naming context
  |     InitialContext ctx = new InitialContext();
  | 
  |     // Get a StockList object
  |     stockList 
  |      = (StockList) ctx.lookup("StockListBean/remote");
  |     //  = (StockList) ctx.lookup(StockList.class.getName());
  |     } catch(Exception e) {
  |      e.printStackTrace();
  |     }
  |     return stockList;
  | 

I think the error is in here somewhere:

  | private StockHome getStockHome() 
  |     throws NamingException {
  |     // Get the initial context
  |     InitialContext initial = new InitialContext();
  | 
  |     // Get the object reference
  |     Object objref = initial.lookup("beans_2x.Stock");
  |     StockHome home = (StockHome)
  |       PortableRemoteObject.narrow(objref, StockHome.class);
  |     return home;
  |   }
  | 

But I am not sure what to do because I am not sure out JBoss is interpretting
ejb-jar.xml in the  node

  | <entity>
  |       <ejb-name>StockEjb</ejb-name>
  |       <home>beans_2x.StockHome</home>
  |       <remote>beans_2x.Stock</remote>
  |       <ejb-class>beans_2x.StockBean</ejb-class>
  |       <persistence-type>Bean</persistence-type>
  |       <prim-key-class>java.lang.String</prim-key-class>
  |       <reentrant>false</reentrant>
  |       <resource-ref>
  |         <res-ref-name>jdbc/StockDB</res-ref-name>
  |         <res-type>javax.sql.DataSource</res-type>
  |         <res-auth>Container</res-auth>
  |         <res-sharing-scope>Shareable</res-sharing-scope>
  |       </resource-ref>
  |       <security-identity>
  |         <use-caller-identity/>
  |       </security-identity>
  |     </entity>
  | 

Following on from the pattern I used on StockClient...
2) Do I just use Stock/remote?


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4134922#4134922

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4134922



More information about the jboss-user mailing list