• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Returning a handle to a stateful session bean

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm having a problem returning a handle to a stateful session bean. A ClassNotFoundException is returned from the readObject() method of ObjectInputStream. The class it cannot find is the stub to the session bean that I am attempting to get a handle for. I can see that it exists in the correct package.
I'm using a service locator pattern to get the handle and then I store it in an HttpSession object in my servlet through a Business Delegate. When I want to get the handle to the session bean again I call the service locator through my business delegate passing the handle id through to the getService(String id) method of my service locator:
public static EJBObject getService(String id) throws ServiceLocatorException {
if (id == null) {
throw new ServiceLocatorException("test");
}
try {
byte[] bytes = new String(id).getBytes();
InputStream io = new
ByteArrayInputStream(bytes);
ObjectInputStream os = new
ObjectInputStream(io);
javax.ejb.Handle handle =
(javax.ejb.Handle)os.readObject();
return handle.getEJBObject();
} catch(Exception ex) {
ex.printStackTrace();
throw new ServiceLocatorException("test");
}
}
The problem I have is that when it gets to the line
javax.ejb.Handle handle =
(javax.ejb.Handle)os.readObject();
os.readObject() returns a class not found exception:
java.lang.ClassNotFoundException: com.waersystems.ejb.supplier._SupplierMaintenance_Stub
That is the correct stub for the session object and it exists in that package so why am I getting the exception? I'm using Websphere Studio Application Developer 5. Any ideas would be greatly appreciated.
 
Ranch Hand
Posts: 227
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is happening because the stubs are not available to your web app. Are you deploying as a EAR or as a EJB JAR and a seperate WAR?
 
DC Roberts
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have an EAR that includes my web and my EJB projects. The build path of the web project references the EJB project. I have tried adding the stub files to the web project resources without success.
reply
    Bookmark Topic Watch Topic
  • New Topic