0 Replies Latest reply on Jun 7, 2006 2:57 AM by Rohitha Dayan Gunawardhana

    JNDI naming problem with JBoss

    Rohitha Dayan Gunawardhana Newbie

      Hi all,

      I'm trying to deploy a Session bean on JBoss.

      My java classes as follows:
      pkg1.MyBean //Bean
      pkg1.My //Remote Interface
      pkg1.MyHome //Home Interface
      pkg1.MyLocalHome //Local Home Interface
      pkg1.MyLocal //Local Interface


      ejb-jar.xml related codes:

      <!-- Session Beans -->

      <![CDATA[A session bean named My]]>
      <display-name>My</display-name>

      <ejb-name>My</ejb-name>

      pkg1.MyHome
      pkg1.My
      <local-home>pkg1.MyLocalHome</local-home>
      pkg1.MyLocal
      <ejb-class>pkg1.MySession</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>






      jboss.xml related codes:

      <enterprise-beans>

      <ejb-name>My</ejb-name>
      <jndi-name>My</jndi-name>
      <local-jndi-name>MyLocal</local-jndi-name>

      <method-attributes>
      </method-attributes>

      </enterprise-beans>




      then I'm trying to call the Bean using JSP page
      JSP page code:

      <%!
      private My my = null;

      public void jspInit() {
      try {
      InitialContext ic = new InitialContext();
      Object objRef = ic.lookup("My");
      MyHome home = (MyHome)PortableRemoteObject.narrow(objRef, MyHome.class);
      my = home.create();
      } catch (RemoteException ex) {
      System.out.println("Couldn't create My bean."+ ex.getMessage());
      } catch (CreateException ex) {
      System.out.println("Couldn't create My bean."+ ex.getMessage());
      } catch (NamingException ex) {
      System.out.println("Unable to lookup home: "+ "My "+ ex.getMessage());
      }
      }

      public void jspDestroy() {
      my = null;
      }
      %>




      when I'm try to execute jsp page.
      I got following Exception:

      java.lang.ClassCastException
      at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(Unknown Source)
      at javax.rmi.PortableRemoteObject.narrow(Unknown Source)
      at org.apache.jsp.index_jsp.jspInit(index_jsp.java:22)
      at org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:78)
      at org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:155)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:315)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
      at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
      at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      at java.lang.Thread.run(Unknown Source)
      Caused by: java.lang.ClassCastException: $Proxy73
      ... 27 more



      Pls help me.

      Rohitha