3 Replies Latest reply on Dec 26, 2009 10:34 AM by jaikiran pai

    Class Cast Error

    Charlie Kelly Newbie

      Hi,

      I'm using the EJB3 Calculator tutorial on an (unmodified) 5.1.0GA server.

       

      Within client I'm using the statement:

       

      Calculator calculator = (Calculator) ctx.lookup("CalculatorBean/remote");

       

      and receive this error:

       

      Exception in thread "main" java.lang.ClassCastException: javax.naming.Reference cannot be cast to org.jboss.tutorial.stateless.bean.Calculator
          at org.jboss.tutorial.stateless.client.Client.main(Client.java:42)

       

      I will appreciate any help or suggestions.

       

      Thanks

       

      Charlie

        • 1. Re: Class Cast Error
          jaikiran pai Master

          How are you running the tutorial? Looks like your client classpath does not have jbossall-client.jar (and the other jars referenced in its META-INF/MANIFEST.MF file). These jars can be found in JBOSS_HOME/client folder. But i would expect all this to be set by the Ant/Maven scripts in the tutorials. So did you change anything?

          • 2. Re: Class Cast Error
            Charlie Kelly Newbie

            Hi,

             

            This solved the problem (indirectly).

             

            I'm running a "client" in a JUnit test within Eclipse.

            The jbossall-client is only 2K (I suspect that this might be an error).

            I included all the jars in the JBoss client folder into the Eclipse classpath for the JUnit test.

            Then it completed correctly.

             

            Thank you for your help.

             

            Charlie

            • 3. Re: Class Cast Error
              jaikiran pai Master

              CharlieKelly wrote:

               


              The jbossall-client is only 2K (I suspect that this might be an error).


              The jbossall-client.jar is a MANIFEST only jar. What this means is, there are no classes within that jar but it has a META-INF/MANIFEST.MF which contains a Class-Path reference to point to all other required jars. The Class-Path entries are relative to the location of the jbossall-client.jar i.e. the jbossall-client.jar and all the referenced jars should be in the same folder. Usually, pointing to the jbossall-client.jar in the JBOSS_HOME/client is enough, but i don't know how IDEs handle the MANIFEST only jars.

              1 of 1 people found this helpful