Problem calling EJB3 method via HTTP only
formica May 25, 2007 10:39 AMI have a problem in testing remote method calls via http using JBOSS 4.2.0.GA application server.
I want to call EJB3 methods via HTTP ONLY (I have a firewall problem, as usual ;-) )
(REMARK: using simple RMI and adequate JNDI parameter the client
code is working correctly...)
Following many forums/doc/wiki pages I have ended up with a configuration of the following type:
SERVER SIDE:
1) I have modified ejb3.deployer/META-INF/jboss-service.xml in the following way:
<mbean code="org.jboss.remoting.transport.Connector" name="jboss.remoting:type=Connector,name=DefaultEjb3Connector,handler=ejb3"> <depends>jboss.aop:service=AspectDeployer</depends> <attribute name="InvokerLocator">servlet://${jboss.bind.address}:8080/invoker/EJBInvokerServlet</attribute> <attribute name="Configuration"> <handlers> <handler subsystem="AOP">org.jboss.aspects.remoting.AOPRemotingInvocationHandler</handler> </handlers> </attribute> </mbean>
2) I have slightly modified the http-invoker.sar/META-INF/jboss-service.xml adding the the following lines to the 3 relative MBEAN definitions:
<attribute name="InvokerURL">http://${jboss.bind.address}:8080/invoker/EJBInvokerServlet</attribute> ..... <attribute name="InvokerURL">http://${jboss.bind.address}:8080/invoker/JMXInvokerServlet</attribute> ..... <attribute name="InvokerURL">http://${jboss.bind.address}:8080/invoker/readonly/JMXInvokerServlet</attribute>
3) I have modified the conf/standardjboss.xml config file like :
<invoker-proxy-binding> <name>stateless-http-invoker</name> <invoker-mbean>jboss:service=invoker,type=http</invoker-mbean> <proxy-factory>org.jboss.proxy.ejb.ProxyFactory</proxy-factory> <proxy-factory-config> <client-interceptors> <home> <interceptor>org.jboss.proxy.ejb.HomeInterceptor</interceptor> <interceptor>org.jboss.proxy.SecurityInterceptor</interceptor> <interceptor>org.jboss.proxy.TransactionInterceptor</interceptor> <interceptor call-by-value="false">org.jboss.invocation.InvokerInterceptor</interceptor> <interceptor call-by-value="true">org.jboss.invocation.MarshallingInvokerInterceptor</interceptor> </home> <bean> <interceptor>org.jboss.proxy.ejb.StatelessSessionInterceptor</interceptor> <interceptor>org.jboss.proxy.SecurityInterceptor</interceptor> <interceptor>org.jboss.proxy.TransactionInterceptor</interceptor> <interceptor call-by-value="false">org.jboss.invocation.InvokerInterceptor</interceptor> <interceptor call-by-value="true">org.jboss.invocation.MarshallingInvokerInterceptor</interceptor> </bean> </client-interceptors> </proxy-factory-config> </invoker-proxy-binding>
and the container part accordingly
<container-name>Standard Stateless SessionBean</container-name> <call-logging>false</call-logging> <invoker-proxy-binding-name>stateless-http-invoker</invoker-proxy-binding-name> .....
4) I have added the following annotation to my stateless session
//@RemoteBinding(jndiBinding="AsapServer/OltestlinesDAOBean/remote") @RemoteBindings({ @RemoteBinding(jndiBinding="AsapServer/OltestlinesDAOBean/remote"), @RemoteBinding(clientBindUrl="servlet://localhost:8080/invoker/EJBInvokerServlet", jndiBinding="AsapServer/OltestlinesDAOBean/http") })
and finally...
CLIENTSIDE
5) I have defined the following JNDI properties for the connection :
java.naming.factory.initial=org.jboss.naming.HttpNamingContextFactory java.naming.provider.url=http://$host:$port/invoker/JNDIFactory java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces where host/port are : localhost/8080 or 127.0.0.1/8080
Now, I get correctly the stub to the session bean in my client, and I
managed to execute the method, but the method execution itself fails
with the following exception from the server:
2007-05-25 16:20:50,986 DEBUG [org.jboss.invocation.http.servlet.InvokerServlet] Invoke threw exception java.lang.ClassCastException: org.jboss.remoting.InvocationRequest at org.jboss.invocation.http.servlet.InvokerServlet.processRequest(InvokerServlet.java:137) at org.jboss.invocation.http.servlet.InvokerServlet.doPost(InvokerServlet.java:224) at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433) at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Thread.java:613)
while the client sees the following :
getting stub for beanName OltestlinesDAO obj looked up in OltestlinesDAO/http java.lang.ClassCastException: java.lang.String at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:62) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:53) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:72) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:103) at $Proxy2.findOlsLike(Unknown Source) at asap.client.delegate.OpticallineDBJboss.listOpticallines(OpticallineDBJboss.java:82) at asap.client.delegate.OpticallineDBJboss.main(OpticallineDBJboss.java:202) at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:74) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:53) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:72) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:103) at $Proxy2.findOlsLike(Unknown Source) at asap.client.delegate.OpticallineDBJboss.listOpticallines(OpticallineDBJboss.java:82) at asap.client.delegate.OpticallineDBJboss.main(OpticallineDBJboss.java:202) Exception in thread "main" java.lang.NullPointerException at asap.client.delegate.OpticallineDBJboss.main(OpticallineDBJboss.java:203)
Could you please explain me what is going on ? I'll try to post the message also in Remoting forum...
Andrea