Calling EJB from servlet.

Discussions

EJB design: Calling EJB from servlet.

  1. Calling EJB from servlet. (1 messages)

    Hello I am using following code for accessing EJB on a remote machine. com.nepasoft.npg.ejb.NpgTxn npgTxn = null; 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(); if(npgTxn.validateUser(customerId, txnPassword)){ request.setAttribute("MESSAGE", "The user is authenticated"); } The Same code works in jsp page but throws Exception while used in a servlet. 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 $Proxy63.create(Unknown Source) at com.nepasoft.npg.controller.PostPayBillsFormEventHandler.process(PostPayBillsFormEventHandler.java:73) 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) 12:35:25,125 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 12:35:25,125 ERROR [STDERR] at org.jboss.ejb.plugins.LogInterceptor.handleException(LogInterceptor.java:365) 12:35:25,125 ERROR [STDERR] at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:136) 12:35:25,125 ERROR [STDERR] at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderInterceptor.java:107) 12:35:25,125 ERROR [STDERR] at org.jboss.ejb.SessionContainer.internalInvokeHome(SessionContainer.java:637) 12:35:25,125 ERROR [STDERR] at org.jboss.ejb.Container.invoke(Container.java:975) 12:35:25,125 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 12:35:25,125 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 12:35:25,125 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 12:35:25,125 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585) 12:35:25,125 ERROR [STDERR] at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155) 12:35:25,125 ERROR [STDERR] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94) 12:35:25,125 ERROR [STDERR] at org.jboss.mx.server.Invocation.invoke(Invocation.java:86) 12:35:25,125 ERROR [STDERR] at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264) 12:35:25,125 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659) 12:35:25,125 ERROR [STDERR] at org.jboss.invocation.local.LocalInvoker$MBeanServerAction.invoke(LocalInvoker.java:169) 12:35:25,125 ERROR [STDERR] at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:118) 12:35:25,125 ERROR [STDERR] at org.jboss.invocation.InvokerInterceptor.invokeLocal(InvokerInterceptor.java:206) 12:35:25,125 ERROR [STDERR] at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:192) 12:35:25,125 ERROR [STDERR] at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:61) 12:35:25,125 ERROR [STDERR] at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:70) 12:35:25,125 ERROR [STDERR] at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.java:184) 12:35:25,125 ERROR [STDERR] at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:100) 12:35:25,125 ERROR [STDERR] at $Proxy63.create(Unknown Source) 12:35:25,125 ERROR [STDERR] at com.nepasoft.npg.controller.PostPayBillsFormEventHandler.process(PostPayBillsFormEventHandler.java:73) 12:35:25,125 ERROR [STDERR] at com.nepasoft.npg.controller.PostAllFormsEventHandler.process(PostAllFormsEventHandler.java:31) 12:35:25,125 ERROR [STDERR] at com.nepasoft.npg.controller.MainController.processRequest(MainController.java:93) 12:35:25,125 ERROR [STDERR] at com.nepasoft.npg.controller.MainController.doPost(MainController.java:133) 12:35:25,125 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) 12:35:25,125 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:810) 12:35:25,125 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) 12:35:25,125 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) 12:35:25,125 ERROR [STDERR] at com.nepasoft.npg.filters.AuthenticationFilter.doFilter(AuthenticationFilter.java:46) 12:35:25,125 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202) 12:35:25,125 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) 12:35:25,125 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) 12:35:25,125 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202) 12:35:25,125 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) 12:35:25,125 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) 12:35:25,125 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) 12:35:25,125 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175) 12:35:25,125 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74) 12:35:25,125 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) 12:35:25,125 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) 12:35:25,125 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) 12:35:25,125 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) 12:35:25,125 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869) 12:35:25,125 ERROR [STDERR] at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664) 12:35:25,125 ERROR [STDERR] at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) 12:35:25,125 ERROR [STDERR] at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112) 12:35:25,125 ERROR [STDERR] at java.lang.Thread.run(Thread.java:595) 12:35:25,125 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 12:35:25,125 ERROR [STDERR] at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invokeHome(StatelessSessionContainer.java:175) 12:35:25,125 ERROR [STDERR] at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome(CachedConnectionInterceptor.java:189) 12:35:25,125 ERROR [STDERR] at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invokeHome(StatelessSessionInstanceInterceptor.java:98) 12:35:25,125 ERROR [STDERR] at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:105) 12:35:25,125 ERROR [STDERR] at org.jboss.ejb.plugins.CallValidationInterceptor.invokeHome(CallValidationInterceptor.java:56) 12:35:25,125 ERROR [STDERR] at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:125) 12:35:25,125 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:350) 12:35:25,125 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:161) 12:35:25,125 ERROR [STDERR] at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:145) 12:35:25,125 ERROR [STDERR] at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:132) 12:35:25,125 ERROR [STDERR] ... 48 more 12:35:25,125 INFO [[/NPG]] 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 12:35:25,125 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)
  2. Possible omission of semicolon[ Go to top ]

    if(npgTxn.validateUser(customerId, txnPassword)) [shouldn't this have a semicolon here to separate the arguments?] (Still learning Java, so this is a WAG.) Regards, Alan