4 Replies Latest reply on Apr 27, 2014 2:54 AM by jaikiran

    Is Spring compatible with EJB / remote naming?

    pbenedict

      I have a Spring 3.2 webapp deployed on server A and remote EJBs deployed on server B. Both servers are using WildFly 8. The webapp is unable to see the remote EJBs.

       

      Here is the Spring config:

      <util:properties id="props" location="classpath:/jndi.properties"/>
      
      <jee:remote-slsb
        id="locationService"
        jndi-name="myapp/myejb/LocationServiceBean!com.company.LocationService"
        resource-ref="false"
        environment-ref="props"
        business-interface="com.company.LocationService"/>
      
      
      
      
      
      
      

       

      Here are the properties:

      java.naming.factory.initial=org.jboss.naming.remote.client.InitialContextFactory
      java.naming.provider.url=http-remoting://localhost:8080
      java.naming.security.principal=ejb
      java.naming.security.credentials=test
      
      
      
      
      
      
      

       

      And I am importing the correct module (necessary to make visible the JBoss InitialContextFactory referenced above):

      <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
        <deployment>
          <dependencies>
           <module name="org.jboss.remote-naming" />
          </dependencies>
        </deployment>
      </jboss-deployment-structure>
      
      
      
      
      
      
      

       

      Upon startup of the webapp, the home interface can be found. However, invocation always always always fails. I have yet to ever get it to work.

      Caused by: java.lang.IllegalStateException: EJBCLIENT000025: No EJB receiver available for handling [appName:myapp, moduleName:myejb, distinctName:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@7261573e
          at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:749)
          at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:116)
          at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:186)
          at org.jboss.ejb.client.EJBInvocationHandler.sendRequestWithPossibleRetries(EJBInvocationHandler.java:253)
          at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:198)
          at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:181)
          at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:144)
          at com.sun.proxy.$Proxy113.locate(Unknown Source)
      
      
      
      
      
      
      

       

      FYI, I followed the instructions here:

      https://docs.jboss.org/author/display/WFLY8/Remote+EJB+invocations+via+JNDI+-+EJB+client+API+or+remote-naming+project

        • 1. Re: Is Spring compatible with EJB / remote naming?
          jaikiran

          Never tried Spring. But does it allow you to pass additional JBoss specific properties from that jndi.properties that you are using? If yes, then add this property to it:

           

          jboss.naming.client.ejb.context=true

           

          and see if it works

          • 2. Re: Re: Is Spring compatible with EJB / remote naming?
            pbenedict

            Jaikiran, I hope you can keep watching this post for a bit. I appreciate your assistance.

             

            This did not work:

            Never tried Spring. But does it allow you to pass additional JBoss specific properties from that jndi.properties that you are using? If yes, then add this property to it:

            jboss.naming.client.ejb.context=true

             

            But I did get this to work in an unexpected matter and need assistance on understanding why. I even stepped through the JBoss server during debugging to get an understanding of what is going on. Consequently, it appears I need to setup BOTH remote naming/JNDI [1] and JBoss client setup [2]. Spring uses remote naming to find the bean. However, when JBoss goes invoking the bean, it requires that an org.jboss.ejb.client.EJBReceiver exist (and in my case it was the org.jboss.ejb.client.remoting.RemoteConnectionEJBReceiver instance). So both steps are critically important. But really my question is why can't JBoss be "smart enough" to simply invoke the bean that I already found instead of requiring an additional layer of setup?

             

            BTW, I should note that this is all the JNDI config I needed:

            java.naming.factory.initial=org.jboss.naming.remote.client.InitialContextFactory
            java.naming.provider.url=http-remoting://localhost:8080
            

             

            It seems my JNDI lookup isn't secure. I did specify a principal and credentials but those didn't matter. I guess I haven't found out how to secure the JNDI -- any pointers?

             

            PS: I don't like how port 8080 is used both for servicing user requests and remoting. I know WildFly 8 [3] makes a big deal about "combining the ports" but it screams of a security hole to me. Why would I ever want to open a port to the public for both user requests and internal object lookups? It was way better keeping the two separate.

             

            [1] https://docs.jboss.org/author/display/WFLY8/Remote+EJB+invocations+via+JNDI+-+EJB+client+API+or+remote-naming+project

            [2] https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+server+instance

            [3] http://planet.jboss.org/post/wildfly_8_0_0_alpha3_released_with_support_for_ejb_invocations_over_http

             

            Thoughts?

            • 3. Re: Is Spring compatible with EJB / remote naming?
              jaikiran

              Paul Benedict wrote:

               

              But I did get this to work in an unexpected matter and need assistance on understanding why. I even stepped through the JBoss server during debugging to get an understanding of what is going on. Consequently, it appears I need to setup BOTH remote naming/JNDI [1] and JBoss client setup [2]. Spring uses remote naming to find the bean. However, when JBoss goes invoking the bean, it requires that an org.jboss.ejb.client.EJBReceiver exist (and in my case it was the org.jboss.ejb.client.remoting.RemoteConnectionEJBReceiver instance). So both steps are critically important. But really my question is why can't JBoss be "smart enough" to simply invoke the bean that I already found instead of requiring an additional layer of setup?

               

              It can be smart enough and that's where the jboss.naming.client.ejb.context JNDI context property comes into picture. When it is set to true, the remote naming just reuses the connection to create a EJBClientContext backed by the remoting connection and allows invocation to continue on that connection. It's just a matter of making sure that jboss.naming.client.ejb.context is being passed as true through the spring configuration file(s). I don't have much experience in that latter part but a quick look at the docs suggests that you can just add it to the .properites file you are referring to in the Spring configuration and that should have worked.

              • 4. Re: Is Spring compatible with EJB / remote naming?
                jaikiran

                Paul Benedict wrote:

                 

                 

                PS: I don't like how port 8080 is used both for servicing user requests and remoting.

                ...

                 

                Thoughts?

                I think you have already got some inputs on how to revert back to the multi port behaviour, but for the others who are curious, take a look at the comments here https://issues.jboss.org/browse/WFLY-3282?focusedCommentId=12963626&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-12963626