aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes new to EJB : EJB 3.0 queries Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "new to EJB : EJB 3.0 queries" Watch "new to EJB : EJB 3.0 queries" New topic
Author

new to EJB : EJB 3.0 queries

sh. garg
Greenhorn

Joined: Jan 21, 2009
Posts: 10
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




Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959

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.


SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
My Blog
sh. garg
Greenhorn

Joined: Jan 21, 2009
Posts: 10
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
Yair Ivan
Greenhorn

Joined: Jul 13, 2008
Posts: 15

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.


SCJP 6.0, SCBCD 5.0, SCDJWS 5.0
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: new to EJB : EJB 3.0 queries