EJB design: ClassCastException

  1. ClassCastException (5 messages)


       I have stored statfull session bean object in httpsession object, then I have extracted the bean using getattribute method, when casting the extracted object I have following exception :

    [8/11/05 13:27:25:172 AST] 00000044 SystemErr R java.lang.ClassCastException: com.fact._CentralSF_Stub
    at com.fact.ChequeBookSLEJB.requestBook(ChequeBookSLEJB.java:83)
    at com.fact.EJSRemoteStatelessChequeBookSL_9a1bf50d.requestBook(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:85)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:58)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java(Compiled Code))
    at java.lang.reflect.Method.invoke(Method.java(Compiled Code))
    at com.ibm.rmi.util.ProxyUtil$4.run(ProxyUtil.java:727)
    at java.security.AccessController.doPrivileged1(Native Method)
    at java.security.AccessController.doPrivileged(AccessController.java:351)
    at com.ibm.rmi.util.ProxyUtil.invokeWithClassLoaders(ProxyUtil.java:725)
    at com.ibm.CORBA.iiop.ClientDelegate.invoke(ClientDelegate.java:1121)
    at $Proxy13.requestBook(Unknown Source)
    at com.fact._ChequeBookSL_Stub.requestBook(_ChequeBookSL_Stub.java:263)
    at fact.client.MainServicesServlet.doPost(MainServicesServlet.java:502)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1212)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:629)
    at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:80)
    at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1657)
    at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:77)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:421)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:367)
    at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:94)
    at com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java:548)
    at com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java:601)
    at com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java:934)
    at com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java:1021)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1332)

    I am using WebSphere Application Server 6.0.
    Our aplication is running on Bea Weblogic 8.1 without giving that exception.


    Threaded Messages (5)

  2. WAS Stubs[ Go to top ]

       My first question would be if the SFSB you are accessing is truly remote, if not, then you having something misconfigured in either JNDI or in the rmic process you used to originally generate your deployment code. If you are accessing a remote EJB, did you perform a narrow prior to storing the Stub in the HTTP session? This could be what is causing the issue.


  3. WAS Stub[ Go to top ]

    Thanx Weston, I appreciate your help.

    Actually, Our jars and wars running on the same JVM (deployed on same application server).

    One important issue I should tell you about it:
    After deploying ejb application , I have copied generated stubs(after extracting them) into the war application and deploy it.

    I have store SFSB on HTTP Session using the following code:
    home0 = (OracleHandlerSLHome) ctx.lookup("AppCtx/OracleHandlerSL");
    the_ejb = home0.create();
    CentralSF the_ejb1 = null;
    String userValidate = the_ejb.validateLogin(userID,Password,"NET","en");
    int aa = (new Integer(userValidate.substring(0, 1))).intValue();

                           case 1: /** success login */
                 the_ejb1 = the_ejb.getCentralSF();
                 session.setAttribute("RemoteStub", the_ejb1);

  4. WAS Stub continued[ Go to top ]


       Then if you are in the save VM, then you really shouldn't be using the remote stubs, unless there is something I am missing. Typically, you would not copy the stubs into your web application. Usually, you would use an ejb-ref and point to the ejb-jar. Are you deploying everything as part of the same EAR?

  5. WAS Stub[ Go to top ]

    I am not using EAR file , I have deployed the applications as separated wars and jars.
  6. WAS[ Go to top ]

    Thanx Weston.

    I have solved the problem using ear file.