Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

EJB Client - Local Interface

 
Greenhorn
Posts: 29
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
 
Creator of Enthuware JWS+ V6
Posts: 3341
303
Android Eclipse IDE Chrome
  • 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: 29
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
Posts: 3341
303
Android Eclipse IDE Chrome
  • 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: 29
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
Posts: 3341
303
Android Eclipse IDE Chrome
  • 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: 29
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
Posts: 3341
303
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might want to checkout the examples in my notes: OCEEJBD-Links
 
Arch enemy? I mean, I don't like you, but I don't think you qualify as "arch enemy". Here, try this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic