Problems with servlet transport
trevorh Feb 27, 2006 10:25 AMI am using Jboss 4.0.4RC1 and have created a simple stateless session bean using ejb3. Remote access using the default socket transport works fine but I cannot get servlet trandport working.
I have added this to ejb3.deployer/META-INF/jboss-service.xml
<mbean code="org.jboss.remoting.transport.Connector" xmbean-dd="org/jboss/remoting/transport/Connector.xml" name="jboss.remoting:type=Connector,transport=servlet,name=Servlet,handler=ejb3"> <depends>jboss.aop:service=AspectDeployer</depends> <attribute name="InvokerLocator">servlet://${jboss.bind.address}:8080/servlet-invoker/ServerInvokerServlet</attribute> <attribute name="Configuration"> <handlers> <handler subsystem="AOP">org.jboss.aspects.remoting.AOPRemotingInvocationHandler</handler> </handlers> </attribute> </mbean>
I have added servlet-invoker.war to the deploy directory. This contains the following META_INF/web.xml file
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <!-- The the JBossRemoting server invoker servlet web.xml descriptor $Id: web.xml,v 1.1 2005/06/16 21:12:48 telrod Exp $ --> <web-app> <servlet> <servlet-name>ServerInvokerServlet</servlet-name> <description>The ServerInvokerServlet receives requests via HTTP protocol from within a web container and passes it onto the ServletServerInvoker for processing. </description> <servlet-class>org.jboss.remoting.transport.servlet.web.ServerInvokerServlet</servlet-class> <init-param> <param-name>invokerName</param-name> <param-value>jboss.remoting:service=invoker,transport=servlet</param-value> <description>The servlet server invoker</description> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>ServerInvokerServlet</servlet-name> <url-pattern>/ServerInvokerServlet/*</url-pattern> </servlet-mapping> </web-app>
My session bean is declared as:
@RemoteBinding(clientBindUrl="http://localhost:8080/servlet-invoker/ServerInvokerServlet", jndiBinding="mailserver.TestStatelessEJB.servlet")
The client program is:
Properties p = new Properties(); p.put( Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory"); p.put( Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces" ); p.put("java.naming.provider.url", "localhost"); ctx = new InitialContext(p); TestStatelessRemote r = (TestStatelessRemote) ctx.lookup("mailserver.TestStatelessEJB.servlet"); r.remove(10); r.create(10,"hello from testEJB"); System.out.println(r.getText(10)); .....
JNDI lookup works ok but when r.remove is executed the following exception is thrown:
org.jboss.remoting.CannotConnectException: Can not connect http client invoker. at org.jboss.remoting.transport.http.HTTPClientInvoker.useHttpURLConnection(HTTPClientInvoker.java:192) at org.jboss.remoting.transport.http.HTTPClientInvoker.transport(HTTPClientInvoker.java:74) at org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInvoker.java:136) at org.jboss.remoting.Client.invoke(Client.java:444) at org.jboss.remoting.Client.invoke(Client.java:407) at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:55) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:55) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:65) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:102) at $Proxy0.remove(Unknown Source) at trevan.mailserver.client.TestClient.main(TestClient.java:55) Caused by: java.io.StreamCorruptedException: invalid stream header at java.io.ObjectInputStream.readStreamHeader(Unknown Source) at java.io.ObjectInputStream.<init>(Unknown Source) at org.jboss.remoting.loading.ObjectInputStreamWithClassLoader.<init>(ObjectInputStreamWithClassLoader.java:57) at org.jboss.remoting.serialization.impl.java.JavaSerializationManager.createInput(JavaSerializationManager.java:52) at org.jboss.remoting.serialization.impl.java.JavaSerializationManager.receiveObject(JavaSerializationManager.java:119) at org.jboss.remoting.marshal.serializable.SerializableUnMarshaller.read(SerializableUnMarshaller.java:66) at org.jboss.remoting.marshal.http.HTTPUnMarshaller.read(HTTPUnMarshaller.java:131) at org.jboss.remoting.transport.http.HTTPClientInvoker.useHttpURLConnection(HTTPClientInvoker.java:166) ... 15 more
Please can anyone help.
Please can you tell me if http transport is still supported or only servlet and socker.
Regards Trevor