Problem Accessing Session Bean

S

sid_mulpuru

Hi,


I would greatly appreciate your help since i am stuck with this error
for more than a week now ..


I have been trying to access the remote home interface of a session
bean from a java class belonging to a different
web Application.


This is the code segment :


private static EJBHome lookupTargetHome(String jndiName, Class
homeClass,String factoryName) throws NamingException {


java.util.Properties properties = new java.util.Properties();


properties.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,
factoryName);


javax.naming.InitialContext initialContext =
getInitialContext(properties);


java.lang.Object obj = initialContext.lookup(jndiName);


EJBHome home = (EJBHome) javax.rmi.PortableRemoteObject.narrow(obj,
homeClass);


return home;



}


I have two Web Applications and the EJB packaged into a single EAR.
I am running this on WSAD 5.1 test server.

This is the exception i am getting:


java.lang.ClassCastException: cannot cast class
com.ibm.ejs.container._EJSWrapper_Stub to interface
com.mayco.ldap.ejbs.LdapEjbsHome
at
com.ibm.rmi.javax.rmi.PortableRemoteObject.narrow(PortableRe­moteObject.java:366)

at
javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.j­ava:146)
at
com.mayco.ldap.EJBLdapHelper.lookupTargetHome(EJBLdapHelper.­java:104)

at com.mayco.ldap.EJBLdapHelper.getTargetHome(EJBLdapHelper.jav­a:81)
at com.mayco.ldap.MayLdapServlet.getLdapEJB(MayLdapServlet.java­:374)
at
com.mayco.ldap.MayLdapServlet.checkUserBean(MayLdapServlet.j­ava:201)
at
com.mayco.ldap.MayLdapServlet.processRequest(MayLdapServlet.­java:448)

at com.mayco.ldap.MayLdapServlet.service(MayLdapServlet.java:49­7)
at
com.ibm.ws.webcontainer.servlet.StrictServletInstance.doServ­ice(StrictServletInstance.java:110)

at
com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._serv­ice(StrictLifecycleServlet.java:174)

at
com.ibm.ws.webcontainer.servlet.IdleServletState.service(Str­ictLifecycleServlet.java:313)

at
com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.servi­ce(StrictLifecycleServlet.java:116)

at
com.ibm.ws.webcontainer.servlet.ServletInstance.service(Serv­letInstance.java:283)

at
com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.d­ispatch(ValidServletReferenceState.java:42)

at
com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dis­patch(ServletInstanceReference.java:40)

at
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handl­eWebAppDispatch(WebAppRequestDispatcher.java:948)

at
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispa­tch(WebAppRequestDispatcher.java:530)

at
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forwa­rd(WebAppRequestDispatcher.java:176)

at org.apache.jsp._index._jspService(_index.java:144)
at
com.ibm.ws.webcontainer.jsp.runtime.HttpJspBase.service(Http­JspBase.java:89)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
com.ibm.ws.webcontainer.jsp.servlet.JspServlet$JspServletWra­pper.service(JspServlet.java:357)

at
com.ibm.ws.webcontainer.jsp.servlet.JspServlet.serviceJspFil­e(JspServlet..java:675)

at
com.ibm.ws.webcontainer.jsp.servlet.JspServlet.service(JspSe­rvlet.java:773)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
com.ibm.ws.webcontainer.servlet.StrictServletInstance.doServ­ice(StrictServletInstance.java:110)

at
com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._serv­ice(StrictLifecycleServlet.java:174)

at
com.ibm.ws.webcontainer.servlet.IdleServletState.service(Str­ictLifecycleServlet.java:313)

at
com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.servi­ce(StrictLifecycleServlet.java:116)

at
com.ibm.ws.webcontainer.servlet.ServletInstance.service(Serv­letInstance.java:283)

at
com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.d­ispatch(ValidServletReferenceState.java:42)

at
com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dis­patch(ServletInstanceReference.java:40)

at
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handl­eWebAppDispatch(WebAppRequestDispatcher.java:948)

at
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispa­tch(WebAppRequestDispatcher.java:530)

at
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forwa­rd(WebAppRequestDispatcher.java:176)

at
com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppIn­voker.java:79)

at
com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHo­ok(WebAppInvoker.java:201)

at
com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.ha­ndleInvocation(CachedInvocation.java:71)

at
com.ibm.ws.webcontainer.cache.invocation.CacheableInvocation­Context.invoke(CacheableInvocationContext.java:114)

at
com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatch­ByURI(ServletRequestProcessor.java:186)

at
com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.se­rvice(OSEListener.java:334)

at
com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(Ht­tpConnection..java:56)

at
com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConn­ection.java:610)

at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:435)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:593)


Both the webapps have the ejb checked in their MANIFEST.MF file..


This is the EJB deployment descriptor:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise
JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar id="ejb-jar_ID">
<display-name>Mayco_LdapEJBV5</display-name>
<enterprise-beans>
<session id="Session_1107557246140">
<ejb-name>LdapEjbsBean</ejb-name>
<home>com.test.ldap.ejbs.LdapEjbsHome</home>
<remote>com.test.ldap.ejbs.LdapEjbs</remote>
<ejb-class>com.test.ldap.ejbs.LdapEjbsBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>


</enterprise-beans>
</ejb-jar>


Please let me know your thoughts on the excpetion and what needs to be
done so i can access the Session EJB's in wsad.


Thanks for your help
Sid
 
S

sid_mulpuru

I think it is not a code problem since the code works on production on
websphere. I am trying to run the same app from within wsad on my
computer and it fails out with the error of class cast exception.

Here is how it I have it setup. I have three webapplications one has
java classes that access the session bean (which is a jar file included
in the EAR) and another has utility java classes and the third one is
for login authentication using SSO. The main application is also a
webapplication where i use the other classes for authentication and
authorization.

The login works fine but where it fails is when it accesses the session
bean which gets the profile info for the authenticated user from LDAP

All of these are packed into one single EAR and deployed. If i put the
session bean as part of the webapplication that uses it and not with
the EAR then a class not found exception occurs. If i make it part of
the EAR then the class cast exception is being triggered. Please help
me with this problem.

Thanks
Sid
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top