remote lookup issue in ejb3

290 views
Skip to first unread message

DILIP kumar

unread,
Aug 26, 2022, 11:50:37 AM8/26/22
to WildFly
Hi folks, 

Hope you are doing great !!!

We are using wildfly 21 and we are facing issue while lookup for ejb through remote client.

Our remote client is launched via  launcher which is launching independent java  process 

 Process process = Runtime.getRuntime().exec(commandArgs.toArray(new String[commandArgs.size()]));

all the required jar is getting added in command args i.e. class path of the above process.
With same jar if we are doing lookup without launching process then lookup is successful.
But the same is not working while launching it as java independent process we are getting stackOverflow error i.e.

Caused by: java.lang.StackOverflowError
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader$3.next(URLClassLoader.java:606)
    at java.net.URLClassLoader$3.hasMoreElements(URLClassLoader.java:631)
    at sun.misc.CompoundEnumeration.next(CompoundEnumeration.java:45)
    at sun.misc.CompoundEnumeration.hasMoreElements(CompoundEnumeration.java:54)
    at java.util.ServiceLoader$LazyIterator.hasNextService(ServiceLoader.java:354)
    at java.util.ServiceLoader$LazyIterator.hasNext(ServiceLoader.java:393)
    at java.util.ServiceLoader$1.hasNext(ServiceLoader.java:474)
    at org.wildfly.naming.client.WildFlyRootContext.lambda$loadServices$0(WildFlyRootContext.java:97)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.wildfly.naming.client.WildFlyRootContext.loadServices(WildFlyRootContext.java:93)
    at org.wildfly.naming.client.WildFlyRootContext.<init>(WildFlyRootContext.java:89)
    at org.wildfly.naming.client.WildFlyRootContext.<init>(WildFlyRootContext.java:79)
    at org.wildfly.naming.client.WildFlyInitialContextFactory.getInitialContext(WildFlyInitialContextFactory.java:54)
    at org.jboss.ejb.client.naming.ejb.ejbURLContextFactory.getObjectInstance(ejbURLContextFactory.java:43)
    at javax.naming.spi.NamingManager.getURLObject(NamingManager.java:612)
    at javax.naming.spi.NamingManager.getURLContext(NamingManager.java:561)
    at org.wildfly.naming.client.WildFlyRootContext.getProviderContext(WildFlyRootContext.java:801)
    at org.wildfly.naming.client.WildFlyRootContext.lookup(WildFlyRootContext.java:140)
    at org.wildfly.naming.client.WildFlyRootContext.lookup(WildFlyRootContext.java:142)
    at org.wildfly.naming.client.WildFlyRootContext.lookup(WildFlyRootContext.java:142)
    at org.wildfly.naming.client.WildFlyRootContext.lookup(WildFlyRootContext.java:142)


while digging out more we have found that in WildflyRootContext class The above error is coming due to NamingProviderFactories List and NamingContextFactories is empty. But The same list is not empty in case of normal fixture lookup i.e. without launching independent process.

here is the properties we are using for context initialization :- ( env is HashTable  instance)
env.put(Context.PROVIDER_URL, "http://" + "localhost" + ":" + "8080" +"/wildfly-services" );
        env.put(Context.INITIAL_CONTEXT_FACTORY, WildFlyInitialContextFactory.class.getName());
        env.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
        env.put("jnp.disableDiscovery", "true");
        env.put(Context.SECURITY_PRINCIPAL,"system");
        env.put(Context.SECURITY_CREDENTIALS,"openview");   

Note :
We have tried with http-remoting( in this case we have changed the  provider url as http-remoting://localhost:8080). Along with we have tried various combination as well but it didn't worked out. we want it be worked with pure  http protocol.

Have anyone faced this issue or any idea/solution of above issue.
Quick response will be appreciated.

Thanks 
Dilip


Cheng Fang

unread,
Aug 26, 2022, 3:28:55 PM8/26/22
to DILIP kumar, WildFly
Did you try without the following?
env.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");

From the stack trace, it looks like an endless redirecting between the deprecated ejbUrlContextFactory and WildFlyInitialContextFactory, leading to the StackOverflowError, as seen in https://issues.redhat.com/browse/WFNC-24

I suspect there are some jars (like jboss-ejb-client.jar) or resources that are present in the parent process, but are actually missing in the child process. Can you double check?


--
You received this message because you are subscribed to the Google Groups "WildFly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wildfly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wildfly/31c6a7d2-f6f6-4279-bbd7-2f12fb7ea3f5n%40googlegroups.com.

DILIP kumar

unread,
Aug 29, 2022, 12:47:52 AM8/29/22
to WildFly
Hi,
I have tried removing following as well 
env.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
 it is throwing InvalidnameException :

javax.naming.InvalidNameException: WFNAM00007: Invalid URL scheme name "ejb"
    at org.wildfly.naming.client.WildFlyRootContext.getProviderContext(WildFlyRootContext.java:808)
    at org.wildfly.naming.client.WildFlyRootContext.lookup(WildFlyRootContext.java:140)
    at javax.naming.InitialContext.lookup(InitialContext.java:417)

also tried with global namespace as well as exported also facing same issue for these namespace as well.

I have rechecked it again jboss-ejb-client.jar (version- 4.0.44) is already there in classpath.

As you have referred  https://issues.redhat.com/browse/WFNC-24 (issue is still open solution not yet verified)  which looks similar kind of issue but the solution doesn't work for us.
Please suggest us other approaches.

Regards 
Dilip
    

Cheng Fang

unread,
Aug 30, 2022, 10:07:06 AM8/30/22
to DILIP kumar, WildFly
Can you create a WFNC issue https://issues.redhat.com/projects/WFNC/issues/ , and preferably with a reproducer?

The root problem is the subprocess failed to load service provider org.wildfly.naming.client.remote.RemoteNamingProviderFactory, which is configured in

META-INF/services/org.wildfly.naming.client.NamingProviderFactory in wildfly-naming-client.jar and wildfly-http-naming-client.jar

But the subprocess can already load naming classes like WildFlyRootContext as in the stacktrace, I don't know why the provider is not visible to the subprocess. So a reproducer will be very helpful.

Cheng Fang

unread,
Sep 6, 2022, 6:14:42 PM9/6/22
to DILIP kumar, WildFly
Can you try the latest WildFly stable release 26.1.2?

You may also want to use JBOSS_HOME/bin/client/jboss-client.jar in your classpath in both direct lookup and sub-process. This is a shaded jar that contains all the necessary client-side libs.
Reply all
Reply to author
Forward
0 new messages