1 Reply Latest reply on Jun 25, 2007 11:48 AM by jaikiran pai

    Invoking EJB from a servlet

    Milan Shrestha Newbie

      I am trying to access ejb form a servlet but I am getting following exception.
      i would be thankful if anybody could tell me how can I fix the problem.

      I am using following code :

      Properties props = new Properties();
      props.put("java.naming.factory.initial",
      "org.jnp.interfaces.NamingContextFactory");
      props.put("java.naming.factory.url.pkgs",
      "org.jboss.naming:org.jnp.interfaces");
      props.put("java.naming.provider.url",
      "100.100.100.12:1099");
      InitialContext ic = new InitialContext(props);
      Object objRef = ic.lookup("npg/NpgTxn");
      System.out.println("ObjRef="+objRef);
      NpgTxnHome home = (NpgTxnHome)PortableRemoteObject.narrow(objRef,NpgTxnHome.class);
      npgTxn = home.create();

      And getting following Exception

      ERROR [LogInterceptor] EJBException in method: public abstract com.nepasoft.npg.ejb.NpgTxn com.nepasoft.npg.ejb.NpgTxnHome.create() throws javax.ejb.CreateException,java.rmi.RemoteException:
      javax.ejb.EJBException: Invalid invocation, check your deployment packaging, method=public abstract com.nepasoft.npg.ejb.NpgTxn com.nepasoft.npg.ejb.NpgTxnHome.create() throws javax.ejb.CreateException,java.rmi.RemoteException
      at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invokeHome(StatelessSessionContainer.java:175)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome(CachedConnectionInterceptor.java:189)
      at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invokeHome(StatelessSessionInstanceInterceptor.java:98)
      at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:105)
      at org.jboss.ejb.plugins.CallValidationInterceptor.invokeHome(CallValidationInterceptor.java:56)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:125)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:350)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:161)
      at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:145)
      at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:132)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderInterceptor.java:107)
      at org.jboss.ejb.SessionContainer.internalInvokeHome(SessionContainer.java:637)
      at org.jboss.ejb.Container.invoke(Container.java:975)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
      at org.jboss.invocation.local.LocalInvoker$MBeanServerAction.invoke(LocalInvoker.java:169)
      at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:118)
      at org.jboss.invocation.InvokerInterceptor.invokeLocal(InvokerInterceptor.java:206)
      at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:192)
      at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:61)
      at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:70)
      at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.java:184)
      at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:100)
      at $Proxy66.create(Unknown Source)
      at com.nepasoft.npg.controller.PostPayBillsFormEventHandler.init(PostPayBillsFormEventHandler.java:35)
      at com.nepasoft.npg.controller.PostPayBillsFormEventHandler.process(PostPayBillsFormEventHandler.java:45)
      at com.nepasoft.npg.controller.PostAllFormsEventHandler.process(PostAllFormsEventHandler.java:31)
      at com.nepasoft.npg.controller.MainController.processRequest(MainController.java:93)
      at com.nepasoft.npg.controller.MainController.doPost(MainController.java:133)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      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 com.nepasoft.npg.filters.AuthenticationFilter.doFilter(AuthenticationFilter.java:46)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      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(Thread.java:595)
      17:26:46,609 ERROR [STDERR] java.rmi.ServerException: EJBException:; nested exception is:
      javax.ejb.EJBException: Invalid invocation, check your deployment packaging, method=public abstract com.nepasoft.npg.ejb.NpgTxn com.nepasoft.npg.ejb.NpgTxnHome.create() throws javax.ejb.CreateException,java.rmi.RemoteException
      17:26:46,609 ERROR [STDERR] at org.jboss.ejb.plugins.LogInterceptor.handleException(LogInterceptor.java:365)
      17:26:46,609 ERROR [STDERR] at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:136)
      17:26:46,609 ERROR [STDERR] at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderInterceptor.java:107)
      17:26:46,609 ERROR [STDERR] at org.jboss.ejb.SessionContainer.internalInvokeHome(SessionContainer.java:637)
      17:26:46,609 ERROR [STDERR] at org.jboss.ejb.Container.invoke(Container.java:975)
      17:26:46,609 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      17:26:46,609 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      17:26:46,609 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      17:26:46,609 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
      17:26:46,609 ERROR [STDERR] at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
      17:26:46,609 ERROR [STDERR] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
      17:26:46,609 ERROR [STDERR] at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
      17:26:46,609 ERROR [STDERR] at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
      17:26:46,609 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
      17:26:46,609 ERROR [STDERR] at org.jboss.invocation.local.LocalInvoker$MBeanServerAction.invoke(LocalInvoker.java:169)
      17:26:46,609 ERROR [STDERR] at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:118)
      17:26:46,609 ERROR [STDERR] at org.jboss.invocation.InvokerInterceptor.invokeLocal(InvokerInterceptor.java:206)
      17:26:46,609 ERROR [STDERR] at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:192)
      17:26:46,609 ERROR [STDERR] at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:61)
      17:26:46,609 ERROR [STDERR] at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:70)
      17:26:46,609 ERROR [STDERR] at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.java:184)
      17:26:46,609 ERROR [STDERR] at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:100)
      17:26:46,609 ERROR [STDERR] at $Proxy66.create(Unknown Source)
      17:26:46,609 ERROR [STDERR] at com.nepasoft.npg.controller.PostPayBillsFormEventHandler.init(PostPayBillsFormEventHandler.java:35)
      17:26:46,609 ERROR [STDERR] at com.nepasoft.npg.controller.PostPayBillsFormEventHandler.process(PostPayBillsFormEventHandler.java:45)
      17:26:46,609 ERROR [STDERR] at com.nepasoft.npg.controller.PostAllFormsEventHandler.process(PostAllFormsEventHandler.java:31)
      17:26:46,609 ERROR [STDERR] at com.nepasoft.npg.controller.MainController.processRequest(MainController.java:93)
      17:26:46,609 ERROR [STDERR] at com.nepasoft.npg.controller.MainController.doPost(MainController.java:133)
      17:26:46,609 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      17:26:46,625 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      17:26:46,625 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      17:26:46,625 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      17:26:46,625 ERROR [STDERR] at com.nepasoft.npg.filters.AuthenticationFilter.doFilter(AuthenticationFilter.java:46)
      17:26:46,625 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      17:26:46,625 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      17:26:46,625 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      17:26:46,625 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      17:26:46,625 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      17:26:46,625 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      17:26:46,625 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      17:26:46,625 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
      17:26:46,625 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
      17:26:46,625 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      17:26:46,625 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      17:26:46,625 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      17:26:46,625 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      17:26:46,625 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
      17:26:46,625 ERROR [STDERR] at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
      17:26:46,625 ERROR [STDERR] at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      17:26:46,625 ERROR [STDERR] at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      17:26:46,625 ERROR [STDERR] at java.lang.Thread.run(Thread.java:595)
      17:26:46,625 ERROR [STDERR] Caused by: javax.ejb.EJBException: Invalid invocation, check your deployment packaging, method=public abstract com.nepasoft.npg.ejb.NpgTxn com.nepasoft.npg.ejb.NpgTxnHome.create() throws javax.ejb.CreateException,java.rmi.RemoteException
      17:26:46,625 ERROR [STDERR] at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invokeHome(StatelessSessionContainer.java:175)
      17:26:46,625 ERROR [STDERR] at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome(CachedConnectionInterceptor.java:189)
      17:26:46,625 ERROR [STDERR] at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invokeHome(StatelessSessionInstanceInterceptor.java:98)
      17:26:46,625 ERROR [STDERR] at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:105)
      17:26:46,625 ERROR [STDERR] at org.jboss.ejb.plugins.CallValidationInterceptor.invokeHome(CallValidationInterceptor.java:56)
      17:26:46,625 ERROR [STDERR] at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:125)
      17:26:46,625 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:350)
      17:26:46,625 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:161)
      17:26:46,625 ERROR [STDERR] at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:145)
      17:26:46,625 ERROR [STDERR] at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:132)
      17:26:46,625 ERROR [STDERR] ... 49 more
      17:26:46,625 ERROR [STDERR] java.lang.NullPointerException
      17:26:46,625 ERROR [STDERR] at com.nepasoft.npg.controller.PostPayBillsFormEventHandler.process(PostPayBillsFormEventHandler.java:101)
      17:26:46,625 ERROR [STDERR] at com.nepasoft.npg.controller.PostAllFormsEventHandler.process(PostAllFormsEventHandler.java:31)
      17:26:46,625 ERROR [STDERR] at com.nepasoft.npg.controller.MainController.processRequest(MainController.java:93)
      17:26:46,625 ERROR [STDERR] at com.nepasoft.npg.controller.MainController.doPost(MainController.java:133)
      17:26:46,625 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      17:26:46,625 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      17:26:46,625 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      17:26:46,625 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      17:26:46,625 ERROR [STDERR] at com.nepasoft.npg.filters.AuthenticationFilter.doFilter(AuthenticationFilter.java:46)
      17:26:46,734 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      17:26:46,734 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      17:26:46,734 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      17:26:46,734 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      17:26:46,734 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      17:26:46,734 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      17:26:46,734 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      17:26:46,734 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
      17:26:46,734 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
      17:26:46,734 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      17:26:46,734 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      17:26:46,734 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      17:26:46,734 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      17:26:46,734 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
      17:26:46,734 ERROR [STDERR] at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
      17:26:46,734 ERROR [STDERR] at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      17:26:46,734 ERROR [STDERR] at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      17:26:46,734 ERROR [STDERR] at java.lang.Thread.run(Thread.java:595)
      17:26:46,734 INFO [[/NPG]]
      17:26:46,953 ERROR [[controller]] Servlet.service() for servlet controller threw exception
      java.lang.NullPointerException
      at com.nepasoft.npg.controller.MainController.processRequest(MainController.java:114)
      at com.nepasoft.npg.controller.MainController.doPost(MainController.java:133)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      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 com.nepasoft.npg.filters.AuthenticationFilter.doFilter(AuthenticationFilter.java:46)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      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(Thread.java:595)



      But the code works when I use the same code in a jsp page in jspInit() function. But doesnot work outside the function.

      Regards
      Milan