2 Replies Latest reply on May 11, 2014 5:21 AM by Wolf-Dieter Fink

    Invoke Remote Session Bean 2.1 in WAS 6.1 from JBoss 7.1

    José Luis Manríquez Newbie

      Hi all,

       

      I need help. I'm trying to invoke a EJB 2.1 deployed in WAS 6.1 from JSF Application deployed in JBoss 7.1 and i get the ClassCastException but i dont know why.

       

      Trace:

       

      21:42:10,673 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) java.lang.ClassCastException

      21:42:10,674 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.jboss.com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:246)

      21:42:10,674 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:158)

      21:42:10,675 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.prototype.test.connector.EJBConnector.getCalculadoraEJB(EJBConnector.java:53)

      21:42:10,676 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.prototype.test.business.CalculadoraSrv.sumar(CalculadoraSrv.java:12)

      21:42:10,677 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.prototype.test.bbeans.HomeBean.sumar(HomeBean.java:48)

      21:42:10,677 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      21:42:10,678 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

      21:42:10,679 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

      21:42:10,680 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at java.lang.reflect.Method.invoke(Unknown Source)

      21:42:10,680 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.apache.el.parser.AstValue.invoke(AstValue.java:262)

      21:42:10,681 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)

      21:42:10,682 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:153)

      21:42:10,683 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)

      21:42:10,684 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:769)

      21:42:10,685 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at javax.faces.component.UICommand.broadcast(UICommand.java:300)

      21:42:10,685 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)

      21:42:10,686 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)

      21:42:10,686 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)

      21:42:10,687 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)

      21:42:10,687 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)

      21:42:10,687 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)

      21:42:10,688 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)

      21:42:10,688 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)

      21:42:10,689 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)

      21:42:10,690 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)

      21:42:10,691 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)

      21:42:10,692 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)

      21:42:10,692 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

      21:42:10,693 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

      21:42:10,694 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)

      21:42:10,694 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)

      21:42:10,695 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)

      21:42:10,695 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)

      21:42:10,696 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at java.lang.Thread.run(Unknown Source)

      21:42:10,715 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) Caused by: java.lang.ClassCastException: com.sun.corba.se.impl.corba.CORBAObjectImpl cannot be cast to org.omg.CORBA.Object

      21:42:10,716 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.jboss.com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:225)

      21:42:10,716 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) ... 33 more

      15:13:13,191 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) java.lang.ClassCastException

      15:13:13,286 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.jboss.com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:246)

      15:13:13,287 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:158)

      15:13:13,289 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.prototype.test.connector.EJBConnector.getCalculadoraEJB(EJBConnector.java:53)

      15:13:13,291 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.prototype.test.business.CalculadoraSrv.sumar(CalculadoraSrv.java:12)

      15:13:13,292 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.prototype.test.bbeans.HomeBean.sumar(HomeBean.java:48)

      15:13:13,293 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      15:13:13,293 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

      15:13:13,294 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

      15:13:13,294 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at java.lang.reflect.Method.invoke(Unknown Source)

      15:13:13,295 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.apache.el.parser.AstValue.invoke(AstValue.java:262)

      15:13:13,295 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)

      15:13:13,296 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:153)

      15:13:13,296 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)

      15:13:13,297 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:769)

      15:13:13,297 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at javax.faces.component.UICommand.broadcast(UICommand.java:300)

      15:13:13,297 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)

      15:13:13,298 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)

      15:13:13,298 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)

      15:13:13,299 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)

      15:13:13,299 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)

      15:13:13,300 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)

      15:13:13,300 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)

      15:13:13,301 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)

      15:13:13,301 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)

      15:13:13,302 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)

      15:13:13,302 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)

      15:13:13,303 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)

      15:13:13,303 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

      15:13:13,304 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

      15:13:13,304 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)

      15:13:13,305 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)

      15:13:13,305 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)

      15:13:13,306 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)

      15:13:13,306 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at java.lang.Thread.run(Unknown Source)

      15:13:13,306 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) Caused by: java.lang.ClassCastException: com.sun.corba.se.impl.corba.CORBAObjectImpl cannot be cast to org.omg.CORBA.Object

      15:13:13,307 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.jboss.com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:225)

      15:13:13,308 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) ... 33 more

       

      jboss-deployment-structure.xml:

      <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">

          <deployment>

              <dependencies>

                  <system export="true">

                      <paths>

                          <path name="com/sun/jndi/cosnaming"/>

                          <path name="com/sun/corba/se/impl/orb"/>

                          <path name="com/sun/corba/se/impl/logging"/>

                          <path name="com/sun/corba/se/impl/javax/rmi/CORBA"/>

                          <path name="org/jacorb/orb"/>

                          <path name="org/omg/CORBA"/>

                      </paths>

                  </system>

              </dependencies>

          </deployment>

      </jboss-deployment-structure>

       

      Java Code:

      Properties env = new Properties();

      final String initCtxFactoryImpl = "com.sun.jndi.cosnaming.CNCtxFactory";

       

      env.put(Context.INITIAL_CONTEXT_FACTORY, initCtxFactoryImpl);

      env.put(Context.PROVIDER_URL, "iiop://localhost:2809/");

       

      try {

           ctx = new InitialContext(env);

      } catch (NamingException e) {

           throw new RuntimeException("No fue posible iniciar contexto para acceder a componente distribuido", e);

      }

      ....

      ....

      final String jndiEJB = "cell/nodes/joseluis-PCNode01/servers/server1/ejb/org/prototype/ejbs/CalculadoraHome";

      try {

        Object home = ctx.lookup(jndiEJB);

        CalculadoraHome calculadoraHome = (CalculadoraHome) PortableRemoteObject.narrow(home, CalculadoraHome.class);

      ...

      ...

       

      Thx.

       

       

        calculadora = (Calculadora) calculadoraHome.create();