1 Reply Latest reply on Nov 3, 2002 3:33 PM by stephen smithstone

    FileNotFoundException Accessing Session bean from Servlet

    John Snyder Newbie

      Hello all,

      Using jboss-3.0.0_tomcat-4.0.3, I am trying to access a Session bean called Registration from within a servlet, both of which are part of an application called pc, deployed as pc.ear. I can access the bean with no problem from a stand-alone client, with the following code:

      Context jndiContext = getInitialContext();
      Object ref = jndiContext.lookup("RegistrationHomeRemote");
      RegistrationHomeRemote registrationHome = (RegistrationHomeRemote)
      PortableRemoteObject.narrow(ref,RegistrationHomeRemote.class);
      RegistrationRemote registration = registrationHome.create();
      registration.remove();

      When I placed this code in a TestServlet, however, I initially got a ClassCastException at the third line. Some research in the forums and the manual suggested to me that I did not have everything specified correctly in my deployment descriptors. After some tinkering, I no longer get a ClassCastException. However, I do get the following Exception:

      javax.servlet.ServletException: Could not activate; nested exception is:
      java.io.FileNotFoundException: C:\Java\jboss\jboss-3.0.0_tomcat-4.0.3\server\default\db\sessions\Registration\1036311619820.ser (The system cannot find the file specified)
      at com.pc.servlets.TestServlet.doRequest(TestServlet.java:44)
      at com.pc.servlets.BaseServlet.doPost(BaseServlet.java:33)
      at com.pc.servlets.BaseServlet.doGet(BaseServlet.java:28)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:446)
      at org.apache.catalina.servlets.InvokerServlet.doGet(InvokerServlet.java:180)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
      at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
      at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:475)
      at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
      at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
      at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
      at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2343)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
      at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
      at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
      at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
      at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
      at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
      at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
      at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1012)
      at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1107)
      at java.lang.Thread.run(Thread.java:536)

      Could anyone shed any light on what's happening here? My deployment descriptors (in relevant part) are as follows:
      ejb.jar:

      <display-name>Registration</display-name>
      <ejb-name>Registration</ejb-name>
      com.pc.ejb.session.interfaces.RegistrationHomeRemote
      com.pc.ejb.session.interfaces.RegistrationRemote
      <ejb-class>com.pc.ejb.session.beans.RegistrationBean</ejb-class>
      <session-type>Stateful</session-type>
      <transaction-type>Container</transaction-type>


      jboss.xml:

      <ejb-name>Registration</ejb-name>
      <jndi-name>RegistrationHomeRemote</jndi-name>


      web.xml:

      <servlet-name>RegistrationServlet</servlet-name>
      <servlet-class>com.pc.servlets.RegistrationServlet</servlet-class>

      <ejb-ref>
      <ejb-ref-name>Registration</ejb-ref-name>
      <ejb-ref-type>Session</ejb-ref-type>
      RegistrationHomeRemote
      RegistrationRemote
      <ejb-link>Registration</ejb-link>
      </ejb-ref>

      jboss-web.xml:
      <ejb-ref>
      <ejb-ref-name>Registration</ejb-ref-name>
      <jndi-name>pc/RegistrationHomeRemote</jndi-name>
      </ejb-ref>