0 Replies Latest reply on Feb 15, 2002 5:09 PM by watermelonjam

    ClassCastException JBoss 3.0alpha Jan15snapshot

    watermelonjam

      I've been trying to get the simplest of web applications deployed on JBoss 3. There's a 2.0 CMP Entity EJB called "Switch" with a boolean field. There's a Session EJB called SwitchController, with some "switchy" business methods. The beans deploy fine as a JAR, or in an EAR. There are three JSP pages in my WAR - switchco.jsp, which calls on switchstate.jsp and flipswitch.jsp to do stuff. The last two, in turn, refer to a JavaBean front component packaged with them called SwitchBean. This is where the trouble starts. Everything deploys nicely, but when the JSP pages call SwitchBean methods (any), I get a ClassCastException.

      public class SwitchBean {
      private SwitchController c;

      public SwitchBean() {
      try {
      InitialContext i = new InitialContext();
      Object o = i.lookup("SwitchController");
      SwitchControllerHome ch = (SwitchControllerHome) o;
      c = ch.create();
      } catch (NamingException ne) {
      ne.printStackTrace();
      } catch (CreateException ce) {
      ce.printStackTrace();
      } catch (RemoteException re) {
      re.printStackTrace();
      }
      }

      public void toggle() {
      if (c != null) {
      try {
      c.toggle();
      } catch (RemoteException re) {
      re.printStackTrace();
      } catch (InvalidSwitchStateException re) {
      re.printStackTrace();
      }
      }
      }
      }

      I've played with commenting out some of this class, and determined that:

      1. The constructor seems good. c gets set to something without any exceptions.

      2. When I access c using anything (i.e. c.getClass().getName()), the result is:
      16:52:31,630 WARN [Jetty] WARNING: Servlet Exception for /switchco/switchco.jspjava.lang.InstantiationException: class org.clix.web.SwitchBean : java.lang.ClassCastException
      at org.apache.jsp.switchstate$jsp._jspService(switchstate$jsp.java:70)
      at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:202)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:327)
      at org.mortbay.jetty.servlet.Dispatcher.dispatch(Dispatcher.java:261)
      at org.mortbay.jetty.servlet.Dispatcher.include(Dispatcher.java:168)
      at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:820)
      at org.apache.jsp.switchco$jsp._jspService(switchco$jsp.java:60)
      at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:202)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:327)
      at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:546)
      at org.mortbay.http.HttpContext.handle(HttpContext.java:1269)
      at org.mortbay.http.HttpContext.handle(HttpContext.java:1223)
      at org.mortbay.http.HttpServer.service(HttpServer.java:725)
      at org.mortbay.http.HttpConnection.service(HttpConnection.java:748)
      at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:921)
      at org.mortbay.http.HttpConnection.handle(HttpConnection.java:763)
      at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:138)
      at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:287)
      at org.mortbay.util.ThreadPool$JobRunner.run(ThreadPool.java:715)
      at java.lang.Thread.run(Thread.java:484)

      Any ideas?