Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Accessing local EJBs (JNDI problem)  RSS feed

 
Lalit Nagalkar
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Darya Akbari
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Lalit,

How do you set the InitialContext? You must set the InitialContext before you can do any JNDI stuff.

Regards,
Darya
 
Lalit Nagalkar
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Darya;

I used
------------------------------------------
InitialContext init=new InitialContext();
-----------------------------------------
as you can see the init variable in the statements I posted.

Pleazzz help someone
Lalit
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Does this help:
WhyDoesTheLocalNameContainARandomNumber
 
Darya Akbari
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Lalit Nagalkar:
hi Darya;

I used
------------------------------------------
InitialContext init=new InitialContext();
-----------------------------------------
as you can see the init variable in the statements I posted.

Pleazzz help someone
Lalit


Hi Lalit,

you can not just call InitialContext(). You first have to create your JBoss context.

Use the following lines before you call new InitialContext():



Regards,
Darya
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!