1 Reply Latest reply on Dec 26, 2006 12:28 PM by bart1985

    classcastexception on redeploy

    bart1985

      Hello,

      I am relatively new to EJB3.0 and I am currently developing session and entity beans for a new application.

      I'm using Jboss-4.0.5 and when I deploy the first time and I use a standalone application to test my sessionbeans, everything works fine. But when I redeploy my .jar application and use that standalone application again to invoke a sessionbean that passes a remote interface of another sessionbean, I get a classcastexception on PortableRemoteObject.narrow in the standalone application!

      This is the remote interface that I invoke to get another sessionbeans remote interface:

      @Remote
      public interface PermissionRemote

      {
      public SchoolsRemote getSchoolsBean();//UserlogRemote ulr);
      }

      And then the interface that causes the classcastexception:

      @Remote
      public interface SchoolsRemote
      {
      public boolean subscribeSchool(String adminFullName,
      String adminUserName,
      String adminEmail,
      String adminPhoneNumber,
      String adminPassword,
      String schoolName);
      //public School findSchool(int pKey);
      public String sayHi();
      }

      The JBoss error:

      11:08:09,078 ERROR [STDERR] java.lang.ClassCastException
      11:08:09,078 ERROR [STDERR] at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:229)

      11:08:09,078 ERROR [STDERR] at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
      11:08:09,078 ERROR [STDERR] at schoolTime.ejb.permission.PermissionBean.getSchoolsBean(Unknown Source)
      11:08:09,078 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      11:08:09,078 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      11:08:09,078 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      11:08:09,078 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
      11:08:09,078 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
      11:08:09,078 ERROR [STDERR] at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
      11:08:09,078 ERROR [STDERR] at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.
      java:63)
      11:08:09,078 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      11:08:09,078 ERROR [STDERR] at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEn
      tityManagerInterceptor.java:54)
      11:08:09,078 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      11:08:09,078 ERROR [STDERR] at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
      11:08:09,078 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      11:08:09,078 ERROR [STDERR] at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
      11:08:09,078 ERROR [STDERR] at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:197)
      11:08:09,078 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      11:08:09,078 ERROR [STDERR] at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
      11:08:09,078 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      11:08:09,078 ERROR [STDERR] at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.
      java:62)
      11:08:09,078 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      11:08:09,109 ERROR [STDERR] at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java
      :77)
      11:08:09,109 ERROR [STDERR] at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor
      .java:131)
      11:08:09,109 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      11:08:09,109 ERROR [STDERR] at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
      11:08:09,109 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      11:08:09,109 ERROR [STDERR] at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:10
      6)
      11:08:09,109 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      11:08:09,109 ERROR [STDERR] at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:263)
      11:08:09,109 ERROR [STDERR] at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106)
      11:08:09,109 ERROR [STDERR] at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandle
      r.java:82)
      11:08:09,109 ERROR [STDERR] at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:828)
      11:08:09,109 ERROR [STDERR] at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:681)
      11:08:09,109 ERROR [STDERR] at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:358)
      11:08:09,109 ERROR [STDERR] at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:398)
      11:08:09,109 ERROR [STDERR] at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:239)
      11:08:09,109 ERROR [STDERR] Caused by: java.lang.ClassCastException: $Proxy93
      11:08:09,109 ERROR [STDERR] at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:212)

      11:08:09,109 ERROR [STDERR] ... 36 more

      If anybody can help, I will be most grateful.

        • 1. Re: classcastexception on redeploy
          bart1985

          Well, I finally found what was causing this classcastexception;

          I was using a standalone client to test my EJB's. When the standalone client looked up a sessionbean, it seems remote interface was kept alive. When I redeploy my application, JBoss doesn't replace the old interface with the new one. I don't know why this is, but I think it has something to do with the client stub and that the underlying connections stay alive.

          Now I've put everything in an ear application and use a test servlet to test my EJB's instead of a standalone client.

          I hope this may help if you're having the same ClasscastExceptions....

          Bart