0 Replies Latest reply on Jul 24, 2017 10:15 PM by George Berish

    Why Can't my Java Client Get Wildfly 8's Initial Context?

    George Berish Novice

      I can find several prior requests for help with how a Java Program (outside of Wildfly 8’s container) can secure an InitialContext from Wildfly 9 running on the same computer.

       

      But for reasons I don’t understand I can’t find an answer that makes the following test code work.

       

      So I hope someone is willing to tell what I'm doing wrong.

       

      The goal is a Class that enables JMS messaging. But for now I've cut out everything except getting an InitialContext.

       

      I run it on Eclipse so aside from the Build Path, it should be a cut, paste and run, example. I’m attaching all the jars in its build path (every jar every thread suggested). And I’ve pasted the relevant console error info at the end.

       

      I’d like to leave this code behind for those who start learning JBoss to just cut and paste as a start.

      Any Help?

       

      package org.america3.gotest.xtra;

      import java.util.Properties;

      import javax.naming.CommunicationException;

      import javax.naming.Context;

      import javax.naming.InitialContext;

       

      public class GetJNDIContext {

       

        //members

        static Properties ENV = new Properties() {

          private static final long serialVersionUID = 1L;

          {

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

            put(Context.PROVIDER_URL, "http-remoting://localhost:9990");

            put(Context.SECURITY_PRINCIPAL, "guest"); 

            put(Context.SECURITY_CREDENTIALS, "guest");

          }

        };

           

        static public void main (String[] args) {

          try {

            Context ctx = new InitialContext(GetJNDIContext.ENV);

          } catch (Exception e) {

            System.out.println(e.getClass().getName());

            System.out.println(e.getMessage());

            e.printStackTrace();

          }

        }

      }

       

      CONSOLE OUTPUT:

       

      javax.naming.NamingException

      Failed to create remoting connection

      javax.naming.NamingException: Failed to create remoting connection [Root exception is java.lang.NoSuchMethodError: org.jboss.remoting3.Remoting.createEndpoint(Ljava/lang/String;Lorg/xnio/OptionMap;)Lorg/jboss/remoting3/Endpoint;]

           at org.jboss.naming.remote.client.ClientUtil.namingException(ClientUtil.java:51)

           at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:151)

           ... more

       

      In cases it helps I get the same failure when I used the PW and ID of a user I created with

       

       

      As of 6/27/17

       

      jmsUser

      jmsPW123!

       

      Start in <wildfly> bin.

      Use add-user.bat

       

      Microsoft Windows [Version 10.0.15063]

      (c) 2017 Microsoft Corporation. All rights reserved.

       

      C:\ProgramFilesGeo\Wildfly\wildfly-10.1.0.Final\bin>add-user.bat

       

      What type of user do you wish to add?

      a) Management User (mgmt-users.properties)

      b) Application User (application-users.properties)

      (a): a

       

      Enter the details of the new user to add.

      Using realm 'ManagementRealm' as discovered from the existing property files.

       

      Username : jmsUser

       

      Password recommendations are listed below. To modify these restrictions edit the add-user.properties configuration file.

      - The password should be different from the username

      - The password should not be one of the following restricted values {root, admin, administrator}

      - The password should contain at least 8 characters, 1 alphabetic character(s), 1 digit(s), 1 non-alphanumeric symbol(s)

       

      Password : jmsPW123!

      Re-enter Password : jmsPW123!

       

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

       

      {I left it blank}

       

      About to add user 'jmsUser' for realm 'ManagementRealm'

       

      Is this correct yes/no? yes

       

      Added user 'jmsUser' to file 'C:\ProgramFilesGeo\Wildfly\wildfly-10.1.0.Final\standalone\configuration\mgmt-users.properties'

       

      Added user 'jmsUser' to file 'C:\ProgramFilesGeo\Wildfly\wildfly-10.1.0.Final\domain\configuration\mgmt-users.properties'

       

      Added user 'jmsUser' with groups to file 'C:\ProgramFilesGeo\Wildfly\wildfly-10.1.0.Final\standalone\configuration\mgmt-groups.properties'

      Added user 'jmsUser' with groups to file 'C:\ProgramFilesGeo\Wildfly\wildfly-10.1.0.Final\domain\configuration\mgmt-groups.properties'

       

      Is this new user going to be used for one AS process to connect to another AS process?

      1. e.g. for a slave host controller connecting to the master or for a Remoting connection for server to server EJB calls.

       

      yes/no? no

       

      Press any key to continue . . .