4 Replies Latest reply on Dec 6, 2008 9:41 PM by msecrist

    $Proxy123 cannot be cast to org.omg.CORBA.Object

    msecrist

      Ok, I'm still trying to solve the mystery on the class cast problem on my EJB 2.0 project. I've eliminated a variety of potential causes including the utility class generated by the annotation mechanisms.

      To recap: I have a web application attempting to invoke a session EJB causing the class cast problem. I've attempted using the following code.

      LeagueFacade l = LeagueFacadeUtil.getHome().create();


      and

       InitialContext ic = new InitialContext();
       Object ref = ic.lookup(LeagueFacadeHome.JNDI_NAME);
       LeagueFacadeHome h = (LeagueFacadeHome)PortableRemoteObject.narrow(ref,LeagueFacadeHome.class);
      


      Both essentially attempt to do the same thing but both also result in the ultimate exeption of:
      $Proxy123 cannot be cast to org.omg.CORBA.Object


      The crux seems to be attempting to invoke an EJB from the web app when they co-reside in the same JBoss container. I have been able to extract the web app out to a separately running Tomcat server and it works fine. I have also been able to create a Java program to locate and invoke the EJB and that works as well. That would suggest that there is something going on between the web container and the EJB container portions of JBoss. Isn't JBoss using Tomcat internally though?

      As I mentioned, I was able to move on by just extracting the web app to a separately running process but not knowing exactly why it doesn't work as a full EAR deployed to JBoss is bothering me.

      Having not gotten responses on the previous posts suggest to me one of the following:
      1. The problem is so simple it isn't worth answering
      2. The problem is so unique, no one has encountered it before
      3. I'm not describing the problem adequately to help someone provide an answer easily (and we all are busy)

      I'm happy to keep digging, but I'm running out of resources. I haven't tried deploying to another container like weblogic yet to see if it is just a JBoss problem. That may be my next step. I have a hunch it is a config problem but not having any other references, I'm having a hard time knowing where to look.

      Thanks for any ideas folks may have.

      Mark

        • 1. Re: $Proxy123 cannot be cast to org.omg.CORBA.Object
          jaikiran

          Mark,

          Please post the home/localhome interface, the session bean skeleton and the remote/local interface code. Also please post the entire exception stacktrace. How are you packaging the applicaiton? Does your WAR and the EJB jar in the EAR both cotain the interfaces?

          Also, please post the output of JNDI tree - follow these steps http://www.jboss.org/community/docs/DOC-9584

          • 2. Re: $Proxy123 cannot be cast to org.omg.CORBA.Object
            msecrist

            Thanks for the reply. The WAR file does contain a copy of the EJBClient.jar file stored in the WEB-INF/lib directory so I think it should be able to access it. The whole thing of course is deployed as an EAR packaged by the Eclipse WTP. I did a quick check and it seems like the same components are in the WAR packaged in the EAR and deployed to JBoss that doesn't work are the same as those in the WAR packaged and deployed to JBoss. Oh, and the EAR does also include the EJBClient.jar file outside the WAR file as well.

            Home interface

            /*
             * Generated by XDoclet - Do not edit!
             */
            package com.leagueplanet.ejb;
            
            /**
             * Home interface for LeagueFacade.
             * @generated
             * @wtp generated
             */
            public interface LeagueFacadeHome
             extends javax.ejb.EJBHome
            {
             public static final String COMP_NAME="java:comp/env/ejb/LeagueFacade";
             public static final String JNDI_NAME="LeagueFacade";
            
             public com.leagueplanet.ejb.LeagueFacade create()
             throws javax.ejb.CreateException,java.rmi.RemoteException;
            
            }
            


            Local Home
            /*
             * Generated by XDoclet - Do not edit!
             */
            package com.leagueplanet.ejb;
            
            /**
             * Local home interface for LeagueFacade.
             * @generated
             * @wtp generated
             */
            public interface LeagueFacadeLocalHome
             extends javax.ejb.EJBLocalHome
            {
             public static final String COMP_NAME="java:comp/env/ejb/LeagueFacadeLocal";
             public static final String JNDI_NAME="LeagueFacadeLocal";
            
             public com.leagueplanet.ejb.LeagueFacadeLocal create()
             throws javax.ejb.CreateException;
            
            }
            


            Skeleton

            /*
             * Generated by XDoclet - Do not edit!
             */
            package com.leagueplanet.ejb;
            
            /**
             * Session layer for LeagueFacade.
             * @generated
             * @wtp generated
             */
            public class LeagueFacadeSession
             extends com.leagueplanet.ejb.LeagueFacadeBean
             implements javax.ejb.SessionBean
            {
             public void ejbActivate() throws javax.ejb.EJBException, java.rmi.RemoteException
             {
            
             super.ejbActivate();
             }
            
             public void ejbPassivate() throws javax.ejb.EJBException, java.rmi.RemoteException
             {
             super.ejbPassivate();
             }
            
             public void setSessionContext(javax.ejb.SessionContext ctx) throws javax.ejb.EJBException, java.rmi.RemoteException
             {
             super.setSessionContext(ctx);
             }
            
             public void unsetSessionContext()
             {
             }
            
             public void ejbRemove() throws javax.ejb.EJBException, java.rmi.RemoteException
             {
             super.ejbRemove();
             }
            
            }
            


            Remote interface

            /*
             * Generated by XDoclet - Do not edit!
             */
            package com.leagueplanet.ejb;
            
            /**
             * Remote interface for LeagueFacade.
             * @generated
             * @wtp generated
             */
            public interface LeagueFacade
             extends javax.ejb.EJBObject
            {
            
             public boolean createLeague( com.leagueplanet.model.League newLeague )
             throws java.rmi.RemoteException;
            
             public boolean doesLeagueExist( java.lang.String name )
             throws java.rmi.RemoteException;
            
             public com.leagueplanet.model.Game findGame( long id )
             throws java.rmi.RemoteException;
            
             public com.leagueplanet.model.League findLeague( long id )
             throws java.rmi.RemoteException;
            
             public com.leagueplanet.model.Location findLocation( long id )
             throws java.rmi.RemoteException;
            
             public com.leagueplanet.model.Player findPlayer( long id )
             throws java.rmi.RemoteException;
            
             public com.leagueplanet.model.Schedule findSchedule( long id )
             throws java.rmi.RemoteException;
            
             public com.leagueplanet.model.Team findTeam( long id )
             throws java.rmi.RemoteException;
            
             public java.util.Set getSchedulesForLeague( java.lang.String league )
             throws java.rmi.RemoteException;
            
             public java.lang.String foo( java.lang.String league )
             throws java.rmi.RemoteException;
            
            }
            


            Stack trace

            21:56:47,819 INFO [EjbModule] Deploying Game
            21:56:47,991 INFO [EjbModule] Deploying LeagueFacade
            21:56:51,194 INFO [BaseLocalProxyFactory] Bound EJB LocalHome 'Game' to jndi 'GameLocal'
            21:56:51,241 INFO [ProxyFactory] Bound EJB Home 'Game' to jndi 'Game'
            21:56:51,257 INFO [BaseLocalProxyFactory] Bound EJB LocalHome 'LeagueFacade' to jndi 'LeagueFacadeLocal'
            21:56:51,257 INFO [ProxyFactory] Bound EJB Home 'LeagueFacade' to jndi 'LeagueFacade'
            21:56:51,272 INFO [EJBDeployer] Deployed: file:/C:/jboss-4.2.3.GA/server/all/tmp/deploy/tmp46360LeaguePlanetEAR.ear-contents/LeaguePlanetEJB.jar
            21:56:51,335 INFO [TomcatDeployer] deploy, ctxPath=/LeaguePlanetWeb, warUrl=.../tmp/deploy/tmp46360LeaguePlanetEAR.ear-contents/LeaguePlanetWeb-exp.war/
            21:56:51,460 INFO [EARDeployer] Started J2EE application: file:/C:/jboss-4.2.3.GA/server/all/deploy/LeaguePlanetEAR.ear
            21:56:51,803 INFO [Http11Protocol] Starting Coyote HTTP/1.1 on http-127.0.0.1-8080
            21:56:51,850 INFO [AjpProtocol] Starting Coyote AJP/1.3 on ajp-127.0.0.1-8009
            21:56:51,882 INFO [Server] JBoss (MX MicroKernel) [4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181439)] Started in 53s:157ms
            21:56:55,053 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
            java.lang.ClassCastException: $Proxy74 cannot be cast to org.omg.CORBA.Object
             at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(Unknown Source)
             at javax.rmi.PortableRemoteObject.narrow(Unknown Source)
             at com.leagueplanet.ejb.LeagueFacadeUtil.lookupHome(LeagueFacadeUtil.java:25)
             at com.leagueplanet.ejb.LeagueFacadeUtil.getHome(LeagueFacadeUtil.java:42)
             at org.apache.jsp.schedule_jsp._jspService(schedule_jsp.java:82)
             at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
             at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
             at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
             at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:336)
             at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
             at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
             at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
             at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
             at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
             at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
             at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
             at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
             at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
             at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
             at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
             at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
             at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
             at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
             at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
             at java.lang.Thread.run(Unknown Source)
            


            And... The JSP result as well
            org.apache.jasper.JasperException: An exception occurred processing JSP page /schedule.jsp at line 19
            
            16: <html>
            17: <%
            18:
            19: LeagueFacadeHome h = LeagueFacadeUtil.getHome();
            20: LeagueFacade l = LeagueFacadeUtil.getHome().create();
            21: League league = l.findLeague(1);
            22: Iterator schedules = league.getSchedules()
            
            
            Stacktrace:
             org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:504)
             org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:415)
             org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:336)
             org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
             javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
             org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
            
            
            root cause
            
            java.lang.ClassCastException
             com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(Unknown Source)
             javax.rmi.PortableRemoteObject.narrow(Unknown Source)
             com.leagueplanet.ejb.LeagueFacadeUtil.lookupHome(LeagueFacadeUtil.java:25)
             com.leagueplanet.ejb.LeagueFacadeUtil.getHome(LeagueFacadeUtil.java:42)
            
            


            • 3. Re: $Proxy123 cannot be cast to org.omg.CORBA.Object
              jaikiran

              See this http://www.jboss.org/community/docs/DOC-9280. When packaging the WAR and the EJB inside an EAR, there should not be multiple packages containing the EJB interfaces, as in your case. Remove the EJBClient.jar from the WEB-INF/lib and let the WAR access them from the one available at the EAR. See if that fixes the problem.

              If not, please post the JNDI tree output, which i requested for in my earlier reply:

              "jaikiran" wrote:

              Also, please post the output of JNDI tree - follow these steps http://www.jboss.org/community/docs/DOC-9584


              1 of 1 people found this helpful
              • 4. Re: $Proxy123 cannot be cast to org.omg.CORBA.Object
                msecrist

                Yup - that looks like the trick. Removing the EJBClient.jar file from the WEB-INF/lib directory got me past that problem.

                Thanks,

                Mark