Skip to main content
JoshuaSharf
Participant
June 15, 2018
Question

Connecting to Java JBoss Objects in EAP7 from CF Server 2016

  • June 15, 2018
  • 1 reply
  • 697 views

e're trying to run the CF 2016 server alongside a Java Middle Tier running in a JBoss EAP 7 Standalone server.  I'm copying over the .ear file and the appropriate client .jar files, but when we actually go to lookup the jndiName on the InitialContext, the server fails.  Neither the ColdFusion log nor the Middle Tier server.log show any errors.  We have already shown that we can hit the Middle Tier from a test connection tool running in Eclipse.

Has anyone else encountered this problem, and/or is there some CF Server setting that might be wrong?

Below are the settings for the InitialContext and the method to get the InitialContext.  The bolded line is what fails.

Joshua Sharf

 

@SuppressWarnings("unchecked")
public <T> T getRemote(Class<T> remote, String jndiName) {
InitialContext initialContext = null;
T remoteReturned = null;
try {
initialContext = getInitialContext();
remoteReturned = (T)initialContext.lookup(jndiName);
} catch (Exception e) {
_logger.error("name:" + e.getClass().getSigners() + "\t message:" + e.getMessage() + "\t cause:" + e.getCause());
_logger.error(" Could not look up jndiName " + jndiName, e);
}
return remoteReturned;
}

public static InitialContext getInitialContext() throws SystemException {
try {
final Hashtable env = new Hashtable();
env.put(InitialContext.URL_PKG_PREFIXES, "org.wildfly.naming.client");
              env.put(InitialContext.INITIAL_CONTEXT_FACTORY, "org.wildfly.naming.client.WildFlyInitialContextFactory");
   env.put(InitialContext.PROVIDER_URL, "http-remoting://127.0.0.1:8080");
env.put("org.wildfly.naming.client", true);
return new InitialContext(env);
} catch (Exception e) {
_logger.error("Error in getInitialContext:",e);
throw new SystemException(RemoteServiceLocator.buildClientExceptionContent("RemoteServiceLocator.getIntitialContext()",
"System Exception attempting to get Initial Context.\n"));
}
}

    This topic has been closed for replies.

    1 reply

    BKBK
    Community Expert
    Community Expert
    June 17, 2018

    Some questions:

    1) What are you passing as the value of

    Class<T> remote

    2)  Shouldn't you delete this line:

    env.put("org.wildfly.naming.client", true);

    3) Is the value of jndiName that you are passing to lookUp() a correct JNDI name for the type T that you are passing?

    JoshuaSharf
    Participant
    June 17, 2018

    1) A java class, of the type we're trying to connect to.  For instance QuoteSbRemote.class

    2) It didn't work with or without it.  We'll take it back out, but it's not what's causing the problem

    3) Yes, we've dumped that a few times to make sure we're passing the correct name

    BKBK
    Community Expert
    Community Expert
    June 18, 2018

    Thanks for the answers.

    Some suggestions.

    1) Your first _logger.error() call has just 1 argument. Is that intentional?

    2) You could add the following catch to getRemote() to get more information

            catch (NamingException ne) {

                _logger.error("Cannot get {0} with jndiName {1}", ne);

                return null;

            }