3 Replies Latest reply on Dec 16, 2006 3:11 AM by Santosh Kottamasu

    Class.cast.Exception when Accessing a Session bean on 4.0.5

    Nigel Cheetham Newbie

      Can anyone help me - I'm at a loss. I'm also embarrassed because I think this should be easy. I've deployed my application in an EAR, it contains a JSF web app, and some EJB's.

      Here's the code I use to call the bean.

       InitialContext context = new InitialContext();
      
       Object objref = context.lookup("ReservationManager");
      
       ReservationManagerHome reservationManagerHome =
       (ReservationManagerHome)PortableRemoteObject.narrow(objref, ReservationManagerHome.class);
      
       _reservationManager =
       (ReservationManager)reservationManagerHome.create();
      


      The context.lookup successfully returns a proxy, but the narrow function throws a Class Cast Error shown below:

      2006-12-07 14:56:13,610 ERROR [businesstier.base.ReservationsClassFactory] java.lang.ClassCastException
      


      The deployment reports no errors -> here's the log:

      DEBUG [org.jboss.ejb.EJBDeployer.verifier] Bean checked: ReservationManager: Verified.
      ...
      INFO [org.jboss.ejb.EjbModule] Deploying ReservationManager
      ...
      DEBUG [org.jboss.ejb.EjbModule] creating binding for ReservationManager:stateless-rmi-invoker
      ...
      DEBUG [org.jboss.system.ServiceController] Creating service jboss.j2ee:jndiName=ReservationManager,service=EJB
      ...
      DEBUG [org.jboss.ejb.StatelessSessionContainer] Creating jboss.j2ee:jndiName=ReservationManager,service=EJB
      ...
      DEBUG [org.jboss.system.ServiceController] Creating service jboss.j2ee:service=EJB,plugin=pool,jndiName=ReservationManager
      DEBUG [org.jboss.ejb.plugins.StatelessSessionInstancePool] Creating jboss.j2ee:service=EJB,plugin=pool,jndiName=ReservationManager
      ...
      DEBUG [org.jboss.ejb.plugins.StatelessSessionInstancePool] Created jboss.j2ee:service=EJB,plugin=pool,jndiName=ReservationManager
      ...
      jboss.j2ee:jndiName=ReservationManager,service=EJB state: Created
      ...
      INFO [org.jboss.ejb.plugins.local.BaseLocalProxyFactory] Bound EJB LocalHome 'ReservationManager' to jndi 'local/ReservationManager@15468898'
      


      I can see it as a service in the JMX-Console

      The Web.XML looks like this:
       <ejb-ref>
       <ejb-ref-name>ejb/ReservationManager</ejb-ref-name>
       <ejb-ref-type>Session</ejb-ref-type>
       <home>businesstier.impl.ReservationManagerHome</home>
       <remote>businesstier.impl.ReservationManager</remote>
       <ejb-link>ReservationManager</ejb-link>
       </ejb-ref>
      


      The ejb-jar.xml looks like this:

       <session>
       <description>Session Bean ( Stateless )</description>
       <display-name>ReservationManager</display-name>
       <ejb-name>ReservationManager</ejb-name>
       <home>businesstier.impl.ReservationManagerHome</home>
       <remote>businesstier.impl.ReservationManager</remote>
       <local-home>businesstier.impl.ReservationManagerLocalHome</local-home>
       <local>businesstier.impl.ReservationManagerLocal</local>
       <ejb-class>businesstier.impl.ReservationManagerBean</ejb-class>
       <session-type>Stateless</session-type>
       <transaction-type>Container</transaction-type>
      ...
      


      The deployment works like a charm on Oracle Application Server 10g.

      I'm completely stumped. What am I missing.

      Thanks,

      Nigel