This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes how to call EJB2.0 from one apllication into another? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "how to call EJB2.0 from one apllication into another?" Watch "how to call EJB2.0 from one apllication into another?" New topic
Author

how to call EJB2.0 from one apllication into another?

Prashant Bhardwaj
Greenhorn

Joined: Jul 25, 2006
Posts: 16
hi,
I am new to EJB.We have an application made in EJB2.0 that has
an architecture as follows:
web-->service/business delegate-->control(session beans)-->entity beans.
I need to to access data provided by one application from another application.I believe EJBs provide different ways for that by accessing the remote interface, however I need to choose a clean way so that I don't have to put the ejb client jars in the server classpath.
Can you please provide help (preferably code excerpts as well)?
Someone told me that it might be possible using reflection...
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17258
    
    6

Can you explain this a bit further;

however I need to choose a clean way so that I don't have to put the ejb client jars in the server classpath.


What EJB client jars? Any client can call an EJB2.0, if that other client is also deployed in the same server, then it should be able to do local lookups and keep it in the same JVM, so that the jar that you would give to a remote client does not need to be given to the client in the same app server. Is that what you mean?

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Prashant Bhardwaj
Greenhorn

Joined: Jul 25, 2006
Posts: 16
ok, my bad for not having described the enviornment completely.
Ours is a distributed enviornment and we have 2 application servers administered by a managed server (weblogic 8.2).
Take it for granted that the applications are on different JVMs.
Now, if I want to use the EJB in application 'A' from another application 'B' by using the remote server, then the only way I know to do that is by putting the client jars of 'A' in server classpath so that 'B' can have access to them at runtime.
However, doing that would make hot deployments difficult, besides its not a good practice to keep such jar files in server classpath.
Phew!, does that explain the problem in its entirity?
Prashant Bhardwaj
Greenhorn

Joined: Jul 25, 2006
Posts: 16
sorry. Read "remote server" as remote interface in my statement above.
And also by client jars, I mean the Remote interface(stub) class files.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17258
    
    6

OK, so App A is a remote client of App B, so App A must have the client jars, this is not a bad practice, whether App A is in a different App Server or not.

If you really wanted to, you could front App B with Web Services so App A just calls a web service, if you want, but that will add a little overhead.

Mark
Prashant Bhardwaj
Greenhorn

Joined: Jul 25, 2006
Posts: 16
ok, I had to go through the embarassment of our mutual idea being rejected by my Technical Manager, but found the answer anyway from him. :-|

Putting ejb-client jars from application A into another Application B is bad because then you have to update the client jars in B every time you change application A.It also means that you are making cross-references between application codes.

The best way out of it is (he told me 2 more, but they went over the head, besides, he told me this one is the best ) :
"Use EJB reflection". Its more costly than any other solution, but its the cleanest way for the said purpose.
 
jQuery in Action, 2nd edition
 
subject: how to call EJB2.0 from one apllication into another?