This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EJB Client - Local Interface

 
Amandeep Singh Ghai
Greenhorn
Posts: 24
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am making my way to OCE EJB Certification & have one question.

* I created a EJB Project & a stateless Session Bean with a local interface
* In the same package I created a Java Class with Main method. This class has code like:




Problem:
The mBean instance is always null. Somehow, dependency injection is not working. I also checked JBoss deployment & it does contains JNDI Bindings for this bean.



Please advise further!

Thanks, Aman
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2534
113
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What kind of class is testP2p? A CDI or an EJB, or a POJO?
 
Amandeep Singh Ghai
Greenhorn
Posts: 24
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
testP2p is a normal POJO & is deployed together with the EJB in the same JAR file
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2534
113
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
POJO's are not managed by the container (unless it is a CDI-bean) and that is why this won't work. Make testP2p Stateless and you can see that works.
 
Amandeep Singh Ghai
Greenhorn
Posts: 24
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I added code like this but it still does not work. EJB Reference is still null.



Please advise
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2534
113
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't use static methods.

The easiest way to test your EJB is from a Servlet, which means you have to create a Dynamic Web Project in Eclipse.
 
Amandeep Singh Ghai
Greenhorn
Posts: 24
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I do JNDI lookup from application-client that is deployed together with EJB JAR in the same EAR file? I have seen several examples to connect remote-client to EJBs, but none that tells how to connect application-client (local EJB Client) to EJB using JNDI.

Please advise!
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2534
113
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might want to checkout the examples in my notes: OCEEJBD-Links
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic