File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes How to call the class in servlet container from the 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 "How to call the class in servlet container from the ejb" Watch "How to call the class in servlet container from the ejb" New topic
Author

How to call the class in servlet container from the ejb

saxena vicky
Greenhorn

Joined: Sep 05, 2005
Posts: 18
How to call the class in servlet container from the ejb

when I try to call the class in the servlet context from the
EJB , I am getting class not found exception.

[ September 07, 2005: Message edited by: saxena vicky ]
[ September 08, 2005: Message edited by: saxena vicky ]
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

It depends on your app. server but typically each deployed application will have its own class loader, so classes on the web apps classpath are not necessarily available to the ejb app, even if they are deployed together in an ear. Which app. server are you using?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
saxena vicky
Greenhorn

Joined: Sep 05, 2005
Posts: 18
I am using Jboss
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

OK. Well in JBoss classes deployed at the root of the ear are available to the ejb app, so you need to jar your common classes and depoy them there.
Valentin Tanase
Ranch Hand

Joined: Feb 17, 2005
Posts: 704
Hi Saxena,


when I try to call the class in the servlet context from the
EJB , I am getting class not found exception.

Which is the right behavior. Usually the classloader architecture of most of the containers should allow servlets to load ejb classes but not the other way around. Think about, is no reason for your business logic to invoke any services of the web/presentation tier. Just for the argument sake imagine that an ejb would call a class packed within your war. If that class is a servlet than is nothing much to say: servlets cannot be invoked directly, they can only handle http requests. On the other hand if that class is a POJO then you can solve this problem packing your application in a different way. Hence you better extract all the common classes from your war and pack them in a common.jar library. You can pack all your modules in an ear and you can make the common.jar available to your ejbs probably editing the manifest file. Again you should check the jboss documentation about tips regarding packaging.
Regards.


I think, therefore I exist -- Rene Descartes
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to call the class in servlet container from the ejb