2 Replies Latest reply on Feb 3, 2007 7:01 AM by mindflyer

    ClassCastException in the InvokeRemoteInterceptor

    mindflyer

      Client application lookups SLSB in the JNDI and invokes its method. If SLSB throws exception (in this example - DAOException), I see on the client side ClassCastException.

      Caused by: java.lang.ClassCastException: net.uk.topdog.td2.common.dao.DAOException
      at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:55)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:53)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:77)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:102)
      at $Proxy4.executeCommands(Unknown Source)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at net.uk.topdog.td2.common.jndi.RemoteProxy.invokeRemote(RemoteProxy.java:75)
      at net.uk.topdog.td2.common.jndi.RemoteProxy.invoke(RemoteProxy.java:40)
      at $Proxy4.executeCommands(Unknown Source)
      at net.uk.topdog.td2.common.dao.client.ClientUnTypedDAOImpl.executeCommands(ClientUnTypedDAOImpl.java:173)
      ... 12 more

      I saw ClassCastException for EJBException also.
      And ClassCastException for NotFoundInDispatcherException if I used clustered SLSB.

      My SessionBean :

      @Stateless(name = "UnTypedEmfDAORemoteSessionBean")
      @Remote(UnTypedEmfSerializableDAO.class)
      @Interceptors({EmfPreparerForSerialization.class})
      public class UnTypedEmfDAORemoteSessionBean implements UnTypedEmfSerializableDAO { ... }

      I use JBoss 4.0.5.GA with jboss-EJB-3.0_RC9_Patch_1 now.
      Earlier I used JBoss 4.0.4.GA with EJB 3.0 RC7 and didn't see ClassCastException.

        • 1. Re: ClassCastException in the InvokeRemoteInterceptor
          alrubinger

          When you updated to 4.0.5, did you also update the libs in the client classpath? Versioning conflicts may explain the CCE.

          S,
          ALR

          • 2. Re: ClassCastException in the InvokeRemoteInterceptor
            mindflyer

            Yes, I updated libs in the client classpath.

            I investigated org.jboss.aspects.remoting.InvokeRemoteInterceptor and found out that in the line

            org.jboss.aop.joinpoint.InvocationResponse response = (org.jboss.aop.joinpoint.InvocationResponse)client.invoke(invocation, null);

            "client.invoke()" returns Exception if the server side has thrown Exception.

            I replaced this line to:

            Object result = client.invoke(invocation, null);
            if ( result instanceof Throwable ) throw (Throwable) result;
            org.jboss.aop.joinpoint.InvocationResponse response = (org.jboss.aop.joinpoint.InvocationResponse) result;

            I'm not sure, that I did correctly, but it works :)