This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes BEA/Weblogic and the fly likes Accessing EJB from servlet in WAR file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » BEA/Weblogic
Bookmark "Accessing EJB from servlet in WAR file" Watch "Accessing EJB from servlet in WAR file" New topic
Author

Accessing EJB from servlet in WAR file

Vinu krish
Greenhorn

Joined: Nov 20, 2003
Posts: 16
Hi,
I have a EJB file and I have a WAR file. I have deployed them as seperate applications. WHen both are in a EAR file it works fine. But if I deploy them separately then the WAR file does not recognize the EJB home and remote interface. I have specified <ejb-reference-description> in weblogic.xml and also <ejb-ref> in web.xml as suggested by docs. Here are the pieces of code
weblogic.xml
<weblogic-web-app>
<reference-descriptor>
<ejb-reference-description>
<ejb-ref-name>MyFirstStatelessBean</ejb-ref-name>
<jndi-name>ejb/MyFirstStatelessBeanHome</jndi-name>
</ejb-reference-description>
</reference-descriptor>
</weblogic-web-app>
and web.xml
<ejb-ref>
<ejb-ref-name>MyFirstStatelessBean</ejb-ref-name>
<ejb-ref-type>javax.ejb.SessionBean</ejb-ref-type>
<home>myejbs.ejbs.MyFirstStatelessBeanHome</home>
<remote>myejbs.ejbs.MyFirstStatelessBeanRemote</remote>
</ejb-ref>
weblogic-ejb-jar.xml
<weblogic-enterprise-bean>
<ejb-name>MyFirstStatelessBean</ejb-name>
<stateless-session-descriptor>
</stateless-session-descriptor>
<reference-descriptor>
</reference-descriptor>
<jndi-name>ejb/MyFirstStatelessBeanHome</jndi-name>
</weblogic-enterprise-bean>
Can anyone tell me where I am going wrong. What else should I add in my WAR file to access the EJB files. I am gettin the following exception
<Error> <HTTP> <101017> <[ServletContext(id=6100815,name=FreshEARWeb,context-path=/FreshEARWeb)] Root cause of ServletException
java.lang.NoClassDefFoundError: myejbs.ejbs.MyFirstStatelessBeanHome
Thanks in advance,
Vinu
Marcos Maia
Ranch Hand

Joined: Jan 06, 2001
Posts: 977
Hi,
the home and component interfaces of your ejb are part of the client view of an ejb, knowing this you have to(mandatory) package them with your war archive.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Accessing EJB from servlet in WAR file
 
Similar Threads
calling an ejb from jsp
Problem: creating EJBs in Client in Weblogic7.0
Error----web app could not find ejb module.
Deploying MDB in web application
Need help in calling a EJB from a WAR file