• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

EJB Client - Local Interface

 
Greenhorn
Posts: 29
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Creator of Enthuware JWS+ V6
Posts: 3412
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What kind of class is testP2p? A CDI or an EJB, or a POJO?
 
Amandeep Singh Ghai
Greenhorn
Posts: 29
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 3412
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 29
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 3412
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 29
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 3412
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You might want to checkout the examples in my notes: OCEEJBD-Links
 
I'm THIS CLOSE to ruling the world! Right after reading this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic