4 Replies Latest reply on Oct 22, 2013 1:47 PM by wdfink

    remote-naming project for ejb invocation failing to connect to remote host after all configuration is proper

    ravipatil080

      Hi all,

      I am using jboss7.2.0.Final and I have deployed myapp.ear file and its running

       

       

      I have an ejb (stateless) in the service and it is exposed as

      java:jboss/myapp/mymodule/HiEjb!com.mycompany.api.HiInterfaceRemote

       

       

      And My look up configuration is like

           Properties jndiProps = new Properties();

           jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");

           jndiProps.put(Context.PROVIDER_URL,"remote://localhost:4447");

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

           Context ctx = new InitialContext(jndiProps);     

           ejb =  (HiInterfaceRemote) ctx.lookup("myapp/mymodule/HiEjb!com.mycompany.api.HiInterfaceRemote");

          

        

       

       

       

       

      And I have following jars in the classpath

       

       

      jboss-remote-naming-1.0.5.Final.jar

      xnio-nio-3.0.7.GA.jar

      jboss-ejb-api_3.1_spec-1.0.1.Final.jar

      jboss-ejb-client-1.0.0.Beta11.jar

      jboss-logging-3.1.0.CR2.jar

      jboss-marshalling-1.3.4.GA.jar

      jboss-marshalling-river-1.3.4.GA.jar

      jboss-remoting-3.2.0.CR8.jar

      jboss-sasl-1.0.0.Beta9.jar

      jboss-transaction-api_1.1_spec-1.0.0.Final.jar

      xnio-api-3.0.0.CR7.jar

       

       

      But still I am getting error like

       

       

              at javax.swing.KeyboardManager.fireKeyboardAction(Unknown Source)

              at javax.swing.JComponent.processKeyBindingsForAllComponents(Unknown Source)

              at javax.swing.JComponent.processKeyBindings(Unknown Source)

              at javax.swing.JComponent.processKeyEvent(Unknown Source)

              at java.awt.Component.processEvent(Unknown Source)

              at java.awt.Container.processEvent(Unknown Source)

              at java.awt.Component.dispatchEventImpl(Unknown Source)

              at java.awt.Container.dispatchEventImpl(Unknown Source)

              at java.awt.Component.dispatchEvent(Unknown Source)

              at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)

              at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)

              at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source)

              at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)

              at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)

              at java.awt.Component.dispatchEventImpl(Unknown Source)

              at java.awt.Container.dispatchEventImpl(Unknown Source)

              at java.awt.Window.dispatchEventImpl(Unknown Source)

              at java.awt.Component.dispatchEvent(Unknown Source)

              at java.awt.EventQueue.dispatchEvent(Unknown Source)

              at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)

              at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)

              at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)

              at java.awt.Dialog$1.run(Unknown Source)

              at java.awt.event.InvocationEvent.dispatch(Unknown Source)

              at java.awt.EventQueue.dispatchEvent(Unknown Source)

              at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)

              at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)

              at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

              at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

              at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

              at java.awt.EventDispatchThread.run(Unknown Source)

      Caused by: javax.naming.NamingException: Failed to connect to any server. Servers tried: [remote://localhost:4447]

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

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

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

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

              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(Unknown Source)

       

       

       

       

      I have gone through the documents also and I have implemented in the same way. The links are

       

       

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

       

      https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+client+using+JNDI

       

       

      Am I still missing anything? Please share your points...

      Thanks,

      Ravi

        • 1. Re: remote-naming project for ejb invocation failing to connect to remote host after all configuration is proper
          wdfink

          Do you have add an application user? you should add the credentials as described in the first link. The remote-naming need to have a pswd if the security is enabled for remoting

          • 2. Re: remote-naming project for ejb invocation failing to connect to remote host after all configuration is proper
            ihatetoregister

            As Wolf-Deiter Fink pointed out you need to add a user to the Jboss server . This i think was introduced in Jboss 7 . If you need a good example of  how to add the user to the server then follow this link http://middlewaremagic.com/jboss/?p=1466 .

             

            Client side will change to send username & password to user :

            .

             

              String JBOSS_CONTEXT="org.jboss.naming.remote.client.InitialContextFactory";;

              Properties props = new Properties();

              props.put(Context.INITIAL_CONTEXT_FACTORY, JBOSS_CONTEXT);

              props.put(Context.PROVIDER_URL, "remote://localhost:4447");

              props.put(Context.SECURITY_PRINCIPAL, "testuser");

              props.put(Context.SECURITY_CREDENTIALS, "testpassword");

              context = new InitialContext(props);

            .

             

            Server side will be configured to accept username & password :

             

            [userone@localhost bin]$ ./add-user.sh

             

            What type of user do you wish to add?

            a) Management User (mgmt-users.properties)

            b) Application User (application-users.properties)

            (a): b

             

            Enter the details of the new user to add.

            Realm (ApplicationRealm) :  ApplicationRealm

            Username : testuser

            Password : testpassword

            Re-enter Password : testpassword

             

            What roles do you want this user to belong to? (Please enter a comma separated list, or leave blank for none) : testrole

            About to add user 'testuser' for realm 'ApplicationRealm'

             

            Is this correct yes/no? yes

             

            Added user 'testuser' to file '/home/userone/jboss-as-7.1.0.Final/standalone/configuration/application-users.properties'

            Added user 'testuser' to file '/home/userone/jboss-as-7.1.0.Final/domain/configuration/application-users.properties'

            Added user 'testuser' with roles testrole to file '/home/userone/jboss-as-7.1.0.Final/standalone/configuration/application-roles.properties'

            Added user 'testuser' with roles testrole to file '/home/userone/jboss-as-7.1.0.Final/domain/configuration/application-roles.properties'

            .

            .

             

            I faced the same issue :-) I hope this helps and adds to what Wolf has told you to do .

            • 3. Re: remote-naming project for ejb invocation failing to connect to remote host after all configuration is proper
              ravipatil080

              I don't have any application user added in the Jboss server. So I am not passing principal and password. Do I need to have the application user in order to use remote-naming project? I dont think so.

              • 4. Re: remote-naming project for ejb invocation failing to connect to remote host after all configuration is proper
                wdfink

                If you did not change the default configuration the remoting connector is secured and you need to add an application use.

                Other option is to look into the remoting subsystem configuration and remote the security-realm, in that case the connection is not longer secured and you can connect without credentials.