6 Replies Latest reply on Feb 20, 2007 9:36 AM by amdonov

    Failed to accept socket connection

    Primitivo Dimahugot Newbie

      I'm using jboss4.0.4.GA
      i added this in my $jboss_home/server/$my_server/deploy/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=socket3843,handler=ejb3">
       <depends>jboss.aop:service=AspectDeployer</depends>
       <attribute name="InvokerLocator">sslsocket://0.0.0.0:3843</attribute>
       <attribute name="Configuration">
       <handlers>
       <handler subsystem="AOP">org.jboss.aspects.remoting.AOPRemotingInvocationHandler</handler>
       </handlers>
       </attribute>
       </mbean>
      


      I have an StatefulBean w/ the ff. annotations:
      @Stateful
      @Local({RoleLDAO.class})
      @Remote({RoleRDAO.class})
      @RemoteBindings({
       @RemoteBinding(clientBindUrl="sslsocket://0.0.0.0:3843", jndiBinding="RoleSFDAOActionSSL"),
       @RemoteBinding(jndiBinding="RoleSFDAOAction")
      })
      


      I made a keystore, certificate, truststore for the cleient and server as descrived in http://docs.jboss.org/ejb3/app-server/reference/build/reference/en/html/transport.html

      I have a client program with this code:
      RoleDAO roleDAO = (RoleDAO) context.lookup("RoleSFDAOActionSSL");
      
      
      i got this server error
      
      17:35:14,231 ERROR [SSLSocketServerInvoker] Failed to accept socket connection
      java.lang.reflect.InvocationTargetException
       at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
       at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
       at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
       at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
       at org.jboss.remoting.transport.socket.ServerThread.createServerSocket(ServerThread.java:184)
       at org.jboss.remoting.transport.socket.ServerThread.<init>(ServerThread.java:86)
       at org.jboss.remoting.transport.socket.SocketServerInvoker.processInvocation(SocketServerInvoker.java:426)
       at org.jboss.remoting.transport.socket.SocketServerInvoker.run(SocketServerInvoker.java:388)
       at java.lang.Thread.run(Thread.java:595)
      Caused by: java.io.StreamCorruptedException: invalid stream header
       at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:753)
       at java.io.ObjectInputStream.<init>(ObjectInputStream.java:268)
       at org.jboss.remoting.loading.ObjectInputStreamWithClassLoader.<init>(ObjectInputStreamWithClassLoader.java:73)
       at org.jboss.remoting.serialization.impl.java.JavaSerializationManager.createInput(JavaSerializationManager.java:52)
       at org.jboss.remoting.transport.socket.ServerSocketWrapper.createInputStream(ServerSocketWrapper.java:56)
       at org.jboss.remoting.transport.socket.ClientSocketWrapper.createStreams(ClientSocketWrapper.java:76)
       at org.jboss.remoting.transport.socket.ClientSocketWrapper.<init>(ClientSocketWrapper.java:54)
       at org.jboss.remoting.transport.socket.ServerSocketWrapper.<init>(ServerSocketWrapper.java:50)
       ... 9 more
      
      
      
      
      
      Please help.
      


        • 1. Re: Failed to accept socket connection
          Primitivo Dimahugot Newbie

          but when i do not use the SSL jniBinding like so:

          RoleDAO roleDAO = (RoleDAO) context.lookup("RoleSFDAOAction");
          

          everything works fine.

          i need to use ssl for my sesssion beans but i can't because of the errors i mentioned in my previous post. anyone got any idea how to solve this?

          tnx.

          • 2. Re: Failed to accept socket connection
            Primitivo Dimahugot Newbie

            BTW, on the client program, i got this error:

            javax.naming.NamingException: Could not dereference object [Root exception is org.jboss.remoting.CannotConnectException: Can not get connection to server. Problem establishing socket connection.]
             at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1150)
             at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:705)
             at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
             at javax.naming.InitialContext.lookup(InitialContext.java:351)
             at com.medsoft.util.DataLoader.addRoles(DataLoader.java:51)
             at com.medsoft.util.DataLoader.<init>(DataLoader.java:40)
             at com.medsoft.util.DataLoader.main(DataLoader.java:109)
            Caused by: org.jboss.remoting.CannotConnectException: Can not get connection to server. Problem establishing socket connection.
             at org.jboss.remoting.transport.socket.SocketClientInvoker.transport(SocketClientInvoker.java:267)
             at org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInvoker.java:143)
             at org.jboss.remoting.Client.invoke(Client.java:525)
             at org.jboss.remoting.Client.invoke(Client.java:488)
             at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:55)
             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
             at org.jboss.aspects.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:48)
             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
             at org.jboss.aspects.remoting.PojiProxy.invoke(PojiProxy.java:61)
             at $Proxy0.createProxy(Unknown Source)
             at org.jboss.ejb3.JndiProxyFactory.getObjectInstance(JndiProxyFactory.java:52)
             at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
             at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1125)
             at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1142)
             ... 6 more
            Caused by: java.lang.reflect.InvocationTargetException
             at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
             at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
             at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
             at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
             at org.jboss.remoting.transport.socket.SocketClientInvoker.createClientSocket(SocketClientInvoker.java:518)
             at org.jboss.remoting.transport.socket.SocketClientInvoker.getConnection(SocketClientInvoker.java:485)
             at org.jboss.remoting.transport.socket.SocketClientInvoker.transport(SocketClientInvoker.java:263)
             ... 19 more
            Caused by: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
             at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:742)
             at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1030)
             at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:678)
             at com.sun.net.ssl.internal.ssl.AppInputStream.read(AppInputStream.java:75)
             at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
             at java.io.BufferedInputStream.read1(BufferedInputStream.java:256)
             at java.io.BufferedInputStream.read(BufferedInputStream.java:313)
             at java.io.ObjectInputStream$PeekInputStream.read(ObjectInputStream.java:2222)
             at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2235)
             at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2703)
             at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:760)
             at java.io.ObjectInputStream.<init>(ObjectInputStream.java:278)
             at org.jboss.remoting.loading.ObjectInputStreamWithClassLoader.<init>(ObjectInputStreamWithClassLoader.java:73)
             at org.jboss.remoting.serialization.impl.java.JavaSerializationManager.createInput(JavaSerializationManager.java:52)
             at org.jboss.remoting.transport.socket.ClientSocketWrapper.createInputStream(ClientSocketWrapper.java:83)
             at org.jboss.remoting.transport.socket.ClientSocketWrapper.createStreams(ClientSocketWrapper.java:76)
             at org.jboss.remoting.transport.socket.ClientSocketWrapper.<init>(ClientSocketWrapper.java:54)
             ... 26 more
            Caused by: java.io.EOFException: SSL peer shut down incorrectly
             at com.sun.net.ssl.internal.ssl.InputRecord.read(InputRecord.java:333)
             at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:723)
             ... 42 more
            


            • 3. Re: Failed to accept socket connection
              Ron Sigal Master

              This is puzzling. The client side failed during ssl handshake, but the server side either (1) succeeded with the handshake and got unexpected header bytes, or (2) bypassed the handshake and mistook the handshake protocol bytes for object stream header bytes. The only way I can think of for (2) to occur would be if somehow a plain vanilla ServerSocketFactory is being used on the server side. Could you set the logging level for org.jboss.remoting to DEBUG in $jboss_home/server/$my_server/conf/log4j.xml? The output of

              log.debug("Created server socket factory: " + serverSocketFactory);
              


              should appear. Just a thought.

              • 4. Re: Failed to accept socket connection
                Ariel Newbie

                I implemented SSL as described in this post and I see the same client and server exceptions. I am using Jboss 4.04 RC 4.
                Is there a fix to this problem, perhaps in a later RC?

                • 5. Re: Failed to accept socket connection
                  Heiko Lettmann Newbie

                  The same issue with 4.04 and 4.05...

                  • 6. Re: Failed to accept socket connection
                    amdonov Newbie

                    After some poking around, I found that someone duplicated this problem with a testcase at http://jira.jboss.com/jira/browse/EJBTHREE-819. No one is working it. Based upon the steps outlined in http://jira.jboss.com/jira/browse/JBWS-1134. I upgraded jboss-remoting to 2.0. It only requires a minor change to JBOSS_HOME/server/INSTANCE/deploy/ejb3.deployer/META-INF/jboss-service.xml and one line of new code to org.jboss.aspects.remoting.InvokeRemoteInterceptor. After those changes, I can successfully make ejb calls over SSL. The one caveat is that I did not run any of the JBoss testsuite. It could break something, but I haven't had any problems yet.