2 Replies Latest reply on Nov 22, 2007 8:44 AM by jaikiran pai

    Problem deploying Session Bean

    Breako Beats Newbie

      Hi,
      I have a very simpl ear, test.ear which packages up the following:

      test.ear
      -enterprise.jar
      ---- AddressDAI
      ---- AddressDAOImpl
      ---- // other java files
      -enterprise.war
      ---- // usual web stuff
      - meta - inf
      ---- application.xml


      My session bean interface is

      @Remote
      public interface AddressDAO {
       public void createAddress(Address address);
      }
      


      My Session bean implementation is:

      @Stateless
      @TransactionManagement(TransactionManagementType.BEAN)
      public class AddressDAOImplBMT implements AddressDAO{
       public void createAddress(Address address) {
       // java code
       }
      }
      


      I deploy my .ear. I check the JBoss JMX console to see if I can see my Session bean.

      I expect to see it under:

      java:comp namespace of the test.ear/test.war application
      


      But I don't.

      I see it under:
      Global JNDI Namespace
       +- test (class: org.jnp.interfaces.NamingContext)
       | +- AddressDAOImplBMT (class: org.jnp.interfaces.NamingContext)
      


      Consequently I have problems using the Session bean.

      If I try to do:

      Object ref = ctx.lookup("java:comp");
      ref = ctx.lookup("test/AddressDAOImplBMT");
      AddressDAO dao = (AddressDAO)PortableRemoteObject.narrow(ref, AddressDAOImplBMT.class);
      

      I get a class cast exception,
       java.lang.ClassCastException: Class AddressDAOImplBMT is not a valid remote interface
      


      any ideas would be greatly appreciated - thanks


        • 1. Re: Problem deploying Session Bean
          Breako Beats Newbie

          Hi,
          I fixed this problem by updated client code to:

           Object ref = ctx.lookup("ta3g/AddressDAOImplBMT/remote");
           System.out.println("ref is : " + ref);
           AddressDAO dao = (AddressDAO)PortableRemoteObject.narrow(ref, AddressDAO.class);
          


          Now I am getting:
          java.lang.ClassCastException: $Proxy74
           at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:212)
           at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
           at org.apache.jsp.TestSessionBeansWithJPA_jsp._jspService(TestSessionBeansWithJPA_jsp.java:86)
           at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
           at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
           at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
           at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:336)
          


          • 2. Re: Problem deploying Session Bean
            jaikiran pai Master

            Since you are using EJB3.0, you no longer need to "narrow" the returned object. The lookup will return you an proxy which implements AddressDAO interface. Change your code to


            AddressDAO dao = (AddressDAO) ctx.lookup("ta3g/AddressDAOImplBMT/remote");