5 Replies Latest reply on Dec 21, 2005 5:22 AM by Martin Heinemann

    Client call Stateless problem, Bug??

    song hao Newbie


      public @Stateless class CmpTestBean implements CmpTest {
       @PersistenceContext(unitName = "fids")
       protected EntityManager em;
       public void dosomething() {
       aodb_chkin_desk ak = new aodb_chkin_desk("A01");
       aodb_chkin_desk ab = new aodb_chkin_desk("A02");
       if (ak != null){
       System.out.println("not find");
       }catch(Exception e){

      15:30:40,905 INFO [STDOUT] start
      15:30:40,905 INFO [STDOUT] find
      15:30:41,065 INFO [STDOUT] ok
      15:30:41,155 ERROR [ServerThread] failed
      java.net.SocketException: Connection reset
       at java.net.SocketInputStream.read(SocketInputStream.java:168)
       at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
       at java.io.BufferedInputStream.read(BufferedInputStream.java:235)
       at java.io.ObjectInputStream$PeekInputStream.peek(ObjectInputStream.java
       at java.io.ObjectInputStream$BlockDataInputStream.readBlockHeader(Object
       at java.io.ObjectInputStream$BlockDataInputStream.refill(ObjectInputStre
       at java.io.ObjectInputStream$BlockDataInputStream.read(ObjectInputStream
       at java.io.ObjectInputStream$BlockDataInputStream.readByte(ObjectInputSt
       at java.io.ObjectInputStream.readByte(ObjectInputStream.java:864)
       at org.jboss.remoting.transport.socket.ServerSocketWrapper.checkConnecti
       at org.jboss.remoting.transport.socket.ServerThread.acknowledge(ServerTh
       at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.j
       at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.jav

      what's wrong?

        • 1. Re: Client call Stateless problem, Bug??
          Vladimir Atehortua Newbie

          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??
            Eric Dale Newbie

            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

            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)
             if (System.getSecurityManager() == null)
             System.setSecurityManager(new RMISecurityManager());
             Properties props = new Properties();
             props.setProperty(Context.PROVIDER_URL, "");
             InitialContext initial = new InitialContext(props);
             Hello hello = (Hello)initial.lookup(Hello.class.getName());
             catch (NamingException e)

            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;
            public class HelloBean implements Hello {
             public String sayHello() {
             return "Hello";


            <?xml version="1.0" encoding="UTF-8"?>
             <mbean code="org.jboss.ejb3.EJB3Deployer" name="jboss.ejb3:service=EJB3Deployer">
             <mbean code="org.jboss.remoting.transport.Connector"
             <attribute name="InvokerLocator"></attribute>
             <attribute name="Configuration">
             <handler subsystem="AOP">org.jboss.aspects.remoting.AOPRemotingInvocationHandler</handler>

            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 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??
              Martin Heinemann Newbie


              just close the IntitialContext after you have finished your call.
              This will prevent the TimeOutException.

              • 5. Re: Client call Stateless problem, Bug??
                Martin Heinemann Newbie

                don't think about this any furhter. It is wrong. My fault.