1 2 Previous Next 18 Replies Latest reply on Sep 18, 2017 5:45 AM by Loren Chang

    Remote EJB Look up in Wildfly 8.2.Final

    Arnab Ghosh Novice

      Hi All,

       

      I need to look up SessionBeans, both Stateless and Stateful, deployed in one instance of Wildfly 8.2 from application deployed in another instance Wildfly 8.2 and also from a standalone client. I read couple of articles:

      EJB invocations from a remote server instance - WildFly 8 - Project Documentation Editor

      Remote EJB invocations via JNDI - EJB client API or remote-naming project - WildFly 8 - Project Documentation Editor

      EJB invocations from a remote client using JNDI - JBoss AS 7.1 - Project Documentation Editor

       

      I am unable to decide on an approach. If I use the EJB client approach will the code be same while doing the look up from a wildfly instance or a standalone client ?

      My assumption is jboss-client.jar will only be required when I am doing the look up from the standalone client. Is this correct ?

       

      Please advice.

       

      Regards

      Arnab

        • 1. Re: Remote EJB Look up in Wildfly 8.2.Final
          tomekadamski Novice

          Hi Arnab,

          For the invocations from standalone client you should configure your beans according to article

          EJB invocations from a remote client using JNDI - JBoss AS 7.1 - Project Documentation Editor

          and for the invocations between servers from

          https://docs.jboss.org/author/display/WFLY8/EJB+invocations+from+a+remote+server+instance.

           

          Your code will look similar in both cases as you will create JNDI context to lookup remote beans but the way the connections are configured differs between standalone and server version. In standalone mode your are going to configure it using properties file and in server mode you have to configure outbound sockets in the server and refer to them from the client context file within your application. If you need to perform both standalone and server to server calls then you have to perform both configurations.

           

          Tomek

          • 2. Re: Remote EJB Look up in Wildfly 8.2.Final
            Arnab Ghosh Novice

            Thank you for your suggestion. I am trying to set this is now.

             

            I am facing one problem: I have two remote wild-fly instances from which the client application deployed in another willdfly instance needs to look up remote SessionBeans. As per the documentation i will need to create a socket-binding pointing to the remote server like below

             

             

            <socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">

             

                    ...

                    <outbound-socket-binding name="remote-ejb">

                        <remote-destination host="localhost" port="8080"/>

                    </outbound-socket-binding>

                </socket-binding-group>

             

            But I have two remote server, how to configure that ? The below breaks server start up:

                    <outbound-socket-binding name="remote-ejb">

                        <remote-destination host="server1.server.arvato-systems.de" port="8080"/>

                        <remote-destination host="server2.server.arvato-systems.de" port="8080"/>

                    </outbound-socket-binding>

             

            Please advice.

            • 3. Re: Remote EJB Look up in Wildfly 8.2.Final
              tomekadamski Novice

              You have to configure different outbound socket bindings for different destinations. In your case you need to configure two of them.

              • 4. Re: Remote EJB Look up in Wildfly 8.2.Final
                Arnab Ghosh Novice

                Yeah you are right. Just figured it out. I have add two outboud-sockets, two outboud-connections and then add two remoting-ejb-receivers in jboss-ejb-client.xml.

                • 5. Re: Remote EJB Look up in Wildfly 8.2.Final
                  Arnab Ghosh Novice

                  Hi Tomasz,

                   

                  I was able to get the Remote EJB look up working between the Wildfly instances. Thanks for you suggestion. I am creating the InitialContext like below:

                   

                  final Hashtable<String, String> props = new Hashtable<String, String>();

                  // setup the ejb: namespace URL factory

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

                  // create the InitialContext     

                  final Context context = new javax.naming.InitialContext(props);

                   

                  I have the below questions :

                  1) Is creation of this InitialContext an expensive operation ? Do the application need to re-uses the same instance  or creation of the context on every EJB look up is acceptable?

                  2) If I have configured two EJB receivers on jboss-ejb-client.xml, how will be they used during InitialContext creation ? Any selection algorithm for the receivers ?

                   

                  Thanks in Advance.

                   

                  Regards

                  Arnab

                  • 6. Re: Remote EJB Look up in Wildfly 8.2.Final
                    tomekadamski Novice

                    Hi Arnab,

                    1. You should strive to reuse InitialContext if possible.

                    2. During ejb lookup all possible providers will be queried about the bean. The first provider that is able to handle the request and responds will be chosen.

                     

                    Tomek

                    • 7. Re: Remote EJB Look up in Wildfly 8.2.Final
                      Pawel Predki Newbie

                      tomekadamski

                      Hey guys,

                       

                      I've been doing Remote EJB lookup in Wildfly 8.2 the same way you described here, by setting up  everything in the standalone.xml file. However, we're currently developing an application that wants to connect to many remote servers, all of which are created dynamically, so it's not possible to configure the connectores beforehand, as we don't even know the IP addresses of the targets.

                       

                      Is there any way to create all the needed options programatically, knowing the IP, username, password and the JNDI name of the required class?

                       

                      Cheers,

                      Pawel

                      • 8. Re: Remote EJB Look up in Wildfly 8.2.Final
                        tomekadamski Novice

                        Hi Pawel,

                        At present remote ejb configuration has to be done statically. Nevertheless, new version of ejb client library which we are currently developing is planned to provided extensible discovery mechanisms, among which dynamic discovery will be included. The new library should be helpful in your use case so please stay tuned for the information about it in new versions of WildFly - it is possible that it will be available in WildFly 11.

                         

                        Regards,

                        Tomek

                        • 9. Re: Remote EJB Look up in Wildfly 8.2.Final
                          Pawel Predki Newbie

                          Hi Tomasz,

                           

                          This is both good and bad news I understand that this would also not be possible using the 'old' method? I tried the following code:

                           

                           Properties jndiProps = new Properties();
                           jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
                           jndiProps.put("jboss.naming.client.ejb.context", true);
                           jndiProps.put(Context.PROVIDER_URL, this.getUrl());
                           jndiProps.put(Context.SECURITY_PRINCIPAL, this.getUsername());
                           jndiProps.put(Context.SECURITY_CREDENTIALS, this.getDecodedPassword());
                           Context ctx = new InitialContext(jndiProps);
                           Object remoteInstance = context.lookup(this.getJndi());
                          

                           

                          Obviously, the 'this.' methods provide the URL of the remote server (in form of http-remoting://xxx), the credentials and the JNDI name of the object I want to get.

                           

                          The funny thing is, I get a connection to the correct machine, because if I change the username or if the remote machine is not up yet, I get errors. In the end, however, I don't get the object I wanted.

                           

                          I can provide detailed error logs but I wonder if this approach might work at all.

                           

                          If we're stuck with waiting for Wildfly 11 and then upgrading from 8.2, I'm sure this will be a pain in the butt to do We were looking forward to keeping our current software platform.

                           

                          Cheers,

                          Pawel

                          • 10. Re: Remote EJB Look up in Wildfly 8.2.Final
                            tomekadamski Novice

                            Are you running this code from the standalone client of from the server? Please paste the logs I will look at them.

                            • 11. Re: Remote EJB Look up in Wildfly 8.2.Final
                              Pawel Predki Newbie

                              On my development machine I'm running two applications on one server: APP1 and APP2. On production, APP2 will be launched on every dynamically started machine and APP1 will be statically launched on a single machine. APP1 will want to connect to the remote machines with APP2s running on them.

                               

                              In the dev standalone.xml file I defined the following entries:

                               

                              <subsystem xmlns="urn:jboss:domain:remoting:2.0">
                                  <endpoint worker="default"/>
                                  <http-connector name="http-remoting-connector" connector-ref="default" security-realm="ApplicationRealm"/>
                                  <outbound-connections>
                                      <remote-outbound-connection name="remote-app2-ejb-connection" outbound-socket-binding-ref="remote-app2-ejb" username="remoteuser" security-realm="OurRealm" protocol="http-remoting">
                                          <properties>
                                              <property name="SASL_POLICY_NOANONYMOUS" value="false"/>
                                              <property name="SSL_ENABLED" value="false"/>
                                          </properties>
                                      </remote-outbound-connection>
                                  </outbound-connections>
                              </subsystem>
                              
                              ...
                              
                              <security-realm name="OurRealm">
                                  <server-identities>
                                      <secret value="cG9sc2thZ29yYQ=="/>
                                  </server-identities>
                              </security-realm>
                              
                              ...
                              
                              <outbound-socket-binding name="remote-app2-ejb">
                                  <remote-destination host="my.dev.machine" port="8080"/>
                              </outbound-socket-binding>
                              
                              
                              
                              
                              

                               

                              In my client application (APP1) I added the following code to jboss-ejb-client.xml

                               

                              <?xml version='1.0' encoding='UTF-8'?>
                              <jboss-ejb-client xmlns="urn:jboss:ejb-client:1.2"
                                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                xsi:noNamespaceSchemaLocation="jboss-ejb-client_1_2.xsd">
                                <client-context>
                                <ejb-receivers>
                                    <remoting-ejb-receiver outbound-connection-ref="remote-app2-ejb-connection" />
                                </ejb-receivers>
                                </client-context>
                              </jboss-ejb-client>
                              
                              
                              
                              

                               

                              In order to get the classes exposed via java:jboss/exported/ I use the following code

                               

                              final Hashtable jndiProperties = new Hashtable();
                              jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
                              jndiProperties.put("jboss.naming.client.ejb.context", true);
                              Context context = new InitialContext(jndiProperties);
                              MyClassRemote mcr = (MyClassRemote) context.lookup("ejb:app2-ear/app2-ejb//MyClass!com.mydev.app2.MyClassRemote");
                              
                              
                              
                              

                               

                              And I'm able to run the methods on APP2. Also, if I change my.dev.machine to the real hostname of the remote machine, it works just as well.

                               

                              But that was all clear and understandable, as it's configured statically. Now, let's move on to the second part.

                               

                              At first, I didn't change any configurations and went with this code:

                              Properties jndiProps = new Properties();
                              jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
                              jndiProps.put(Context.PROVIDER_URL, "http-remoting://my.remote.machine:8080");
                              jndiProps.put(Context.SECURITY_PRINCIPAL, "myremoteuser");
                              jndiProps.put(Context.SECURITY_CREDENTIALS, myRemotePassword64);
                              Context ctx = new InitialContext(jndiProps);
                              MyClassRemote mcr = (MyClassRemote) context.lookup("app2-ear/app2-ejb//MyClass!com.mydev.app2.MyClassRemote");
                              
                              
                              
                              

                               

                              Remember, that I'm running this on my.dev.machine. To my surprise, this worked and I was able to call methods from MyClassRemote. However, upon further investigation, it turned out that I was still using the MyClassRemote instance provided by APP2 on my.dev.machine and not on my.remote.machine. However, if my.remote.machine was down or I got an exception:

                               

                              2015-10-15 14:33:04,520 ERROR [stderr] (EJB default - 3) javax.naming.CommunicationException: Failed to connect to any server. Servers tried: [http-remoting://my.remote.machine:8080 (Operation failed with status WAITING after 5000 MILLISECONDS)] [Root exception is java.net.ConnectException: Operation failed with status WAITING after 5000 MILLISECONDS]
                              2015-10-15 14:33:04,520 ERROR [stderr] (EJB default - 3)        at org.jboss.naming.remote.client.HaRemoteNamingStore.failOverSequence(HaRemoteNamingStore.java:240)
                              2015-10-15 14:33:04,520 ERROR [stderr] (EJB default - 3)        at org.jboss.naming.remote.client.HaRemoteNamingStore.namingStore(HaRemoteNamingStore.java:149)
                              2015-10-15 14:33:04,520 ERROR [stderr] (EJB default - 3)        at org.jboss.naming.remote.client.HaRemoteNamingStore.namingOperation(HaRemoteNamingStore.java:130)
                              2015-10-15 14:33:04,520 ERROR [stderr] (EJB default - 3)        at org.jboss.naming.remote.client.HaRemoteNamingStore.lookup(HaRemoteNamingStore.java:272)
                              2015-10-15 14:33:04,520 ERROR [stderr] (EJB default - 3)        at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:87)
                              2015-10-15 14:33:04,520 ERROR [stderr] (EJB default - 3)        at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:129)
                              2015-10-15 14:33:04,521 ERROR [stderr] (EJB default - 3)        at javax.naming.InitialContext.lookup(InitialContext.java:411)
                              2015-10-15 14:33:04,521 ERROR [stderr] (EJB default - 3)        at javax.naming.InitialContext.lookup(InitialContext.java:411)
                              
                              
                              

                               

                              or

                               

                              2015-10-15 13:25:00,288 ERROR [stderr] (EJB default - 1) javax.naming.CommunicationException: Failed to connect to any server. Servers tried: [http-remoting://my.remote.machine:8080 (java.net.ConnectException: Connection refused)]
                              2015-10-15 13:25:00,289 ERROR [stderr] (EJB default - 1)        at org.jboss.naming.remote.client.HaRemoteNamingStore.failOverSequence(HaRemoteNamingStore.java:244)
                              2015-10-15 13:25:00,289 ERROR [stderr] (EJB default - 1)        at org.jboss.naming.remote.client.HaRemoteNamingStore.namingStore(HaRemoteNamingStore.java:149)
                              2015-10-15 13:25:00,289 ERROR [stderr] (EJB default - 1)        at org.jboss.naming.remote.client.HaRemoteNamingStore.namingOperation(HaRemoteNamingStore.java:130)
                              2015-10-15 13:25:00,289 ERROR [stderr] (EJB default - 1)        at org.jboss.naming.remote.client.HaRemoteNamingStore.lookup(HaRemoteNamingStore.java:272)
                              2015-10-15 13:25:00,289 ERROR [stderr] (EJB default - 1)        at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:87)
                              2015-10-15 13:25:00,289 ERROR [stderr] (EJB default - 1)        at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:129)
                              2015-10-15 13:25:00,289 ERROR [stderr] (EJB default - 1)        at javax.naming.InitialContext.lookup(InitialContext.java:411)
                              2015-10-15 13:25:00,289 ERROR [stderr] (EJB default - 1)        at javax.naming.InitialContext.lookup(InitialContext.java:411)
                              
                              
                              

                               

                              Only when the machine and APP2 were running, the context looked the remote class up and returned an instance of it (from the WRONG machine). This is very confusing, as it suggests that the connection is done to the correct destination, but some magic happens afterwards.

                               

                              The next test was to remove the remote-app2-ejb-connection definition from jboss-ejb-client.xml. I also added an additional property to the Context:

                               

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

                               

                              This leads to the following behavior:

                               

                              18:56:42,880 WARN  [InitialContextFactory] EJB client integration will not be available due to a problem setting up the client context
                              java.lang.reflect.InvocationTargetException
                                      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                                      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
                                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                                      at java.lang.reflect.Method.invoke(Method.java:606)
                                      at org.jboss.naming.remote.client.InitialContextFactory.setupEJBClientContext(InitialContextFactory.java:449)
                                      at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:142)
                                      at org.jboss.as.naming.InitialContext.getDefaultInitCtx(InitialContext.java:114)
                                      at org.jboss.as.naming.InitialContext.init(InitialContext.java:99)
                                      at javax.naming.ldap.InitialLdapContext.<init>(InitialLdapContext.java:153)
                                      at org.jboss.as.naming.InitialContext.<init>(InitialContext.java:90)
                                      at org.jboss.as.naming.InitialContextFactory.getInitialContext(InitialContextFactory.java:44)
                                      at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684)
                                      at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307)
                                      at javax.naming.InitialContext.init(InitialContext.java:242)
                                      at javax.naming.InitialContext.<init>(InitialContext.java:216)
                                      at com.myapp1.model.RemoteWildflyEjb.getRemoteInstance(RemoteWildflyEjb.java:196)
                                      at com.myapp1.logic.RemoteWildflyEjbLogic.getMomentManagerRemote(RemoteWildflyEjbLogic.java:129)
                                      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                                      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
                                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                                      at java.lang.reflect.Method.invoke(Method.java:606)
                                      at org.jboss.as.ee.component.ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptor.java:52)
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)
                                      at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:63)
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:407)
                                      at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:82)
                                      at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:93)
                                      at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:63)
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)
                                      at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:63)
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.as.ejb3.component.invocationmetrics.ExecutionTimeInterceptor.processInvocation(ExecutionTimeInterceptor.java:43)
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47)
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:407)
                                      at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:46)
                                      at org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:83)
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.as.ee.concurrent.ConcurrentContextInterceptor.processInvocation(ConcurrentContextInterceptor.java:45)
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21)
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
                                      at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53)
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.as.ejb3.component.interceptors.NonPooledEJBComponentInstanceAssociatingInterceptor.processInvocation(NonPooledEJBComponentInstanceAssociatingInterceptor.java:59)
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:273)
                                      at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:340)
                                      at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:239)
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.as.ejb3.component.invocationmetrics.WaitTimeInterceptor.processInvocation(WaitTimeInterceptor.java:43)
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.as.ejb3.security.SecurityContextInterceptor.processInvocation(SecurityContextInterceptor.java:95)
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.as.ejb3.component.interceptors.ShutDownInterceptorFactory$1.processInvocation(ShutDownInterceptorFactory.java:64)
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59)
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:55)
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:64)
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:326)
                                      at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:448)
                                      at org.jboss.invocation.AccessCheckingInterceptor.processInvocation(AccessCheckingInterceptor.java:61)
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:326)
                                      at org.jboss.invocation.PrivilegedWithCombinerInterceptor.processInvocation(PrivilegedWithCombinerInterceptor.java:80)
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
                                      at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:185)
                                      at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:182)
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
                                      at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:73)
                                      at com.myapp1.logic.RemoteWildflyEjbLogic$$$view596.getMomentManagerRemote(Unknown Source)
                                      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                                      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
                                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                                      at java.lang.reflect.Method.invoke(Method.java:606)
                                      at org.jboss.weld.util.reflection.Reflections.invokeAndUnwrap(Reflections.java:414)
                                      at org.jboss.weld.bean.proxy.EnterpriseBeanProxyMethodHandler.invoke(EnterpriseBeanProxyMethodHandler.java:127)
                                      at org.jboss.weld.bean.proxy.EnterpriseTargetBeanInstance.invoke(EnterpriseTargetBeanInstance.java:56)
                                      at org.jboss.weld.bean.proxy.InjectionPointPropagatingEnterpriseTargetBeanInstance.invoke(InjectionPointPropagatingEnterpriseTargetBeanInstance.java:65)
                                      at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:100)
                                      at com.myapp1.logic.RemoteWildflyEjbLogic$Proxy$_$$_Weld$EnterpriseProxy$.getMomentManagerRemote(Unknown Source)
                                      at com.myapp1.web.rest.RESTTest.test(RESTTest.java:157)
                                      at com.myapp1.web.rest.RESTTest$Proxy$_$$_WeldClientProxy.test(Unknown Source)
                                      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                                      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
                                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                                      at java.lang.reflect.Method.invoke(Method.java:606)
                                      at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:137)
                                      at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:296)
                                      at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:250)
                                      at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:237)
                                      at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:356)
                                      at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:179)
                                      at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:220)
                                      at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
                                      at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
                                      at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
                                      at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
                                      at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61)
                                      at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
                                      at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
                                      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
                                      at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
                                      at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:56)
                                      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
                                      at io.undertow.security.handlers.AuthenticationConstraintHandler.handleRequest(AuthenticationConstraintHandler.java:51)
                                      at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45)
                                      at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:63)
                                      at io.undertow.servlet.handlers.security.ServletSecurityConstraintHandler.handleRequest(ServletSecurityConstraintHandler.java:56)
                                      at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58)
                                      at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70)
                                      at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76)
                                      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
                                      at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
                                      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
                                      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
                                      at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:261)
                                      at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:247)
                                      at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:76)
                                      at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:166)
                                      at io.undertow.server.Connectors.executeRootHandler(Connectors.java:197)
                                      at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:765)
                                      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
                                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
                                      at java.lang.Thread.run(Thread.java:745)
                              Caused by: java.lang.IllegalStateException: EJBCLIENT000405: An EJB client context is already registered for EJB client context identifier [Named EJB client context identifier: RemoteNamingEJBClientContext$2]
                                      at org.jboss.as.ejb3.remote.TCCLEJBClientContextSelectorService.registerContext(TCCLEJBClientContextSelectorService.java:107)
                                      at org.jboss.as.ejb3.remote.DefaultEJBClientContextSelector.registerContext(DefaultEJBClientContextSelector.java:91)
                                      at org.jboss.naming.remote.client.ejb.RemoteNamingStoreEJBClientHandler.registerEJBClientContextWithSelector(RemoteNamingStoreEJBClientHandler.java:103)
                                      at org.jboss.naming.remote.client.ejb.RemoteNamingStoreEJBClientHandler.setupEJBClientContext(RemoteNamingStoreEJBClientHandler.java:63)
                                      ... 139 more
                              18:56:42,881 DEBUG [InitialContextFactory] Looking for jboss-naming-client.properties using classloader ModuleClassLoader for Module "deployment.app1-ear.ear.app1-ejb.jar:main" from Service Module Loader
                              18:56:42,882 DEBUG [InitialContextFactory] jboss.naming.client.endpoint.create.options. has the following options {}
                              18:56:42,882 DEBUG [InitialContextFactory] jboss.naming.client.remote.connectionprovider.create.options. has the following options {}
                              18:56:42,882 DEBUG [InitialContextFactory] jboss.naming.client.connect.options. has the following options {}
                              
                              

                               

                              And I still got the object from my.dev.machine!

                               

                              Then, I restarted Wildfly on my.dev.machine and tried again with the same code. Result:

                               

                              18:59:20,783 DEBUG [InitialContextFactory] Looking for jboss-naming-client.properties using classloader ModuleClassLoader for Module "deployment.app1-ear.ear.app1-ejb.jar:main" from Service Module Loader
                              18:59:20,785 DEBUG [InitialContextFactory] jboss.naming.client.endpoint.create.options. has the following options {}
                              18:59:20,785 DEBUG [InitialContextFactory] jboss.naming.client.remote.connectionprovider.create.options. has the following options {}
                              18:59:20,793 INFO  [xnio] XNIO version 3.3.0.Final
                              18:59:20,799 INFO  [nio] XNIO NIO Implementation Version 3.3.0.Final
                              18:59:20,813 DEBUG [nio] Started channel thread 'Remoting "config-based-naming-client-endpoint" I/O-1', selector sun.nio.ch.EPollSelectorImpl@27b33463
                              18:59:20,817 INFO  [remoting] JBoss Remoting version 4.0.6.Final
                              18:59:20,824 DEBUG [InitialContextFactory] jboss.naming.client.connect.options. has the following options {}
                              18:59:21,049 DEBUG [client] Client authentication failed for mechanism JBOSS-LOCAL-USER: javax.security.sasl.SaslException: Failed to read server challenge [Caused by java.io.FileNotFoundException: /opt/wildfly/standalone/tmp/auth/local19540738999933335.challenge (No such file or directory)]
                              18:59:27,700 DEBUG [PoolingClientConnectionManager] Connection manager is shutting down
                              
                              

                               

                              2015-10-16 18:59:21,259 ERROR [io.undertow.request] (default task-5) UT005023: Exception handling request to /app1-web/rest/test/test/remote: org.jboss.resteasy.spi.UnhandledException: javax.ejb.EJBException: JBAS014580: Unexpected Error
                                      at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:76) [resteasy-jaxrs-3.0.10.Final.jar:]
                                      at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:212) [resteasy-jaxrs-3.0.10.Final.jar:]
                                      at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:149) [resteasy-jaxrs-3.0.10.Final.jar:]
                                      at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:372) [resteasy-jaxrs-3.0.10.Final.jar:]
                                      at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:179) [resteasy-jaxrs-3.0.10.Final.jar:]
                                      at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:220) [resteasy-jaxrs-3.0.10.Final.jar:]
                                      at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56) [resteasy-jaxrs-3.0.10.Final.jar:]
                                      at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51) [resteasy-jaxrs-3.0.10.Final.jar:]
                                      at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) [jboss-servlet-api_3.1_spec-1.0.0.Final.jar:1.0.0.Final]
                                      at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85) [undertow-servlet-1.1.3.Final.jar:1.1.3.Final]
                                      at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61) [undertow-servlet-1.1.3.Final.jar:1.1.3.Final]
                                      at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) [undertow-servlet-1.1.3.Final.jar:1.1.3.Final]
                                      at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
                                      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.3.Final.jar:1.1.3.Final]
                                      at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131) [undertow-servlet-1.1.3.Final.jar:1.1.3.Final]
                                      at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:56) [undertow-servlet-1.1.3.Final.jar:1.1.3.Final]
                                      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.3.Final.jar:1.1.3.Final]
                                      at io.undertow.security.handlers.AuthenticationConstraintHandler.handleRequest(AuthenticationConstraintHandler.java:51) [undertow-core-1.1.3.Final.jar:1.1.3.Final]
                                      at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45) [undertow-core-1.1.3.Final.jar:1.1.3.Final]
                                      at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:63) [undertow-servlet-1.1.3.Final.jar:1.1.3.Final]
                                      at io.undertow.servlet.handlers.security.ServletSecurityConstraintHandler.handleRequest(ServletSecurityConstraintHandler.java:56) [undertow-servlet-1.1.3.Final.jar:1.1.3.Final]
                                      at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58) [undertow-core-1.1.3.Final.jar:1.1.3.Final]
                                      at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70) [undertow-servlet-1.1.3.Final.jar:1.1.3.Final]
                                      at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76) [undertow-core-1.1.3.Final.jar:1.1.3.Final]
                                      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.3.Final.jar:1.1.3.Final]
                                      at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
                                      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.3.Final.jar:1.1.3.Final]
                                      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.3.Final.jar:1.1.3.Final]
                                      at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:261) [undertow-servlet-1.1.3.Final.jar:1.1.3.Final]
                                      at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:247) [undertow-servlet-1.1.3.Final.jar:1.1.3.Final]
                                      at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:76) [undertow-servlet-1.1.3.Final.jar:1.1.3.Final]
                                      at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:166) [undertow-servlet-1.1.3.Final.jar:1.1.3.Final]
                                      at io.undertow.server.Connectors.executeRootHandler(Connectors.java:197) [undertow-core-1.1.3.Final.jar:1.1.3.Final]
                                      at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:765) [undertow-core-1.1.3.Final.jar:1.1.3.Final]
                                      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_80]
                                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_80]
                                      at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_80]
                              Caused by: javax.ejb.EJBException: JBAS014580: Unexpected Error
                                      at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:187) [wildfly-ejb3-8.2.0.Final.jar:8.2.0.Final]
                                      at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:275) [wildfly-ejb3-8.2.0.Final.jar:8.2.0.Final]
                                      at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:340) [wildfly-ejb3-8.2.0.Final.jar:8.2.0.Final]
                                      at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:239) [wildfly-ejb3-8.2.0.Final.jar:8.2.0.Final]
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) [wildfly-ejb3-8.2.0.Final.jar:8.2.0.Final]
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.as.ejb3.component.invocationmetrics.WaitTimeInterceptor.processInvocation(WaitTimeInterceptor.java:43) [wildfly-ejb3-8.2.0.Final.jar:8.2.0.Final]
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.as.ejb3.security.SecurityContextInterceptor.processInvocation(SecurityContextInterceptor.java:95) [wildfly-ejb3-8.2.0.Final.jar:8.2.0.Final]
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.as.ejb3.component.interceptors.ShutDownInterceptorFactory$1.processInvocation(ShutDownInterceptorFactory.java:64) [wildfly-ejb3-8.2.0.Final.jar:8.2.0.Final]
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59) [wildfly-ejb3-8.2.0.Final.jar:8.2.0.Final]
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:55) [wildfly-ejb3-8.2.0.Final.jar:8.2.0.Final]
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:64)
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:326)
                                      at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:448)
                                      at org.jboss.invocation.AccessCheckingInterceptor.processInvocation(AccessCheckingInterceptor.java:61)
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:326)
                                      at org.jboss.invocation.PrivilegedWithCombinerInterceptor.processInvocation(PrivilegedWithCombinerInterceptor.java:80)
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
                                      at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:185)
                                      at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:182)
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
                                      at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:73)
                                      at app1.logic.RemoteWildflyEjbLogic$$$view65.getMomentManagerRemote(Unknown Source) [app1-ejb.jar:]
                                      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_80]
                                      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_80]
                                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_80]
                                      at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_80]
                                      at org.jboss.weld.util.reflection.Reflections.invokeAndUnwrap(Reflections.java:414) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]
                                      at org.jboss.weld.bean.proxy.EnterpriseBeanProxyMethodHandler.invoke(EnterpriseBeanProxyMethodHandler.java:127) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]
                                      at org.jboss.weld.bean.proxy.EnterpriseTargetBeanInstance.invoke(EnterpriseTargetBeanInstance.java:56) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]
                                      at org.jboss.weld.bean.proxy.InjectionPointPropagatingEnterpriseTargetBeanInstance.invoke(InjectionPointPropagatingEnterpriseTargetBeanInstance.java:65) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]
                                      at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:100) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]
                                      at app1.logic.RemoteWildflyEjbLogic$Proxy$_$$_Weld$EnterpriseProxy$.getMomentManagerRemote(Unknown Source) [app1-ejb.jar:]
                                      at app1.web.rest.RESTTest.test(RESTTest.java:157) [classes:]
                                      at app1.web.rest.RESTTest$Proxy$_$$_WeldClientProxy.test(Unknown Source) [classes:]
                                      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_80]
                                      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_80]
                                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_80]
                                      at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_80]
                                      at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:137) [resteasy-jaxrs-3.0.10.Final.jar:]
                                      at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:296) [resteasy-jaxrs-3.0.10.Final.jar:]
                                      at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:250) [resteasy-jaxrs-3.0.10.Final.jar:]
                                      at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:237) [resteasy-jaxrs-3.0.10.Final.jar:]
                                      at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:356) [resteasy-jaxrs-3.0.10.Final.jar:]
                                      ... 33 more
                              Caused by: java.lang.LinkageError: loader constraint violation: when resolving method "org.jboss.ejb.client.EJBClientContext.registerConnection(Lorg/jboss/remoting3/Connection;)V" the class loader (instance of org/jboss/modules/ModuleClassLoader) of the current class, org/jboss/naming/remote/client/ejb/RemoteNamingStoreEJBClientHandler, and the class loader (instance of org/jboss/modules/ModuleClassLoader) for resolved class, org/jboss/ejb/client/EJBClientContext, have different Class objects for the type oss/remoting3/Connection;)V used in the signature
                                      at org.jboss.naming.remote.client.ejb.RemoteNamingStoreEJBClientHandler.associate(RemoteNamingStoreEJBClientHandler.java:78) [jboss-remote-naming.jar:2.0.1.Final]
                                      at org.jboss.naming.remote.protocol.v1.RemoteNamingStoreV1.<init>(RemoteNamingStoreV1.java:71) [jboss-remote-naming.jar:2.0.1.Final]
                                      at org.jboss.naming.remote.protocol.v1.VersionOne.getRemoteNamingStore(VersionOne.java:50) [jboss-remote-naming.jar:2.0.1.Final]
                                      at org.jboss.naming.remote.protocol.Versions.getRemoteNamingStore(Versions.java:55) [jboss-remote-naming.jar:2.0.1.Final]
                                      at org.jboss.naming.remote.client.RemoteContextFactory.createVersionedStore(RemoteContextFactory.java:73) [jboss-remote-naming.jar:2.0.1.Final]
                                      at org.jboss.naming.remote.client.HaRemoteNamingStore.failOverSequence(HaRemoteNamingStore.java:202) [jboss-remote-naming.jar:2.0.1.Final]
                                      at org.jboss.naming.remote.client.HaRemoteNamingStore.namingStore(HaRemoteNamingStore.java:149) [jboss-remote-naming.jar:2.0.1.Final]
                                      at org.jboss.naming.remote.client.HaRemoteNamingStore.namingOperation(HaRemoteNamingStore.java:130) [jboss-remote-naming.jar:2.0.1.Final]
                                      at org.jboss.naming.remote.client.HaRemoteNamingStore.lookup(HaRemoteNamingStore.java:272) [jboss-remote-naming.jar:2.0.1.Final]
                                      at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:87) [jboss-remote-naming.jar:2.0.1.Final]
                                      at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:129) [jboss-remote-naming.jar:2.0.1.Final]
                                      at javax.naming.InitialContext.lookup(InitialContext.java:411) [rt.jar:1.7.0_80]
                                      at javax.naming.InitialContext.lookup(InitialContext.java:411) [rt.jar:1.7.0_80]
                                      at app1.model.RemoteWildflyEjb.getRemoteInstance(RemoteWildflyEjb.java:197) [app1-ejb.jar:]
                                      at app1.logic.RemoteWildflyEjbLogic.getMomentManagerRemote(RemoteWildflyEjbLogic.java:129) [app1-ejb.jar:]
                                      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_80]
                                      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_80]
                                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_80]
                                      at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_80]
                                      at org.jboss.as.ee.component.ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptor.java:52)
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)
                                      at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:63)
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:407)
                                      at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:82) [wildfly-weld-8.2.0.Final.jar:8.2.0.Final]
                                      at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:93) [wildfly-weld-8.2.0.Final.jar:8.2.0.Final]
                                      at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:63)
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)
                                      at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:63)
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.as.ejb3.component.invocationmetrics.ExecutionTimeInterceptor.processInvocation(ExecutionTimeInterceptor.java:43) [wildfly-ejb3-8.2.0.Final.jar:8.2.0.Final]
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47) [wildfly-jpa-8.2.0.Final.jar:8.2.0.Final]
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:407)
                                      at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:46) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]
                                      at org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:83) [wildfly-weld-8.2.0.Final.jar:8.2.0.Final]
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.as.ee.concurrent.ConcurrentContextInterceptor.processInvocation(ConcurrentContextInterceptor.java:45) [wildfly-ee-8.2.0.Final.jar:8.2.0.Final]
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21)
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
                                      at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53)
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.as.ejb3.component.interceptors.NonPooledEJBComponentInstanceAssociatingInterceptor.processInvocation(NonPooledEJBComponentInstanceAssociatingInterceptor.java:59) [wildfly-ejb3-8.2.0.Final.jar:8.2.0.Final]
                                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
                                      at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:273) [wildfly-ejb3-8.2.0.Final.jar:8.2.0.Final]
                                      ... 87 more
                              
                              

                               

                              There are two things that look fishy:

                               

                              18:59:21,049 DEBUG [client] Client authentication failed for mechanism JBOSS-LOCAL-USER: javax.security.sasl.SaslException: Failed to read server challenge [Caused by java.io.FileNotFoundException: /opt/wildfly/standalone/tmp/auth/local19540738999933335.challenge (No such file or directory)]
                              
                              

                               

                              and

                               

                              Caused by: java.lang.LinkageError: loader constraint violation: when resolving method "org.jboss.ejb.client.EJBClientContext.registerConnection(Lorg/jboss/remoting3/Connection;)V" the class loader (instance of org/jboss/modules/ModuleClassLoader) of the current class, org/jboss/naming/remote/client/ejb/RemoteNamingStoreEJBClientHandler, and the class loader (instance of org/jboss/modules/ModuleClassLoader) for resolved class, org/jboss/ejb/client/EJBClientContext, have different Class objects for the type oss/remoting3/Connection;)V used in the signature
                              
                              

                               

                              I don't understand the first message. The second one suggests that there is a library version conflict. I looked into my ear file and, indeed, the remoting .jars are included in my application. I understand this should not be the case and the libraries in the Wildfly modules should be used, right? However, I'm not adding the dependencies myself. They are somewhere in one of the wildfly boms I'm including. Would it help if I either changed the version of the bom or excluded the jars from being loaded?

                               

                              Edit: I figured out that the only place the libraries find their way into my project is through the wildfly maven plugin but I don't know hot to exclude them or mark them as 'provided'.

                              • 12. Re: Remote EJB Look up in Wildfly 8.2.Final
                                tomekadamski Novice

                                jboss-remote-naming is not meant to be used inside application server. All the errors that you encounter dervive from this incompability.

                                 

                                Error 1:

                                 

                                2015-10-15 14:33:04,520 ERROR [stderr] (EJB default - 3) javax.naming.CommunicationException: Failed to connect to any server. Servers tried: [http remoting://my.remote.machine:8080 (Operation failed with status WAITING after 5000 MILLISECONDS)] [Root exception is java.net.ConnectException: Operation failed with status WAITING after 5000 MILLISECONDS] 

                                + invocation from the wrong machine if server is up


                                Inside application server you have application context automatically created for you. It contains local proxy by default. During invocation remote-naming library uses current EJBClientContext to recreate the proxy if returned object is EJBBean - hence unexpected behaviour.

                                 

                                Error 2:

                                1. Caused by: java.lang.IllegalStateException: EJBCLIENT000405: An EJB client context is already registered for EJB client context identifier [Named EJB client context identifier: RemoteNamingEJBClientContext$2] 

                                 

                                As I said before - default proxy is created automatically - you are not allowed to create another one - this options is again not meant to be used inside application server.


                                Error 3:

                                Caused by: java.lang.LinkageError: loader constraint violation: when resolving method "org.jboss.ejb.client.EJBClientContext.registerConnection(Lorg/jboss/remoting3/Connection;)V" the class loader (instance of org/jboss/modules/ModuleClassLoader) of the current class, org/jboss/naming/remote/client/ejb/RemoteNamingStoreEJBClientHandler, and the class loader (instance of org/jboss/modules/ModuleClassLoader) for resolved class, org/jboss/ejb/client/EJBClientContext, have different Class objects for the type oss/remoting3/Connection;)V used in the signature 
                                
                                

                                You probably have remote-naming library and it's dependencies in your application classpath - Connection class included - hence the error.

                                 

                                You should use ejb-client-context.xml/remoting subsystem configuration to configure connections inside the server, but it is static at present.

                                • 13. Re: Remote EJB Look up in Wildfly 8.2.Final
                                  Pawel Predki Newbie

                                  Thanks for clearing that up a little bit. I'm still confused then why a connection is being made to the remote location and what I could do with it. Or should I simply not be allowed to do it and the code looks like a hack that simply isn't going to work? Anyway, this means that the only option to be able to talk to other servers dynamically is to switch to some other mechanism.

                                   

                                  EDIT: I have one more question, though. If I had a pool of remote ejb connections defined in my standalone.xml file, each pointing to a different server, would it be possible to programmatically select which one to use? Or would the first available connection be used?

                                  • 14. Re: Remote EJB Look up in Wildfly 8.2.Final
                                    tomekadamski Novice

                                    The library is not meant to be used with in server context hence the unexpected behaviour.

                                     

                                    Regarding second question:

                                    You can implement your org.jboss.ejb.client.DeploymentNodeSelector and refer to it from jboss-ejb-client.xml like this:

                                     

                                    <client-context deployment-node-selector="your.selector.class" (...)>
                                    

                                     

                                    Please note that this API is deprecated though.

                                    1 2 Previous Next