Hello everyone,
I am practicing EJBs on
jBoss 4.0.4 GA. I have one local SFSB which I can't access with the JNDI name I set in the jBoss.xml deployment descriptor ("shoppingCart/home") as the server gives it a random JNDI name on every deployment (e.g. "local/ShoppingCartSFSB@544217" the part after "@" keeps on changing).
Everytime I access the bean I am getting (as expected in such a situation):>
javax.naming.NameNotFoundException: ShoppingCartSFSB not bound
Necessary fragments of my apps deployment descriptors are given.
---------------------------------------------------------------------------
ejb-jar.xml contains:>
....
<session>
<ejb-name>ShoppingCartSFSB</ejb-name>
<local-home>project.ejb.ShoppingCartLocalHome</local-home>
<local>project.ejb.ShoppingCartLocal</local>
<ejb-class>project.ejb.ShoppingCartEJB</ejb-class>
<session-type>Stateful</session-type>
<transaction-type>Container</transaction-type>
</session>
....
---------------------------------------------------------------------------
jboss.xml contains:>
....
<session>
<ejb-name>ShoppingCartSFSB</ejb-name>
<jndi-name>shoppingCart/home</jndi-name>
</session>
....
---------------------------------------------------------------------------
I am using following statement to access this
EJB :>
---------------------------------------------------------------------------
ShoppingCartLocalHome sch=(ShoppingCartLocalHome)PortableRemoteObject.narrow (init.lookup("shoppingCart/home"), ShoppingCartLocalHome.class);
---------------------------------------------------------------------------
Though I stated "shoppingCart/home"as the jndi name to use in the jboss.xml the server shows while deploying that the ShoppingCartSFSB is bound to "local/ShoppingCartSFSB@***" where *** is a number displayed different every time the app is deployed (e.g "local/ShoppingCartSFSB@544217"). i.e. the JNDI name is different on every deployment.
I also tried using following statement but it failed too :>
---------------------------------------------------------------------------
ShoppingCartLocalHome sch=(ShoppingCartLocalHome)PortableRemoteObject.narrow (init.lookup("local/ShoppingCartSFSB"), ShoppingCartLocalHome.class);
---------------------------------------------------------------------------
How can set a particular JNDI name that will remain unchanged on every deployment.
Thank you.