• 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
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

EJB Client - Local Interface  RSS feed

 
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
Bartender
Posts: 3142
276
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: 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
Bartender
Posts: 3142
276
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: 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
Bartender
Posts: 3142
276
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: 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
Bartender
Posts: 3142
276
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!