我正在将应用程序从JBoss 5升级到7,但遇到了无法找到被调用的bean的问题。

JBoss实际在寻找哪个JNDI绑定?

server.log(启动时)

WFLYEJB0473: JNDI bindings for session bean named 'ManagerLocal' in deployment unit 'subdeployment "Application-EJB.jar" of deployment "Application-EAR.ear"' are as follows:

    java:global/Application-EAR/Application-EJB/ManagerLocal!com.application.data.manager.local.ManagerLocal
    java:app/Application-EJB/ManagerLocal!com.application.data.manager.local.ManagerLocal
    java:module/ManagerLocal!com.application.data.manager.local.ManagerLocal
    java:global/Application-EAR/Application-EJB/ManagerLocal
    java:app/Application-EJB/ManagerLocal
    java:module/ManagerLocal


错误

javax.naming.NameNotFoundException: ManagerLocal -- service jboss.naming.context.java.ManagerLocal
    at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:106)
    at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:207)
    at org.jboss.as.naming.InitialContext$DefaultInitialContext.lookup(InitialContext.java:235)
    at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:193)
    at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:189)
    at javax.naming.InitialContext.lookup(InitialContext.java:417)
    at javax.naming.InitialContext.lookup(InitialContext.java:417)
    at com.common.util.LookupUtil.lookup(LookupUtil.java:91)
    at com.common.util.LookupUtil.lookupLocalBean(LookupUtil.java:35)
    at com.application.web.resource.RequestResource.getRequestManager(RequestResource.java:69)
    at com.application.web.resource.RequestResource.searchRequests(RequestResource.java:413)
    at com.application.trigger.handler.TriggerHandler.execute(TriggerHandler.java:43)
    at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
2018-10-05 16:25:00,030 [ApplicationScheduler_Worker-3] ERROR org.quartz.core.JobRunShell - Job AppJobs.AppBuild threw an unhandled Exception:
java.lang.RuntimeException: Couldn't get an instance of manager bean


计算JNDI名称的代码

private static String computeJNDIName(boolean isLocal, String beanName, String appName) {
        String name;

        if (isLocal) {
            name = appName + "/" + beanName + "/local";
        } else {
            name = appName + "/" + beanName + "/remote";
        }

        return name;
    }

最佳答案

不是最大的答案,例如它没有说明原因或理由,但是我必须将其添加到WAR中的JSF支持bean中,以便在升级到EAP7时它可以访问EJB jar中的bean。


@EJB(lookup="java:app/NEDtoBrsMigratorEJB/CustomerDeleterBean")
CustomerDeleterBeanLocal customerDeleterBean;


EJB的JNDI绑定是:


  java:global / NEDtoBrsMigratorEAR / NEDtoBrsMigratorEJB / CustomerDeleterBean!net.myco.brsupdater.engine.CustomerDeleterBeanLocal
  java:app / NEDtoBrsMigratorEJB / CustomerDeleterBean!net.myco.brsupdater.engine.CustomerDeleterBeanLocal
  java:module / CustomerDeleterBean!net.myco.brsupdater.engine.CustomerDeleterBeanLocal
  java:global / NEDtoBrsMigratorEAR / NEDtoBrsMigratorEJB / CustomerDeleterBean
  java:app / NEDtoBrsMigratorEJB / CustomerDeleterBean
  java:module / CustomerDeleterBean



请注意,该示例注释适用于VM JNDI查找。

07-24 18:24