• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Connecting to Java JBoss Objects in EAP7 from CF Server 2016

New Here ,
Jun 15, 2018 Jun 15, 2018

Copy link to clipboard

Copied

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"));
}
}

Views

515

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 17, 2018 Jun 17, 2018

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 17, 2018 Jun 17, 2018

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 17, 2018 Jun 17, 2018

Copy link to clipboard

Copied

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;

        }

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 18, 2018 Jun 18, 2018

Copy link to clipboard

Copied

1) Doesn't matter.  We call _logger with one argument, and it doesn't cause a problem.

2) Also doesn't help.  That's higher level call, and as you can see, we already have a try-catch around the call to lookup().

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 18, 2018 Jun 18, 2018

Copy link to clipboard

Copied

OK. In my opinion, there are 3 main reasons why the lookup line would fail:

1. Invalid or missing JNDI name;

2. Incorrect InitialContext;

3. Wrong casting of the lookup.

As you're using try-catch, could you then share with us the error that is caught?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 18, 2018 Jun 18, 2018

Copy link to clipboard

Copied

Is it an idea to test the failing line with the default context? That is with:

InitialContext initialContext = new InitialContext();

remoteReturned = (T)initialContext.lookup(jndiName);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 18, 2018 Jun 18, 2018

Copy link to clipboard

Copied

LATEST

As I mentioned in the initial post, part of the problem here is that no error is being thrown on the lookup, nor is anything being written to the logs.  To all appearances, the request simply stops executing.

The InitialContext appears to be fine, on setting breakpoints and inspecting the object.  The values that you see being set in the Hashtable - prefixes, factory, and URL, are all in the object's hashtable.

And in this e, the remote class being passed in is the correct one.

public <T> T getRemote(Class<T> remote, String jndiName) {

The jndiName itself is also what we expect:

ejb:tms-2018.03.20-SNAPSHOT/accounting-2018.03.20-SNAPSHOT/LedgerAuthorizationSb!com.werner.accounting.bp.ledger.authorization.LedgerAuthorizationSbRemote

When we run this with the default InitialContext, we get a NameNotFoundException

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation