8 Replies Latest reply on Oct 9, 2005 4:45 PM by darranl

    java.lang.lassCastException during RMI call to ejb

    darranl

      You say your code works with JBoss 2.4, have you made sure that the client is using the jars from 4.0.1 and that it isn't still using the jars from 2.4.

        • 1. java.lang.ClassCastException during RMI call to ejb
          svewap

          Hi,
          i have a similar problem when i want to connect to a EJB:

          java.lang.ClassCastException
          at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:229)
          at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
          at org.apache.jsp.index_jsp._jspService(org.apache.jsp.index_jsp:57)
          at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
          at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
          at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
          at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
          at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
          at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
          at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:153)
          at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
          at
          Caused by: java.lang.ClassCastException: $Proxy89
          at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:212)
          ... 27 more

          The code is:
          Context context = new InitialContext();
          Object ref = context.lookup("InfoSessionFacade");
          InfoSessionFacadeHome home = (InfoSessionFacadeHome) PortableRemoteObject.narrow(ref,
          InfoSessionFacadeHome.class);

          I use Jboss 4.0.2 Final and i use the jboss and tomcat 5.5.9 libraries to compile my files.

          Thanks for any help.

          • 2. Re: java.lang.lassCastException during RMI call to ejb
            svewap

            Hi, after reading a lot of articels now i new, that this is not a bug and i didn't make a mistake. the problem is, that there is a change of settings between jboss 4.0.2 RC1 and 4.0.2 Final, but i don't know what. it has something to do with classloading and virtual machines. everybody says this but nobody says what to do to resolve this problem :-( .
            know i use jboss 4.0.3 RC1 and everything works fine.

            Grüße aus Deutschland,
            Sven

            • 3. Re: java.lang.lassCastException during RMI call to ejb
              antimoine67

              Hello!

              I had the same problem as you (ClassCastException when trying to retrieve the Home class) with Jboss AS 4.0.2.
              I could fix the problem by (reading the readme doc :-) ) and changing two properties:

              in .../conf/jboss-service.xml:
              set true

              and in ../deploy/ear-deployer.xml:
              true

              For me, it no works fine...finally!!!
              I hope this can help you too.

              Bye,
              Sam

              • 4. Re: java.lang.lassCastException during RMI call to ejb
                antimoine67

                Sorry... in my last post, the xml tags I had copied/pasted from the files were ignored.

                So, the changes I have made are:

                set to true the value of the property CallByValue in both files I mentionned.

                • 5. Re: java.lang.lassCastException during RMI call to ejb
                  innerspace

                  Hello and thanks. I indeed missed some class files in the client. In my project layout the classes that the client uses are packaged into the client jar and have to be given in a different place than the jars for linking.

                  • 6. Re: java.lang.lassCastException during RMI call to ejb
                    svewap

                    Thank you antimoine67 for the reference. Now it functions!

                    • 7. Re: java.lang.lassCastException during RMI call to ejb
                      nicolaspeeters

                      Hi,

                      After a lot of pain and readings, changing the CallByValue settings worked for me (I don't get the ClassCastException anymore!)
                      I am building a very simple Statless Session Bean (the most simple HelloWorld type of thing)...

                      Can anybody explain *why* this is needed? This doesn't look like a standard thing to do (especially considering the simplicity of my SSB).

                      I'd really appreciate some insight about this!

                      Nicolas (JBoss 4.0.2, JRE 1.5, wXP)

                      • 8. Re: java.lang.lassCastException during RMI call to ejb
                        darranl

                        Why are you all assuming thay all ClassCastExceptions are equal?

                        Some of you are talking about remote access to EJBs and some of you are talking about accessing EJBs from web applications.

                        Can anybody explain *why* this is needed? This doesn't look like a standard thing to do


                        You have not bothered to describe the architecture of your deployment, there are lots of reasons why people see ClassCastExceptions and they are dependant on what you are deploying.

                        I would guess that you are deploying a war that contains the home and remote interfaces of your bean, if so this is the source of the problem. Remove the interfaces from the war and you should be able to access the bean without the problems.