1 Reply Latest reply on Jun 1, 2007 3:14 AM by morisona

    ClassCastException on JNDI lookup

    morisona

      There is reason to beieve that this problem is easy (http://jira.jboss.com/jira/browse/EJBTHREE-456), but I have searched the forum and can not find exactly the same situation.
      The easiest way to reproduce it is to take the calcualtor.jsp from the EJB3Trail, and put it in a seperate war along with trail.slsb.Calculator.class. I then get

      20:12:40,859 ERROR [STDERR] java.lang.ClassCastException: $Proxy136
      20:12:48,437 ERROR [STDERR] at org.apache.jsp.calculator_jsp.jspInit(calculator_jsp.java:19)
      20:12:48,437 ERROR [STDERR] at org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:78)
      20:12:48,437 ERROR [STDERR] at org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:155)
      

      The relevent bit of code in the jsp is:

       InitialContext ctx = new InitialContext();
       cal = (Calculator) ctx.lookup(
       "EJB3Trail/StatelessCalculator/local");
      

      On the JMX JNDI screen I have:
       +- EJB3Trail (class: org.jnp.interfaces.NamingContext)
       ........
       | +- StatelessCalculator (class: org.jnp.interfaces.NamingContext)
       | | +- local (proxy: $Proxy136 implements interface trail.slsb.Calculator,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBLocalObject)
      

      Any help and I would be infinitely greatful.

        • 1. Re: ClassCastException on JNDI lookup
          morisona

          Well, I got there in the end. For the benefit of anyone else who has this problem:
          The reason is that the classloader for the ejb interface was not the same as that of the ejb class. So:
          remove the interface file from the war.
          if, in the ear jboss-app.xml you have:
          <loader-repository>
          onebox:app=backend
          </loader-repository>
          or something similar, remove it.
          And you should be OK.