-
1. Re: Client call Stateless problem, Bug??
adun Dec 20, 2005 6:15 PM (in response to adver11)Something similar happens to me.
I installed JBoss 4.03 SP1, graphicall installer, selected "ejb3" installation.
I'm using the tutorial for stateless session beans, the "Calculator" one. I created all the annotated classes, jared them on a .ejb3 file, and copied the .ejb3 file in the deploy folder of my server.
When I dropped the .ejb file there, the JBoss logs showed that it detected it and deployed a stateless ession bean.
But then when I run the client example from the tutorial (as a remote client in its own JVM with jboss jars in classpath and proper .jndi.properties), the server log shows the same "ERROR [ServerThread] failed
java.net.SocketException: Connection reset".
The client seems to be ok, since I get the proper result of the tutorial
"1 + 1 = 2
1 - 1 = 0"
... but that exception on the server log doesnt make me feel good.
I think JBoss NEEDS to put on some brief documentation/example on how to get EJB3 running with remote clients outside of the container. -
2. Re: Client call Stateless problem, Bug??
edale Dec 20, 2005 7:40 PM (in response to adver11)Same problem for me. Here's a configuration that seems to get rid of the error. Note that it assumes your jboss server ip address is 192.168.0.101
Client app:package com.nfr.hello.client; import java.rmi.RMISecurityManager; import java.util.Properties; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import com.nfr.hello.server.Hello; public class HelloClient { public static void main(String[] args) { try { if (System.getSecurityManager() == null) { System.setSecurityManager(new RMISecurityManager()); } Properties props = new Properties(); props.setProperty(Context.PROVIDER_URL, "192.168.0.101"); InitialContext initial = new InitialContext(props); Hello hello = (Hello)initial.lookup(Hello.class.getName()); System.out.println(hello.sayHello()); } catch (NamingException e) { e.printStackTrace(); } } }
Security policy file for client app (c:\test.policy)grant { // Allow everything for now permission java.security.AllPermission; };
Bean Interface:package com.nfr.hello.server; public interface Hello { public String sayHello(); }
Stateless Bean:package com.nfr.hello.server; import javax.ejb.Remote; import javax.ejb.Stateless; import org.jboss.annotation.ejb.RemoteBinding; import org.jboss.annotation.ejb.RemoteBindings; @Stateless @Remote({Hello.class}) @RemoteBindings({ @RemoteBinding( clientBindUrl="http://192.168.0.101:8082/servlet-invoker/ServerInvokerServlet") }) public class HelloBean implements Hello { public String sayHello() { return "Hello"; } }
deploy/ejb3.deployer/META-INF/jboss-service.xml:<?xml version="1.0" encoding="UTF-8"?> <server> <mbean code="org.jboss.ejb3.EJB3Deployer" name="jboss.ejb3:service=EJB3Deployer"> <depends>jboss.aop:service=AspectDeployer</depends> </mbean> <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">http://192.168.0.101:8082/servlet-invoker/ServerInvokerServlet</attribute> <attribute name="Configuration"> <handlers> <handler subsystem="AOP">org.jboss.aspects.remoting.AOPRemotingInvocationHandler</handler> </handlers> </attribute> </mbean> </server>
So, to make this work:
1) start with a clean install of 4.0.3SP1, selecting the "ejb3" installation,
2) change the jboss-service.xml file as illustrated above
3) replace all references to 192.168.0.101 in this sample code with the IP address or DNS name of your JBoss server
4) Deploy the stateless session bean in a jar file named hello.ejb3
5) Save the test.policy file somewhere on the client machine (for Windows, c:\test.policy works fine)
5) Run the client app using the following JVM argument: java -Djava.security.policy=c:\test.policy
And you should be able to invoke methods without the error message
Hope this helps a little. Obvously this is not a realistic scenario. The JBoss server IP addresses is in 3 spots: the client app, the server bean, and an XML file. That would be a real headache for a production application.
Worse, it doesn't work at all on a WAN where there is network address translations happening between the client LAN and server LAN. And, speaking from experience, using DNS is not a workable solution for this problem.
I'm not only looking for an answer to this problem, I am also having trouble making this example work on the same port as tomcat (i.e. port 8080), which is another critical need for the application I'm working on.
In our case, it took two experienced developers about a month to work through all of this with JBoss 4.0.0 and EJB2. EJB3 is much easier, but the lack of real-world examples is making this task almost as hard.
JBoss is a beautiful product, and has excellent high-level documentation, but I wish they would provide more cookbook-style examples that show the EXACT steps needed to take a stock jboss server and configure it to solve common problems like this. -
4. Re: Client call Stateless problem, Bug??
heinrich Dec 21, 2005 3:15 AM (in response to adver11)Hi,
just close the IntitialContext after you have finished your call.
This will prevent the TimeOutException. -
5. Re: Client call Stateless problem, Bug??
heinrich Dec 21, 2005 5:22 AM (in response to adver11)hi,
don't think about this any furhter. It is wrong. My fault.