Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to call the class in servlet container from the ejb

 
saxena vicky
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
saxena vicky
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using Jboss
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic