12 Replies Latest reply on Mar 24, 2014 9:46 AM by Chuck Davis

    remote ejb

    Chuck Davis Newbie

      Has anyone been successful using remote ejb with Wildfly 8 final?  My code no longer works (worked on alpha4 as I recall).

       

      The document @ EJB invocations from a remote client using JNDI - WildFly 8 - Project Documentation Editor states the following:

       

      "Before getting into the details, we would like the users to know that we have introduced a new EJB client API, which is a WildFly-specific API and allows invocation on remote EJBs. This client API isn't based on JNDI. So remote clients need not rely on JNDI API to invoke on EJBs. A separate document covering the EJB remote client API will be made available."

       

      Has anybody seen that document?

       

      The only other documentation I have found is the very confusing article linked to just above the quoted verbiage.

       

      Would it be possible for somebody who knows what is going on to do the document referenced that will be for the EJB client API only without confusing the issue with the remoting project?  I need to know what configuration if any is required and the code to connect to a stateful ejb.  No combination I have been able to extract from the documentation has worked.

       

      My context creation code is as follows:

       

              Properties jndiProps = new Properties();
              jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
              jndiProps.put(Context.PROVIDER_URL, "remote://192.168.3.93:8080");
             jndiProps.put(Context.SECURITY_PRINCIPAL, "myname");

             jndiProps.put(Context.SECURITY_CREDENTIALS, "my_password");
              jndiProps.put("jboss.naming.client.ejb.context", true);
              jndiProps.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");

       

              try {
                  context = new InitialContext(jndiProps);
              } catch (NamingException ex) {
                  Logger.getLogger(ClientConstants.class.getName()).log(Level.SEVERE, null, ex);
              }
              try {
                  myBean = (NewSessionBeanRemote) context.lookup("ejb:PlatformServer/PlatformServer-ejb//NewSessionBean!com.yrs.server.NewSessionBeanRemote?stateful");
              } catch (NamingException ex) {
                  Logger.getLogger(ClientConstants.class.getName()).log(Level.SEVERE, null, ex);
              }

       

      Thanks for any advice.

        • 1. Re: remote ejb
          Chuck Davis Newbie

          By the way, the exception I'm getting is:

           

          java.lang.IllegalStateException: EJBCLIENT000024: No EJB receiver available for handling [appName:PlatformServer, moduleName:PlatformServer-ejb, distinctName:] combination

              at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:813)

              at org.jboss.ejb.client.EJBClient.createSessionWithPossibleRetries(EJBClient.java:222)

              at org.jboss.ejb.client.EJBClient.createSession(EJBClient.java:202)

              at org.jboss.ejb.client.naming.ejb.EjbNamingContext.doCreateProxy(EjbNamingContext.java:216)

              at org.jboss.ejb.client.naming.ejb.EjbNamingContext.createEjbProxy(EjbNamingContext.java:193)

          Caused: javax.naming.NamingException: Failed to create proxy [Root exception is java.lang.IllegalStateException: EJBCLIENT000024: No EJB receiver available for handling [appName:PlatformServer, moduleName:PlatformServer-ejb, distinctName:] combination]

              at org.jboss.ejb.client.naming.ejb.EjbNamingContext.createEjbProxy(EjbNamingContext.java:195)

              at org.jboss.ejb.client.naming.ejb.EjbNamingContext.lookup(EjbNamingContext.java:176)

              at javax.naming.InitialContext.lookup(InitialContext.java:411)

          • 2. Re: remote ejb
            Wolf-Dieter Fink Master

            These properties:

                 jndiProps.put("jboss.naming.client.ejb.context", true);

                 jndiProps.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");

            are for different approaches, as you use remote-naming you should not set the URL_PKG_PREFIXES as this is used for the ejb-client approach.

             

            Did that work for you. Also you should consider that remote-naming is not recommended for ejb invocations.

            • 3. Re: remote ejb
              Chuck Davis Newbie

              Thanks for your assistance Wolf-Dieter.

               

              I WANT to use the ejb API -- it's the new cutting edge making me bleed!    Which of the statements is required/not required?

               

              I commented out the URL_PKG_PREFIXES line and ran it and now am getting the following exception:

               

              java.net.ConnectException: Operation failed with status WAITING after 5000 MILLISECONDS

                  at org.jboss.naming.remote.protocol.IoFutureHelper.get(IoFutureHelper.java:97)

                  at org.jboss.naming.remote.client.HaRemoteNamingStore.failOverSequence(HaRemoteNamingStore.java:198)

              Caused: javax.naming.CommunicationException: Failed to connect to any server. Servers tried: [remote://192.168.3.93:8080 (Operation failed with status WAITING after 5000 MILLISECONDS)] [Root exception is java.net.ConnectException: Operation failed with status WAITING after 5000 MILLISECONDS]

                  at org.jboss.naming.remote.client.HaRemoteNamingStore.failOverSequence(HaRemoteNamingStore.java:240)

                  at org.jboss.naming.remote.client.HaRemoteNamingStore.namingStore(HaRemoteNamingStore.java:149)

                  at org.jboss.naming.remote.client.HaRemoteNamingStore.namingOperation(HaRemoteNamingStore.java:130)

                  at org.jboss.naming.remote.client.HaRemoteNamingStore.lookup(HaRemoteNamingStore.java:272)

                  at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:79)

                  at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:83)

                  at javax.naming.InitialContext.lookup(InitialContext.java:411)

               

              Wildfly is definitely listenting on port 8080 at that address.

              Is there something I have to configure in an xml file other than deploying my *ear file?

               

              My SessionBean is very simple -- just a call to return a string -- while I search for the correct syntax to make a connection.  The session bean is boiler plate from NetBeans so I'm sure the code is correct.

               

              Again, thanks for any help figuring this out.

              • 4. Re: remote ejb
                Wolfgang Knauf Master

                Hi Chuck,

                 

                I did not test my own remote client sample in WildFly 8 final, but on an older beta version, the "PROVIDER_URL" had to be:

                 

                jndiProps.put(Context.PROVIDER_URL, "http-remoting://192.168.3.93:8080");

                 

                WildFly closed all different ports, only port 8080 is used and "http upgrade" is used.

                 

                As far as I understand the remote ejb invocations, your JNDI name will not work. Remove the prefix "ejb:". This part is only required if you use the "JBoss EJB client" is used.

                 

                Hope this helps

                 

                Wolfgang

                • 5. Re: remote ejb
                  Wolf-Dieter Fink Master

                  wolfgangknauf is right, the protocol has changed.

                   

                  If you want to use the recommended ejb-client api you should look to Scoped EJB client contexts - WildFly 8

                  • 6. Re: remote ejb
                    Chuck Davis Newbie

                    Thanks guys for your help.  Unfortunately, I'm still going noplace fast!  I created a clean project using Maven rather than Ant in NetBeans with the Wildfly plugin that a Red Hat employee is kindly providing.  My code is currently: Properties jndiProps = new Properties(); jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory"); jndiProps.put(Context.PROVIDER_URL, "http-remoting://192.168.3.93:8080"); jndiProps.put(Context.SECURITY_PRINCIPAL, "myname");  // not the real value jndiProps.put(Context.SECURITY_CREDENTIALS, "mypass");  // not the real value jndiProps.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming"); jndiProps.put("org.jboss.ejb.client.scoped.context", true); try { context = new InitialContext(jndiProps); } catch (NamingException ex) { io.getOut().println(ex.getMessage() + " @ context creation"); io.getOut().println("the cause is: " + ex.getCause().getMessage()); } if(context == null) { io.getOut().println("context is null so lookup won't work"); } The exception thrown at context creation is now: Failed to create remoting connection @ context creation the cause is: No matching XNIO provider found context is null so lookup won't work Again, I've verified that Wildfly is listening on port 8080 at that address. I changed the JNDI lookup string but of course I'm not getting that far yet so that will be a future issue.

                    • 7. Re: remote ejb
                      Chuck Davis Newbie

                      Brother, what a mess that made!  I'll try this again using HTML

                       

                      Thanks guys for your help.  Unfortunately, I'm still going noplace fast!  I created a clean project using Maven rather than Ant in NetBeans with the Wildfly plugin that a Red Hat employee is kindly providing.

                      My code is currently:

                       

                       

                              Properties jndiProps = new Properties();
                              jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
                              jndiProps.put(Context.PROVIDER_URL, "http-remoting://192.168.3.93:8080");
                              jndiProps.put(Context.SECURITY_PRINCIPAL, "chuck");
                              jndiProps.put(Context.SECURITY_CREDENTIALS, "run4$woodway");
                              jndiProps.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
                              jndiProps.put("org.jboss.ejb.client.scoped.context", true);
                              try {
                                  context = new InitialContext(jndiProps);
                              } catch (NamingException ex) {
                                  io.getOut().println(ex.getMessage() + " @ context creation");
                                  io.getOut().println("the cause is: " + ex.getCause().getMessage());
                              }       
                              if(context == null) {
                                  io.getOut().println("context is null so lookup won't work");
                              }

                       

                      The exception thrown at context creation is now:

                      Failed to create remoting connection @ context creation

                      the cause is: No matching XNIO provider found

                      context is null so lookup won't work

                       

                      Again, I've verified that Wildfly is listening on port 8080 at that address.

                       

                      I changed the JNDI lookup string but of course I'm not getting that far yet so that will be a future issue.

                      • 8. Re: remote ejb
                        Wolfgang Knauf Master

                        Hi,

                         

                        sounds like a missing JAR file in your maven config (xnio-api-x.y.z.jar). How does it look like?

                         

                        But I fear I cannot help much - I don't use maven much.

                         

                        Best regards

                         

                        Wolfgang

                        • 9. Re: remote ejb
                          Wolf-Dieter Fink Master

                          Are you using mavein to start the client?

                          What if you use plain jave and add the JBOSS/bin/client/jboss-client.jar to the classpath?

                          • 10. Re: remote ejb
                            Chuck Davis Newbie

                            Well, if changing the exception is advancing toward a cure then I'm on the march.  My exception now is as follows:

                             

                            Failed to create remoting connection @ context creation

                            the cause is: org.xnio.XnioProvider: Provider org.xnio.nio.NioXnioProvider could not be instantiated: java.lang.NoClassDefFoundError: org/xnio/FileSystemWatcher

                            context is null so lookup won't work

                             

                            This appears to be a 100% client environment issue.  I've let Maven search for every xnio jar it can find and I've tried the jboss ones:  org.jboss.xnio : xnio-all and jboss:jboss-client.   None of them has a class org.xnio.FileSystemWatcher class in the jar.

                             

                            So l googled org.nxio.FileSystemWatcher and discovered it is copyrighted by Red Hat last year and is in package org.xnio.  Unfortunately it's not in any of the jboss jars Maven can find.

                             

                            I'm no Maven expert either Wolfgang.  I'm just starting to use it but I love how it finds things.  It found a number of xnio jars but none of them has this FileSystemWatcher class in it.  Since this appears to be a 100% client issue I'm wondering if jboss/wildfly has a packaging defect?

                             

                            No Wolf-dieter I'm not using Maven to run the project.  I'm running it from Netbeans project management (which IS plain old Java).  One of the reasons I'm moving toward Maven is that I've read lately that Netbeans has a superb implementation.  One thing is for sure -- Maven makes a lot more sense and is much nicer to use than Ant ever was!  The first project (when I started this thread) was a Netbeans Ant project and was using the jboss-client distributed with Wildfly 8 in the bin/client directory.

                            • 11. Re: remote ejb
                              Wolfgang Knauf Master

                              Hi,

                               

                              how does your pom.xml look like? I found this one, which also contains the XNIO related jars: https://github.com/wildfly/quickstart/blob/master/ejb-remote/client/pom.xml

                               

                              Hope this helps

                               

                              Wolfgang

                              • 12. Re: remote ejb
                                Chuck Davis Newbie

                                Thanks Wolfgang.  Unfortunately it's Monday morning here and work stands in the way of progress!  Thanks for the reference to that POM in the quickstart.  Last I knew the quickstart hadn't been updated for the port change (and presumably the protocol change too).  I'll study it when I get a chance (hopefully before next weekend!).