简体   繁体   中英

Migrate from Jboss 4.2.3 to Wildfly 8

I'm trying to migrate a very old java application from Jboss 4.2.3 to Wildfly 8. I just installed the Wildfly server and the minimal config things.

In my App, my JNDI.properties file was :

java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
java.naming.provider.url=localhost:1099

So I updated it to simply :

java.naming.factory.url.pkgs=org.jboss.ejb.client.naming

The code which call the EJB was :

Properties ht = new Properties();
ht.load(BIServicesImpl.class.getClassLoader().getResourceAsStream("jndi.properties"));
Context context = new InitialContext(ht);
return (ServiceEntryPoint) context.lookup("BIServeurMetier/ServiceEntryPointBean/remote");

The JNDI path have changed in Wildfly 8 so I used :

Properties ht = new Properties();
ht.load(BIServicesImpl.class.getClassLoader().getResourceAsStream("jndi.properties"));
Context context = new InitialContext(ht);
return (ServiceEntryPoint) context.lookup("BIServeurMetier/BIServeurMetier/ServiceEntryPointBean!com.al6.bi.business.ServiceEntryPoint"); 

I deploy my application war into it, and start it, it runs pretty well :

2022-06-27 16:21:00,773 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-3) JNDI bindings for session bean named ServiceEntryPointBean in deployment unit subdeployment "BIServeurMetier.jar" of deployment "BIServeurMetier.ear" are as follows:

    java:global/BIServeurMetier/BIServeurMetier/ServiceEntryPointBean!com.al6.bi.business.ServiceEntryPoint
    java:app/BIServeurMetier/ServiceEntryPointBean!com.al6.bi.business.ServiceEntryPoint
    java:module/ServiceEntryPointBean!com.al6.bi.business.ServiceEntryPoint
    java:jboss/exported/BIServeurMetier/BIServeurMetier/ServiceEntryPointBean!com.al6.bi.business.ServiceEntryPoint
    java:global/BIServeurMetier/BIServeurMetier/ServiceEntryPointBean
    java:app/BIServeurMetier/ServiceEntryPointBean
    java:module/ServiceEntryPointBean

So the EJB seams to be fine and deployed. But when I try to do any action on the app, I have this error :

2022-06-27 16:21:41,536 ERROR [stderr] (default task-25) javax.naming.NameNotFoundException: BIServeurMetier/BIServeurMetier/ServiceEntryPointBean!com.al6.bi.business.ServiceEntryPoint -- service jboss.naming.context.java.BIServeurMetier.BIServeurMetier."ServiceEntryPointBean!com.al6.bi.business.ServiceEntryPoint"
2022-06-27 16:21:41,537 ERROR [stderr] (default task-25)    at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:104)
2022-06-27 16:21:41,537 ERROR [stderr] (default task-25)    at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:202)
2022-06-27 16:21:41,537 ERROR [stderr] (default task-25)    at org.jboss.as.naming.InitialContext$DefaultInitialContext.lookup(InitialContext.java:233)
2022-06-27 16:21:41,537 ERROR [stderr] (default task-25)    at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:188)
2022-06-27 16:21:41,537 ERROR [stderr] (default task-25)    at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:184)
2022-06-27 16:21:41,538 ERROR [stderr] (default task-25)    at javax.naming.InitialContext.lookup(InitialContext.java:417)
2022-06-27 16:21:41,538 ERROR [stderr] (default task-25)    at javax.naming.InitialContext.lookup(InitialContext.java:417)
2022-06-27 16:21:41,539 ERROR [stderr] (default task-25)    at com.al6.bi.gwt.server.BIServicesImpl.buildBusinessServices(BIServicesImpl.java:227)
2022-06-27 16:21:41,539 ERROR [stderr] (default task-25)    at com.al6.bi.gwt.server.BIServicesImpl.<init>(BIServicesImpl.java:213)
2022-06-27 16:21:41,539 ERROR [stderr] (default task-25)    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
2022-06-27 16:21:41,539 ERROR [stderr] (default task-25)    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
2022-06-27 16:21:41,540 ERROR [stderr] (default task-25)    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
2022-06-27 16:21:41,540 ERROR [stderr] (default task-25)    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
2022-06-27 16:21:41,541 ERROR [stderr] (default task-25)    at org.jboss.as.ee.component.ConstructorComponentFactory.create(ConstructorComponentFactory.java:24)
2022-06-27 16:21:41,541 ERROR [stderr] (default task-25)    at org.jboss.as.ee.component.ComponentInstantiatorInterceptor.processInvocation(ComponentInstantiatorInterceptor.java:68)
2022-06-27 16:21:41,541 ERROR [stderr] (default task-25)    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
2022-06-27 16:21:41,542 ERROR [stderr] (default task-25)    at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)
2022-06-27 16:21:41,542 ERROR [stderr] (default task-25)    at org.jboss.as.ee.component.AroundConstructInterceptorFactory$1.processInvocation(AroundConstructInterceptorFactory.java:26)
2022-06-27 16:21:41,543 ERROR [stderr] (default task-25)    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
2022-06-27 16:21:41,543 ERROR [stderr] (default task-25)    at org.jboss.as.ee.concurrent.ConcurrentContextInterceptor.processInvocation(ConcurrentContextInterceptor.java:45)
2022-06-27 16:21:41,544 ERROR [stderr] (default task-25)    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
2022-06-27 16:21:41,544 ERROR [stderr] (default task-25)    at org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:64)
2022-06-27 16:21:41,544 ERROR [stderr] (default task-25)    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
2022-06-27 16:21:41,544 ERROR [stderr] (default task-25)    at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:326)
2022-06-27 16:21:41,545 ERROR [stderr] (default task-25)    at org.jboss.invocation.PrivilegedWithCombinerInterceptor.processInvocation(PrivilegedWithCombinerInterceptor.java:80)
2022-06-27 16:21:41,545 ERROR [stderr] (default task-25)    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
2022-06-27 16:21:41,545 ERROR [stderr] (default task-25)    at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
2022-06-27 16:21:41,545 ERROR [stderr] (default task-25)    at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:160)
2022-06-27 16:21:41,547 ERROR [stderr] (default task-25)    at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:133)
2022-06-27 16:21:41,547 ERROR [stderr] (default task-25)    at org.jboss.as.ee.component.BasicComponent.createInstance(BasicComponent.java:89)
2022-06-27 16:21:41,547 ERROR [stderr] (default task-25)    at org.jboss.as.ee.component.ComponentRegistry$ComponentManagedReferenceFactory.getReference(ComponentRegistry.java:149)
2022-06-27 16:21:41,547 ERROR [stderr] (default task-25)    at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$5.createInstance(UndertowDeploymentInfoService.java:1233)
2022-06-27 16:21:41,548 ERROR [stderr] (default task-25)    at io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:215)
2022-06-27 16:21:41,548 ERROR [stderr] (default task-25)    at io.undertow.servlet.core.ManagedServlet.getServlet(ManagedServlet.java:163)
2022-06-27 16:21:41,548 ERROR [stderr] (default task-25)    at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
2022-06-27 16:21:41,548 ERROR [stderr] (default task-25)    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:130)
2022-06-27 16:21:41,549 ERROR [stderr] (default task-25)    at com.al6.bi.gwt.server.security.BasicSessionFilter.doFilter(BasicSessionFilter.java:60)
2022-06-27 16:21:41,549 ERROR [stderr] (default task-25)    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)
2022-06-27 16:21:41,549 ERROR [stderr] (default task-25)    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132)
2022-06-27 16:21:41,549 ERROR [stderr] (default task-25)    at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:85)
2022-06-27 16:21:41,549 ERROR [stderr] (default task-25)    at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
2022-06-27 16:21:41,550 ERROR [stderr] (default task-25)    at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
2022-06-27 16:21:41,550 ERROR [stderr] (default task-25)    at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
2022-06-27 16:21:41,550 ERROR [stderr] (default task-25)    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
2022-06-27 16:21:41,550 ERROR [stderr] (default task-25)    at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
2022-06-27 16:21:41,551 ERROR [stderr] (default task-25)    at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
2022-06-27 16:21:41,551 ERROR [stderr] (default task-25)    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
2022-06-27 16:21:41,551 ERROR [stderr] (default task-25)    at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
2022-06-27 16:21:41,551 ERROR [stderr] (default task-25)    at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
2022-06-27 16:21:41,551 ERROR [stderr] (default task-25)    at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58)
2022-06-27 16:21:41,552 ERROR [stderr] (default task-25)    at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70)
2022-06-27 16:21:41,553 ERROR [stderr] (default task-25)    at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76)
2022-06-27 16:21:41,553 ERROR [stderr] (default task-25)    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
2022-06-27 16:21:41,554 ERROR [stderr] (default task-25)    at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
2022-06-27 16:21:41,556 ERROR [stderr] (default task-25)    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
2022-06-27 16:21:41,557 ERROR [stderr] (default task-25)    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
2022-06-27 16:21:41,559 ERROR [stderr] (default task-25)    at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:261)
2022-06-27 16:21:41,559 ERROR [stderr] (default task-25)    at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:248)
2022-06-27 16:21:41,564 ERROR [stderr] (default task-25)    at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:77)
2022-06-27 16:21:41,565 ERROR [stderr] (default task-25)    at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:167)
2022-06-27 16:21:41,565 ERROR [stderr] (default task-25)    at io.undertow.server.Connectors.executeRootHandler(Connectors.java:199)
2022-06-27 16:21:41,565 ERROR [stderr] (default task-25)    at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:761)
2022-06-27 16:21:41,565 ERROR [stderr] (default task-25)    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
2022-06-27 16:21:41,566 ERROR [stderr] (default task-25)    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
2022-06-27 16:21:41,566 ERROR [stderr] (default task-25)    at java.lang.Thread.run(Thread.java:748)

The path of EJB seems to be good because it is displayed at the beginning of the server log when the server starts. So what I'm doing wrong ?

I also check via the management console in JNDI, my EJB are here and listed.

JNP is the old JNDI implementation, you need to update your jndi.properties. I think that for WildFly 8 it is : final Properties env = new Properties(); env.put(Context.INITIAL_CONTEXT_FACTORY, org.jboss.naming.remote.client.InitialContextFactory.class.getName()); env.put(Context.PROVIDER_URL, "remote://localhost:4447"); remoteContext = new InitialContext(env);

In addition to ehsavoie answer, I needed to trick a few things to make it works.

I follow the tutorial here :

https://docs.jboss.org/author/display/WFLY10/EJB%20invocations%20from%20a%20remote%20client%20using%20JNDI.html

And here :

https://docs.jboss.org/author/display/WFLY10/Remote%20JNDI%20Reference%20Update%20Draft.html

In fact, in my case, I don't need http remoting mode, just a simple EJB mode, so no complex parameters to put in JNDI.properties.

I delete my jndi.properties file, and just update the code to :

final Hashtable jndiProperties = new Hashtable();
jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
final Context context = new InitialContext(jndiProperties);
return (ServiceArchiveEntryPoint) context.lookup("ejb:BIServeurMetier/BIServeurMetier//ServiceArchiveEntryPointBean!com.al6.bi.business.ServiceArchiveEntryPoint");

In my first tries before that code, it doesn't work. I think it was because I don't put the correct path. The rule seems to be :

context.lookup("ejb:" + appName + "/" + moduleName + "/" + distinctName + "/" + beanName + "!" + viewClassName);

Before that, I don't put a "distinctName", but it seems that if we don't have one, just put a empty string, so it gives in my case "//".

Maybe it was that, maybe it was the "ejb:" prefix, I don't know which change make it works, but it works now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM