1 Reply Latest reply on Jul 4, 2012 4:45 AM by mac2009

    ClassCastException at org.jboss.com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(...)

    mac2009

      Hi again,

       

      well, the lookup seems to be ok now (code snippet below). But then following exception occours:

       

      15:24:42,979 ERROR [com.direkt1822.joba.filter.ContextLoaderListener] (MSC service thread 1-3) : java.lang.ClassCastException

          at org.jboss.com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:246) [jboss-rmi-api_1.0_spec-1.0.4.Final.jar:1.0.4.Final]

          at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:158) [jboss-rmi-api_1.0_spec-1.0.4.Final.jar:1.0.4.Final]

          at com.customer.myapp.authob.interfaces.SecuritiesOBUtil.lookupHome(SecuritiesOBUtil.java:19) [myapp-ejb-4.3.0-SNAPSHOT.jar:]

          at com.customer.myapp.authob.interfaces.SecuritiesOBUtil.getHome(SecuritiesOBUtil.java:35) [myapp-ejb-4.3.0-SNAPSHOT.jar:]

          at com.customer.myapp.filter.ContextLoaderListener.createContextLoader(ContextLoaderListener.java:20) [classes:]

          at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:44) [spring-2.5.5.jar:2.5.5]

          at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.13.Final.jar:]

          at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:]

          at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]

          at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)

          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)

          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_31]

          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_31]

          at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_31]

      Caused by: java.lang.ClassCastException: $Proxy13 cannot be cast to org.omg.CORBA.Object

          at org.jboss.com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:225) [jboss-rmi-api_1.0_spec-1.0.4.Final.jar:1.0.4.Final]

          ... 13 more

       

       

      Code:

       

      try {

        Object objRef = initialContext.lookup(jndiName);

         if (java.rmi.Remote.class.isAssignableFrom(narrowTo))

            return javax.rmi.PortableRemoteObject.narrow(objRef, narrowTo);  // line where exception occurs...of course ;-)

         else

            return objRef;

      } finally {

         initialContext.close();

      }

       

      Any idea?

       

      Cheers

      Carsten

        • 1. Re: ClassCastException at org.jboss.com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(...)
          mac2009

          Hi all,

           

          just to close this one, have change the ContextLoaderLister to the LocalHome-Interface cause Remote-Interface isn't necessary.

          But even with the Remote-Interface, the point is:

          Just use the right JNDI-Name for the Interface.

           

          Old JNDI-Name used for

          remote: SecuritiesOB

          local: SecuritiesOBLocal

           

          but should be now for example

          remote: java:app/myapp-ejb-4.3.0-SNAPSHOT/SecuritiesOB!com.customer.myapp.authob.interfaces.SecuritiesOBHome

          local: java:app/myapp-ejb-4.3.0-SNAPSHOT/SecuritiesOB!com.customer.myapp.authob.interfaces.SecuritiesOBLocalHome

           

          Bloody hell of ancient EJB stuff.

          A real pain in the a... to migrate from 4.0.5.GA

           

          Cheers

          Carsten