1 2 Previous Next 16 Replies Latest reply on Sep 26, 2006 7:58 AM by romanchr

    Specifying Default Client Binding

    Andrew Rubinger Master

      Hi.

      I'm attempting to fix related JIRA issues:

      http://jira.jboss.com/jira/browse/EJBTHREE-204
      http://jira.jboss.com/jira/browse/EJBTHREE-629
      http://jira.jboss.com/jira/browse/EJBTHREE-673

      Can anyone more familiar with how an EJB3 client obtains a binding address help me with making progress in submitting a patch? Looking for a push in the right direction.

      Thanks in advance.

      S,
      ALR

        • 1. Re: Specifying Default Client Binding
          Bill Burke Master

          You are creating a new connector? Or just modifying the one in ejb3.deployer/META-INF/jboss-service.xml?

          • 2. Re: Specifying Default Client Binding
            Andrew Rubinger Master

            If I'm understanding correctly what I need to do, modifying the existing one to get overridden values from the Service Bindings Plugin such that the Invoker Locator returned from the ProxyDeployer has client bindings other than the default.

            I think. I'm new at the "patching JBoss" game.

            S,
            ALR

            • 3. Re: Specifying Default Client Binding
              Andrew Rubinger Master

              Also, I'm working out of SVN JBoss AS Branch 4.0 - not entirely sure that's correct, but it seemed logical.

              S,
              ALR

              • 4. Re: Specifying Default Client Binding
                Bill Burke Master

                I cannot reproduce this problem

                • 5. Re: Specifying Default Client Binding
                  Andrew Rubinger Master

                  My Use Case:

                  * Obtain, Build JBoss AS from Branch_4_0.

                  * In build/output/jboss-4.0.5.CR1-ejb3/server/default/conf/jboss-service.xml:

                  <mbean code="org.jboss.services.binding.ServiceBindingManager"
                   name="jboss.system:service=ServiceBindingManager">
                   <attribute name="ServerName">ports-01</attribute>
                   <attribute name="StoreURL">${jboss.server.home.url}/conf/service-bindings.xml</attribute>
                   <attribute name="StoreFactoryClassName">
                   org.jboss.services.binding.XMLServicesStoreFactory
                   </attribute>
                   </mbean>


                  * Copy the default service bindings example file to default/conf, renaming to "service-bindings.xml" Under the "ports-01" section is:

                  <!-- EJB3 Remoting Connector ejb3.deployer/META-INF/jboss-service.xml -->
                  
                   <service-config name="jboss.remoting:type=Connector,name=DefaultEjb3Connector,handler=ejb3"
                   delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
                   <delegate-config>
                   <attribute name="InvokerLocator">socket://${jboss.bind.address}:3973</attribute>
                   </delegate-config>
                   <binding port="3973"/>
                   </service-config>


                  * Copy a simple EJB3 Service Bean to default/deploy.

                  * Set breakpoint in org.jboss.ejb3.service.ServiceRemoteProxyFactory.setRemoteBinding

                  * Run the server

                  * At breakpoint stop, binding.bindUrl evaluates to socket://0.0.0.0:3873, whereas we've specified 3973 in the service binding plugin.

                  * Run client to contact the EJB3 Service Bean.

                  * Exception after timeout:

                  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.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:78)
                   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                   at org.jboss.ejb3.service.ServiceRemoteProxy.invoke(ServiceRemoteProxy.java:92)
                   at $Proxy0.encrypt(Unknown Source)
                   at com.ninem.rx.api.encryption.EncryptionDelegate.encrypt(EncryptionDelegate.java:54)
                   at com.ninem.rx.api.encryption.EncryptionDelegateTests.testRoundtripEncryption(EncryptionDelegateTests.java:31)
                   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                   at java.lang.reflect.Method.invoke(Method.java:585)
                   at junit.framework.TestCase.runTest(TestCase.java:164)
                   at junit.framework.TestCase.runBare(TestCase.java:130)
                   at junit.framework.TestResult$1.protect(TestResult.java:110)
                   at junit.framework.TestResult.runProtected(TestResult.java:128)
                   at junit.framework.TestResult.run(TestResult.java:113)
                   at junit.framework.TestCase.run(TestCase.java:120)
                   at junit.framework.TestSuite.runTest(TestSuite.java:228)
                   at junit.framework.TestSuite.run(TestSuite.java:223)
                   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
                   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
                   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
                  Caused by: java.net.ConnectException: Connection refused: connect
                   at java.net.PlainSocketImpl.socketConnect(Native Method)
                   at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
                   at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
                   at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
                   at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
                   at java.net.Socket.connect(Socket.java:516)
                   at java.net.Socket.connect(Socket.java:466)
                   at java.net.Socket.<init>(Socket.java:366)
                   at java.net.Socket.<init>(Socket.java:179)
                   at org.jboss.remoting.transport.socket.SocketClientInvoker.createSocket(SocketClientInvoker.java:535)
                   at org.jboss.remoting.transport.socket.SocketClientInvoker.getConnection(SocketClientInvoker.java:471)
                   at org.jboss.remoting.transport.socket.SocketClientInvoker.transport(SocketClientInvoker.java:263)
                   ... 30 more
                  
                  
                  


                  • 6. Re: Specifying Default Client Binding
                    Bill Burke Master

                    then this is probably a binding manager problem, not an EJB3 problem.

                    • 7. Re: Specifying Default Client Binding
                      Andrew Rubinger Master

                      Great. Any leads to where I should post for some direction in fixing? Couldn't find a forum for the Binding Manager or the varia package...

                      And thanks, Bill.

                      S,
                      ALR

                      • 8. Re: Specifying Default Client Binding
                        Andrew Rubinger Master

                        Actually, I believe I've fixed it, and found what I believe to be the error in the EJB3 package....

                        org.jboss.ejb3.Ejb3AnnotationHandler.getContainers goes through all ejbNames and calls

                        container.setDefaultClientBinding(deployment.getDefaultClientBinding());


                        ...where appropriate, setting the default client binding of the SessionContainer's ProxyDeployer to the proper address I've overridden via the Service Binding Manager.

                        This line is missing from the method if (ejbType == EJB_TYPE.SERVICE).

                        I added locally, rebuilt - now my client can properly access my Service Bean as it obtains an InvokerLocator with proper binding address.

                        Can you please confirm and provide instructions for my submitting code or a patch?

                        Thanks!

                        S,
                        ALR

                        • 9. Re: Specifying Default Client Binding
                          Bill Burke Master

                          ah hell, didn't know you were using a @Service...sorry bout that looks like a good fix and a great find! I'll get it into RC9.

                          • 10. Re: Specifying Default Client Binding
                            Andrew Rubinger Master

                            Thank you, Bill.

                            Would you mind closing http://jira.jboss.com/jira/browse/EJBTHREE-673 and its references for me? I don't have the permissions.

                            S,
                            ALR

                            • 12. Re: Specifying Default Client Binding
                              romanchr Newbie

                              Hi guys,

                              I came accross the same problem. What I saw is that it doesn't matter if your remote object are using the @service annotation or just @remote.

                              As long as the configuration is set to anything else then "ports-default" (example ports-01, see earlier post) then JBoss 4.0.4GA is not able to execute any kind of function on any remote object (in my case stateless session bean).
                              On the client side you end up with the earlier in this thread posted exception.

                              If you set the configuration to ports-default, everything works fine.

                              We would be realy glad if this bug is resolved as fast as possible. A patch release before RC9 woudl be great.

                              Regards,

                              Christoph

                              • 13. Re: Specifying Default Client Binding
                                Andrew Rubinger Master

                                I'm now getting the same problem when specifying @LocalBinding and @RemoteBinding instead of using the default JNDI names. InvokerLocator in the Proxy returned holds reference to incorrect port (should have been overridden by Service Binding Manager).

                                I'm not sure if this affects only @Service, as in the previous error, or Session beans as well. Will investigate and report back.

                                S,
                                ALR

                                • 14. Re: Specifying Default Client Binding
                                  Andrew Rubinger Master

                                  Perhaps this isn't a bug, but IMHO makes developing very difficult.

                                  From ProxyDeployer.initializeRemoteBindingMetadata():

                                  if (binding == null)
                                   {
                                   ...
                                   }
                                   else
                                   {
                                   RemoteBinding[] list = {binding};
                                   remoteBindings = new RemoteBindingsImpl(list);
                                   advisor.getAnnotations().addClassAnnotation(RemoteBindings.class, remoteBindings);
                                   }


                                  Saying - if you've specified @RemoteBinding, use the bind parameters it contains. One of these is clientBindUrl, which gets a default value of socket://0.0.0.0:3873 unless explicitly overridden in the annotation.

                                  What if you've specified in the Service Bindings manager that your EJBs should be contacted via an alternate port? The only way to contact on the new port is to specify the client bind URL in the annotation? I'd like to be able to deploy my EJBs into any configured server instance without telling it where it should be listening; that's already been accomplished for all my other components in the Service Bind Manager.

                                  Unfortunately as it stands it's impossible to determine whether the @RemoteBinding.clientBindUrl value was set through the default, or specified by the user. I'd recommend having the default value of @RemoteBinding.clientBindUrl be null, and changing the code in ProxyDeployer to the following:

                                  else
                                   {
                                  // If the @RemoteBinding.clientBindUrl was specified
                                  // by the developer, use it, otherwise use the default
                                   RemoteBinding[] list = {new RemoteBindingImpl(
                                   binding.jndiBinding(),
                                   binding.interceptorStack(),
                                   (binding.clientBindUrl() == null) ? this.defaultClientBinding : binding.clientBindUrl(),
                                   binding.factory())};
                                   remoteBindings = new RemoteBindingsImpl(list);
                                   advisor.getAnnotations().addClassAnnotation(RemoteBindings.class, remoteBindings);
                                   }


                                  Thoughts?

                                  1 2 Previous Next