wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes Calling class in a web module from EJB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Calling class in a web module from EJB" Watch "Calling class in a web module from EJB" New topic
Author

Calling class in a web module from EJB

praveen kanakarajan
Ranch Hand

Joined: Apr 27, 2005
Posts: 54
Hi
I need to modify and exisitng application which runs on a websphere.As per the new requirement i need to call a class in webmodule from EJB.Is it a correct to call a class from EJB jar.Also there's a possibility that this appplication can be deployed in a clustered environment.I learnt from sites that shared library option is there.if thats the solution then i need to state the reason why i need to move the class to share library.I would be greatful if someone could tell me the drawbacks of calling class in a webmodule from EJB.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30123
    
150

Praveen,
Typically the web layer calls the ejb layer. Doing the opposite would introduce a circular dependency.

This is a common sign that you really have three units: the common code, the web module and the ejb module. If you refactor the common code into it's own module/jar, you can have the real web module (servlets, etc) and ejb module call it without a circular dependency.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
magesh sripathy
Greenhorn

Joined: Apr 06, 2006
Posts: 27
If you want your ejb to call the class in a webmodule,move those classes in the APP-INF directory of the application ,so that both your ejb module and your webmodule can able to access it now.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30123
    
150

Originally posted by magesh sripathy:
If you want your ejb to call the class in a webmodule,move those classes in the APP-INF directory of the application ,so that both your ejb module and your webmodule can able to access it now.

Is APP-INF a standard? I've seen it in WebLogic, but not JBoss or WebSphere. In other apps, I've just seen the jar files in the root of the EAR (or a lib directory under it.)
praveen kanakarajan
Ranch Hand

Joined: Apr 27, 2005
Posts: 54
I solved it somehow.but i dont know whether its the correct method.I loaded both war and ejb jar with same class loader which websphere provides and then it was working.I would like to know the drawbacks of doing the said method.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Calling class in a web module from EJB
 
Similar Threads
calling an ejb from jsp
Class Cast Problem using PortableRemoteObject.narrow
Remote call or local call?
Method Invocation
EJB Local Bean Call from Web Container