This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Svelte and Sapper in Action and have Mark Volkmann on-line!
See this thread for details.
Win a copy of Svelte and Sapper in Action this week in the JavaScript 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Cannot call EJB from Servlet

Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am developing J2EE project in which a servlet calls an EJB on WAS 5.1.x using RSA 6. In the web project, I have made a reference to the EJB project such that there is no syntax error in the web project. A snippet of code is shown as follows:

Object oRef = ic.lookup("ejb/ejbs/HdlrHome");

// Error occurs here
HdlrHome abc = (HdlrHome) PortableRemoteObject.narrow
( oRef, HdlrHome.class );
Hdlr k = abc.create();
String str = k.getString();

The content of the /WebContent/META-INF/MANIFEST.MF is shown below, indicating the web project will reference the EJB Client JAR file "HdlrClient.jar":

Manifest-Version: 1.0
Class-Path: HdlrClient.jar

Finally, I look into the EAR file which already included the WAR file as "Modules" and the EJB Client JAR "HdlrClient.jar" as "Project Utility JARs" that I think the web servlet should be able to call the EJB as the client .class files are already include in the EAR file as a whole.

However, when I run the servlet after deploying the EAR file, WAS server complained the Class "HdlrHome" cannot be found:

E SRVE0026E: [Servlet Error]-[ejbs.HdlrHome]: java.lang.NoClassDefFoundError: ejbs.HdlrHome

Anyone knows why it is so and how to resolve it?
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

You have to use a different way to query for your EJB when you are running it in a container.

java.lang.Object ejbHome =

java: ... is required as per IBM websphere documetation.

IBM documentation
F is for finger. Can you stick your finger in your nose? Doesn't that feel nice? Now try this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic