aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes EJB3 Null Pointer Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB3 Null Pointer Exception" Watch "EJB3 Null Pointer Exception" New topic
Author

EJB3 Null Pointer Exception

Leandro Coutinho
Ranch Hand

Joined: Mar 04, 2009
Posts: 417
Hi my friends.

I'm studying EJB3 and using JBoss 7 for this. I created a @Remote bean.
But I'm getting NullPointerException when executing the code below. But it works if instead I put the exactly same code in a servlet (doGet for example).
So it's not initializing the placeOrder variable ... How can I fix this? Thank you!

Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10202
    
166

Injection in normal Java clients isn't supported by the spec. You could inject in Java EE "application clients", but that support isn't available in the current AS7 releases.

[My Blog] [JavaRanch Journal]
Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 804
    
    1

Use JNDI lookup instead of DI if you are accessing the bean from within external client.


SCJP6, SCWCD5, OCE:EJBD6.
BLOG: http://leakfromjavaheap.blogspot.com
Leandro Coutinho
Ranch Hand

Joined: Mar 04, 2009
Posts: 417
Thanks Jaikiran and Lucas.

So I need to do something like this:

Exception in thread "main" javax.naming.NoInitialContextException: I get this: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory]
It seems that I need to start JBoss with the -b option. But I'm using Eclipse and I don't know to this in Eclipse.
Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 804
    
    1

Maybe you have to add some .jars to the classpath of your client, especially when you use the client outside the container,
For example while using Glassfish there must be gf-client.jar.
Leandro Coutinho
Ranch Hand

Joined: Mar 04, 2009
Posts: 417
Lucas Smith wrote:Maybe you have to add some .jars to the classpath of your client, especially when you use the client outside the container,
For example while using Glassfish there must be gf-client.jar.

ok. I'm using JBoss AS 7. I download this jbossall-client.jar from here: http://www.java2s.com/Code/Jar/JKL/Downloadjbossallclientjar.htm
Now I'm getting the exception below. How do I know which port to choose?

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EJB3 Null Pointer Exception