Win a copy of Pro Spring MVC with WebFlux: Web Development in Spring Framework 5 and Spring Boot 2 this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

Accessing EJB from servlet in WAR file

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 977
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic