0 Replies Latest reply on Feb 6, 2007 8:29 AM by pkraemer

    EJB 3 TrailBlazer Demo Class Cast

    pkraemer

      Well I know that there are several Threads about the ClassCast Problem, but nothing helped me realy - except looking that I did not have these errors.

      So, I use JBoss 4.04 and started with the TrailBlazer Demo about StatelessSessionBeans.

      I can start the JSP but I got a ClassCastException during it.

      I have deployed it to TrailBalzerApplication.ear which contains:

      TrailBlazerApplication.ear
       application.xml
       jboss-app.xml
       TrailBlazerEJB.jar
       TrailBlazerWeb.war
      


      The application.xml:
      <application xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
       <display-name>TrailBlazerApplication</display-name>
      
       <module id="myeclipse.1170763402122">
       <ejb>TrailBlazerEJB.jar</ejb>
       </module>
      
       <module id="myeclipse.1170763401891">
       <web>
       <web-uri>TrailBlazerWeb.war</web-uri>
       <context-root>TrailBlazerWeb</context-root>
       </web>
       </module>
      </application>
      


      The jboss-app.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <jboss-app>
       <loader-repository>
       trailblazerOne:app=ejb3
       </loader-repository>
      </jboss-app>
      



      The SessionBean
      package trail.slsb;
      
      import org.jboss.annotation.ejb.LocalBinding;
      
      import javax.ejb.*;
      
      @Stateless
      @LocalBinding (jndiBinding="EJB3TrailBlazer/slsb/Calculator")
      public class StatelessCalculator implements Calculator {
      
       public double calculate (int start, int end, double growthrate, double saving) {
       double tmp = Math.pow(1. + growthrate / 12., 12. * (end - start) + 1);
       return saving * 12. * (tmp - 1) / growthrate;
       }
      
      }
      


      Part of the jsp:
       <%@ page import="trail.slsb.*, javax.naming.*, java.text.*"%>
      
       <%!
       private Calculator cal = null;
       public void jspInit () {
       try {
       InitialContext ctx = new InitialContext();
       cal = (Calculator) ctx.lookup(
       "EJB3Trail/StatelessCalculator/local");
       } catch (Exception e) {
       e.printStackTrace ();
       }
       }
       %>
      


      There are no errors during deployment

      Can anybody please help me?

      Thanks