• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

EJB3 Null Pointer Exception

 
Ranch Hand
Posts: 430
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!

 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 430
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 430
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?

 
reply
    Bookmark Topic Watch Topic
  • New Topic