3 Replies Latest reply on Apr 5, 2006 11:34 AM by Alex

    Can't invoke EJB3.0 throw servlet connector

    Alex Newbie

      I try invoke my EJB3 Statless Bean throw servlet connector.
      My configuration remote connector is:

      <mbean code="org.jboss.remoting.transport.Connector"
       xmbean-dd="org/jboss/remoting/transport/Connector.xml"
       name="jboss.remoting:type=Connector,name=DefaultEjb3Connector,handler=ejb3">
       <depends>jboss.aop:service=AspectDeployer</depends>
       <attribute name="InvokerLocator">servlet://localhost:8080/servlet-invoker/ServerInvokerServlet</attribute>
       <attribute name="Configuration">
       <config>
       <handlers>
       <handler subsystem="AOP">org.jboss.aspects.remoting.AOPRemotingInvocationHandler</handler>
       </handlers>
       </config>
       </attribute>
       </mbean>



      The statless bean is:

      public interface TypesRemote{
       public void hello();
      }




      @Stateless
      @Remote (TypesRemote.class)
      @RemoteBinding(clientBindUrl="http://localhost:8080/servlet-invoker/ServerInvokerServlet")
      public class TypesRemoteBean implements TypesRemote,Serializable {
      
       public void hello(){
       System.out.println("hello");
       }
      
      }



      Client cod is:

      public void hello(){
      try{
       Context ctx = getContext();
       TypesRemote remote = (TypesRemote)ctx.lookup (TypesRemote.class.getName());
       remote.hello();
       }
       catch(Exception e){
       e.printStackTrace();
       }
      }
      public InitialContext getContext()throws Exception{
       java.util.Properties env = new java.util.Properties();
       env.setProperty("java.naming.provider.url","http://localhost:8080/invoker/JNDIFactory");
       env.setProperty("java.naming.factory.initial","org.jboss.naming.HttpNamingContextFactory");
       return new InitialContext(env);
      }



      Then i try invoke hello method on the server i cath exception:

      java.lang.NullPointerException
      at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:76)
      at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:69)
      at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:566)
      at org.jboss.remoting.transport.servlet.ServletServerInvoker.processRequest(ServletServerInvoker.java:104)
      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:141)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
      at javax.management.MBeanServerInvocationHandler.invoke(MBeanServerInvocationHandler.java:201)
      at $Proxy75.processRequest(Unknown Source)
      at org.jboss.remoting.transport.servlet.web.ServerInvokerServlet.processRequest(ServerInvokerServlet.java:97)
      at org.jboss.remoting.transport.servlet.web.ServerInvokerServlet.doPost(ServerInvokerServlet.java:122)
      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 org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
      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.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
      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:856)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
      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)

      If use other connector such is socket or http it's work fine.
      What i do not right?

        • 1. Re: Can't invoke EJB3.0 throw servlet connector
          Ramil Israfilov Newbie

          in you connector config should not you replace

          <attribute name="InvokerLocator">servlet:

          by
          <attribute name="InvokerLocator">http:


          • 2. Re: Can't invoke EJB3.0 throw servlet connector
            Tom Elrod Master

            Just tried to reproduce using posted ejb3 app and config with JBossAS 4.0.4RC1 and worked fine (although used regular transport for jndi instead of http). Only thing extra step required (besides changing the ejb3.deployer/META-INF/jboss-service.xml config to match the one above) was to deploy the servlet-invoker.war, which is need if using the servlet transport (more info at http://labs.jboss.com/portal/jbossremoting/docs/guide/ch04.html#d0e858).

            Although this example app will work with:

            @RemoteBinding(clientBindUrl="http://localhost:8080/servlet-invoker/ServerInvokerServlet")
            


            would suggest using:

            @RemoteBinding(clientBindUrl="servlet://localhost:8080/servlet-invoker/ServerInvokerServlet")
            


            just so the remoting locator uri matches up with the once configured on the server. There was a bug that remoting client did not covert to 'http' url internally, so required the 'http' on the client, but has been fixed.

            If you decide to switch to use the pure http invoker (meaning server sides runs in its own embedded web container instead of as a servlet within JBoss's web container... Tomcat), can change the locator uri to be 'http' in both the Connector config and the RemoteBinding. However, due to bug (JBAS-2766), will need to manually copy following jars to server's lib directory (e.g. jboss/server/default/lib):

            tomcat-apr.jar
            tomcat-coyote.jar
            tomcat-http.jar
            tomcat-util.jar

            otherwise will see an error message like:

            java.lang.ClassNotFoundException: org.jboss.remoting.transport.coyote.CoyoteInvoker
            


            Have also tested this with 4.0.4CR1 and working fine.

            • 3. Re: Can't invoke EJB3.0 throw servlet connector
              Alex Newbie

              Thank you Tom.