javax.naming.NoInitialContextException: Failed to create InitialContext using factory specified in hashtable {} [Root exception is java.lang.NullPointerException]
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:243)
at javax.naming.InitialContext.initializeDefaultInitCtx(InitialContext.java:327)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:357)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:447)
at javax.naming.InitialContext.lookup(InitialContext.java:455)
at ejb3inaction.example.client.CalculatorClient.main(CalculatorClient.java:31)
Caused by: java.lang.NullPointerException at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:235)
... 5 more
Please help
THnaks
This message was edited 1 time. Last update was at by Bear Bibeault
Hi,
I would like to add the following to Ivan's reply.
Because you are using the Standalone Java Client to execute your EJB, you need to obtain the JNDI context for that particular environment where your EJB is deployed.
Instead if you put the same code in a JSP deployed as part of the webapplication that belongs to the EAR (EJB + WEB APP) , then getting a default InitialContext works fine.
Hope this helps,
Amit
rachna jain
Ranch Hand
Joined: Jul 14, 2009
Posts: 74
posted
0
Thanks all for replying but i need to clarify one more doubt
i have not edited any deployment descriptor and there i cant see remote interface ref aur name so
are they autogenerated in EJB3 or i need to edit ejb-jar.xml and open-ejbjar.xml for defining jndi context
Please clarify as i have worked over ejb2 and there we do it.
Thanks
Ivan Krizsan
Bartender
Joined: Oct 04, 2006
Posts: 2160
posted
0
Hi!
JNDI names are automatically generated in EJB 3.x, so you do not need to use the deployment descriptor if you do not want to. Prior to EJB 3.1, there is no standard so you have to investigate what names are created in the particular container you use.
To specify a JNDI name of an EJB you can use the mappedName element in the annotation annotating the bean implementation class (@Stateful, @Stateless etc).
With EJB 3.1, JNDI names have been standardized and using such portable JNDI names, your program retains portability across containers. For more information, see section 4.4 of the EJB 3.1 specification.
Best wishes!
rachna jain
Ranch Hand
Joined: Jul 14, 2009
Posts: 74
posted
0
Hi all
Thanks for giving a nice explanation to my problem.
subject: exception while runing EJB3.0 basic application