• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EJB3 Null Pointer Exception

 
Leandro Coutinho
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use JNDI lookup instead of DI if you are accessing the bean from within external client.
 
Leandro Coutinho
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 808
1
Android Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 423
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic