3 Replies Latest reply on Nov 4, 2010 3:33 AM by wdfink

    java.lang.ClassCastException in EBJ lookup

    sgingade

      code:

       

       

      try{

      Context ctx;

      ServiceRequestControlHome ejbHome;

      ServiceRequestControl serviceRequestController;

       

      // Get the EJB

      new InitialContext();ejbHome = (ServiceRequestControlHome) ctx.lookup("ebccs.common.ServiceRequestControl"); ====> I get java.lang.ClassCastException here.

      ctx =

       

       

       

      Can any help me on the issue.

       

      Thank You.

      entry in jboss.xml :

       

      <session>

      <ejb-name>servicerequestcontroller</ejb-name>

      <jndi-name>ebccs.common.ServiceRequestControl</jndi-name>

      <call-by-value>false</call-by-value>

      <configuration-name>Pool Size Stateless Session Bean</configuration-name>

      </session>

       

       

      entry in ejb-jar.xml :

      <session>

      <ejb-name>servicerequestcontroller</ejb-name>

      <home>ca.cgi.ebccs.common.servicerequestcontroller.ServiceRequestControlHome</home>

      <remote>ca.cgi.ebccs.common.servicerequestcontroller.ServiceRequestControl</remote>

      <ejb-class>ca.cgi.ebccs.common.servicerequestcontroller.ServiceRequestControlBean</ejb-class>

      <session-type>Stateless</session-type>

      <transaction-type>Container</transaction-type>

      <env-entry>

      <env-entry-name>orRequestQueue</env-entry-name>

      <env-entry-type>java.lang.String</env-entry-type>

      <env-entry-value>bles.queue.OntOrdReq;bles.queue.QbcOrdReq</env-entry-value>

      </env-entry>

      <env-entry>

      <env-entry-name>qrRequestQueue</env-entry-name>

      <env-entry-type>java.lang.String</env-entry-type>

      <env-entry-value>bles.queue.QbcOrdReq;bles.queue.OntOrdReq</env-entry-value>

      </env-entry>

      <env-entry>

      <env-entry-name>EmailQueue</env-entry-name>

      <env-entry-type>java.lang.String</env-entry-type>

      <env-entry-value>bles.queue.Email1Req;bles.queue.Email2Req</env-entry-value>

      </env-entry>

      <env-entry>

      <env-entry-name>expiryLimitMin</env-entry-name>

      <env-entry-type>java.lang.Integer</env-entry-type>

      <env-entry-value>240</env-entry-value>

      </env-entry>

      <env-entry>

      <env-entry-name>priority</env-entry-name>

      <env-entry-type>java.lang.Integer</env-entry-type>

      <env-entry-value>5</env-entry-value>

      </env-entry>

      </session>

        • 1. Re: java.lang.ClassCastException in EBJ lookup
          wdfink

          It looks like that you use EJB2!

           

          Here you have to lookup as followed:

          Object objRef = initialContext.lookup("ebccs.common.ServiceRequestContro");
          ServiceRequestControlHome home = javax.rmi.PortableRemoteObject.narrow(objRef, ServiceRequestControlHome.class);

          • 2. Re: java.lang.ClassCastException in EBJ lookup
            sgingade

            Thanks for the reply.

             

            I narrowed the lookup, but ran into following exception. Any suggestions?

             

            java.lang.ClassCastException
                 com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:229)
                 javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
                 ca.cgi.ebccs.common.input.OrderMAXCustProfServlet.doPost(OrderMAXCustProfServlet.java:116)
                 javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
                 javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
                 org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
            

             

            root cause

            java.lang.ClassCastException: $Proxy240 cannot be cast to org.omg.CORBA.Object
                 com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:212)
                 javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
                 ca.cgi.ebccs.common.input.OrderMAXCustProfServlet.doPost(OrderMAXCustProfServlet.java:116)
                 javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
                 javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
                 org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

            • 3. Re: java.lang.ClassCastException in EBJ lookup
              wdfink

              Are you sure that 'ebccs.common.ServiceRequestControl' name in JNDI points to the Home interface.

              Please look into the JNDIView of the jmx-console (and post it)

              A toString() log output of the 'objRef' might help because you will see some informations about the proxy object.

               

              Also you don't prove that you are using EJB2, the approach is not for EJB3!