• 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

new to EJB : EJB 3.0 queries

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,

i am a ejb/ejb3.0 newbie .I am fairly comfortable with developing single projects with lots of ejb 's in it.But the problem
comes when i try to harness the real power of EJB.I am using the glassfish eclipse bundle.

Here is what i want to do >>

case 1>>

build 2 simple ejbs all in three different ejb project.

ejb1,ejb 2,

ejb2 calls a business method of ejb1
servlet calls a business method of ejb 2.

in this case how should the dependency between the projects be made.I tried adding the generated project "ejb1Client" with local and remote interface for ejb1 to the
dependent projects of ejb2.ejb2 compiles fine but while deploying I get errors.same for the servlet.

case 2>>

does the @EJB annotation work also for the remote invocation of ejb.
(how would we tell the tag on which server the target ejb is deployed ..)

Any help would be appreciated.

regards,
shobhit




 
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hopefully I understand your question correctly.

With EJB 3.0, if you need to inject an EJB into another EJB or into a Servlet, you can just use @EJB annotation. Another way is to use JNDI lookup.
 
sh. garg
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Freddy Wong wrote:Hopefully I understand your question correctly.

With EJB 3.0, if you need to inject an EJB into another EJB or into a Servlet, you can just use @EJB annotation. Another way is to use JNDI lookup.



Hi Freddy ,

Thanks for replying.
Ya I know that I can use @EJB for dependency injection.
What I want to know is that if i have my ejbs in several different projects then how do I call ejb in one project from an ejb in another project.
how should the EAR be packaged/how do we add project level dependecies in this case.

2)is it possible to call a remote ejb via @EJB annotation.

Thanks
Shobhit
 
Greenhorn
Posts: 15
Eclipse IDE Firefox Browser Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi:

In this case, the client is a bean session (may be component web: JSP,Servlet,JSF, etc....) and
the services are in other projects ejb.

Sessions bean can be accessed using:

- Through JNDI lookup.
- Through dependency injection.

Dependency injection is supported only managed classes whose lifecycle is managed
by the container.
If the client is a EJB then you can use @EJB annotation o JNDI lookup,
if the client is a component web then you must ensure that are managed classes for decide
access type.

The bussines components can be in different packages.

I recommend seeing:
EJB 3 in action:
12.2.1. Accessing session beans using dependency injection.

By.
 
reply
    Bookmark Topic Watch Topic
  • New Topic