再会!
我正在从 glassfish 迁移到 JBoss 7.1.3 。我的 .ear 应用程序无法创建远程连接。我猜我的 EJB 有问题。
下面是我部署的 EJB(来自服务器日志)
*10:10:56,226 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-2) JNDI bindings for session bean named GGICache in deployment unit subdeployment "GGI-ejb.jar" of deployment "GGI.ear" are as follows:
java:global/GGI/GGI-ejb/GGICache!ge.nbsm.weGGI.ejb.cache.GGICacheHome
java:app/GGI-ejb/GGICache!ge.nbsm.weGGI.ejb.cache.GGICacheHome
java:module/GGICache!ge.nbsm.weGGI.ejb.cache.GGICacheHome
java:jboss/exported/GGI/GGI-ejb/GGICache!ge.nbsm.weGGI.ejb.cache.GGICacheHome
java:global/GGI/GGI-ejb/GGICache!ge.nbsm.weGGI.ejb.cache.GGICacheRemote
java:app/GGI-ejb/GGICache!ge.nbsm.weGGI.ejb.cache.GGICacheRemote
java:module/GGICache!ge.nbsm.weGGI.ejb.cache.GGICacheRemote
java:jboss/exported/GGI/GGI-ejb/GGICache!ge.nbsm.weGGI.ejb.cache.GGICacheRemote
10:10:56,268 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-2) JNDI bindings for session bean named GGIDBOperation in deployment unit subdeployment "GGI-ejb.jar" of deployment "GGI.ear" are as follows:
java:global/GGI/GGI-ejb/GGIDBOperation!ge.nbsm.weGGI.ejb.DBOperation.GGIDBOperationHome
java:app/GGI-ejb/GGIDBOperation!ge.nbsm.weGGI.ejb.DBOperation.GGIDBOperationHome
java:module/GGIDBOperation!ge.nbsm.weGGI.ejb.DBOperation.GGIDBOperationHome
java:jboss/exported/GGI/GGI-ejb/GGIDBOperation!ge.nbsm.weGGI.ejb.DBOperation.GGIDBOperationHome
java:global/GGI/GGI-ejb/GGIDBOperation!ge.nbsm.weGGI.ejb.DBOperation.GGIDBOperationRemote
java:app/GGI-ejb/GGIDBOperation!ge.nbsm.weGGI.ejb.DBOperation.GGIDBOperationRemote
java:module/GGIDBOperation!ge.nbsm.weGGI.ejb.DBOperation.GGIDBOperationRemote
java:jboss/exported/GGI/GGI-ejb/GGIDBOperation!ge.nbsm.weGGI.ejb.DBOperation.GGIDBOperationRemote*
下面是我从 ResoureLocator.java 代码中查找的上下文
*Properties jndiProps = new Properties();
jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
jndiProps.put(Context.SECURITY_PRINCIPAL, "admin");
jndiProps.put(Context.SECURITY_CREDENTIALS, "adminadmin");
jndiProps.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
jndiProps.put(Context.PROVIDER_URL, "remote://localhost:4447");
jndiProps.put("jboss.naming.client.ejb.context", true);
try{
ctx = new InitialContext(jndiProps);
String strDSName = "java:jboss/datasources/Functional_GGI_CONNECTION_POOL";
ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup(strDSName);
System.out.println("Context Look Up success>>" + ds.getClass());
return ds;
} catch (NamingException namingException) {
log.error(namingException.getMessage(), namingException);
}*
下面我粘贴了我的 server.log 和我的应用程序日志供您参考。我收到错误,例如无法创建远程连接。我在使用上述属性加载初始上下文时遇到问题 ...ctx = new InitialContext(jndiProps);
10:11:07,998 ERROR [stderr] (MSC service thread 1-2) at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
10:11:08,004 ERROR [stderr] (MSC service thread 1-2) at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
10:11:08,010 ERROR [stderr] (MSC service thread 1-2) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
10:11:08,015 ERROR [stderr] (MSC service thread 1-2) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
10:11:08,020 ERROR [stderr] (MSC service thread 1-2) at java.lang.Thread.run(Thread.java:722)
10:11:08,066 ERROR [stderr] (MSC service thread 1-2) Caused by: java.lang.RuntimeException: Failed to setup EJB remote context
10:11:08,071 ERROR [stderr] (MSC service thread 1-2) at org.jboss.naming.remote.client.InitialContextFactory.setupEjbContext(InitialContextFactory.java:468)
10:11:08,077 ERROR [stderr] (MSC service thread 1-2) at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:145)
10:11:08,086 ERROR [stderr] (MSC service thread 1-2) ... 17 more
10:11:08,089 ERROR [stderr] (MSC service thread 1-2) Caused by: java.lang.reflect.InvocationTargetException
10:11:08,095 ERROR [stderr] (MSC service thread 1-2) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
10:11:08,100 ERROR [stderr] (MSC service thread 1-2) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
10:11:08,106 ERROR [stderr] (MSC service thread 1-2) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
10:11:08,112 ERROR [stderr] (MSC service thread 1-2) at java.lang.reflect.Method.invoke(Method.java:601)
10:11:08,118 ERROR [stderr] (MSC service thread 1-2) at org.jboss.naming.remote.client.InitialContextFactory.setupEjbContext(InitialContextFactory.java:448)
10:11:08,124 ERROR [stderr] (MSC service thread 1-2) ... 18 more
10:11:08,128 ERROR [stderr] (MSC service thread 1-2) Caused by: java.lang.SecurityException: EJBCLIENT000021: EJB client context selector may not be changed
10:11:08,134 ERROR [stderr] (MSC service thread 1-2) at org.jboss.ejb.client.EJBClientContext.setSelector(EJBClientContext.java:186)
10:11:08,139 ERROR [stderr] (MSC service thread 1-2) at org.jboss.naming.remote.client.ejb.RemoteNamingEjbClientContextSelector.setupSelector(RemoteNamingEjbClientContextSelector.java:28)
10:11:08,148 ERROR [stderr] (MSC service thread 1-2) ... 23 more
10:11:08,191 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/GGI]] (MSC service thread 1-2) Exception sending context initialized event to listener instance of class ge.ifm.common.utility.IFMCacheListener: ge.ifm.common.exception.GenericInterfaceException: Throwable-->Occured while loading Interface Configuration information. Exception Message is -->null
at ge.ifm.common.utility.IFMCacheListener.contextInitialized(IFMCacheListener.java:110) [classes:]
at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.17.Final-redhat-1.jar:]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.17.Final-redhat-1.jar:]
at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:89) [jboss-as-web-7.1.3.Final-redhat-4.jar:7.1.3.Final-redhat-4]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_17]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_17]
at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_17]
Caused by: java.lang.NullPointerException
at ge.nbsm.weGGI.DAO.GGIDAO.getDBConnection(GGIDAO.java:62) [GGI-ejb.jar:]
at ge.ifm.dao.GenericInterfaceDAO.initialize(GenericInterfaceDAO.java:33) [classes:]
at ge.ifm.dao.InterfaceDao.initialize(InterfaceDao.java:239) [classes:]
at ge.ifm.common.utility.IFMCacheListener.contextInitialized(IFMCacheListener.java:75) [classes:]
... 8 more
10:11:08,291 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-2) Error listenerStart
10:11:08,297 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-2) Context [/GGI] startup failed due to previous errors
10:11:08,304 ERROR [stderr] (MSC service thread 1-2) log4j:WARN No appenders could be found for logger (ge.nbsm.weGGI.common.utility.GGILifeCycleListener).
10:11:08,318 ERROR [stderr] (MSC service thread 1-2) log4j:WARN Please initialize the log4j system properly.
10:11:08,324 ERROR [stderr] (MSC service thread 1-2) log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
10:11:08,331 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service jboss.web.deployment.default-host./GGI: org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./GGI: JBAS018040: Failed to start context
at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:94)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA-redhat-2.jar:1.0.2.GA-redhat-2]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA-redhat-2.jar:1.0.2.GA-redhat-2]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_17]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_17]
at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_17]
10:11:08,579 INFO [org.jboss.as.server] (HttpManagementService-threads - 6) JBAS015870: Deploy of deployment "GGI.ear" was rolled back with failure message {"JBAS014671: Failed services" => {"jboss.web.deployment.default-host./GGI" => "org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./GGI: JBAS018040: Failed to start context"},"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.deployment.subunit.\"GGI.ear\".\"GGI-ejb.jar\".jndiDependencyService Missing[JBAS014861: <one or more transitive dependencies>]","jboss.deployment.subunit.\"GGI.ear\".\"GGI-war.war\".jboss.security.jacc Missing[JBAS014861: <one or more transitive dependencies>]","jboss.naming.context.java.comp.GGI.GGI-ejb.GGIDBOperation.env.Functional_GGI_CONNECTION_POOL Missing[jboss.naming.context.java.jboss.resources.Functional_GGI_CONNECTION_POOL]","jboss.naming.context.java.comp.GGI.GGI-ejb.GGICache.env.Functional_GGI_CONNECTION_POOL Missing[jboss.naming.context.java.jboss.resources.Functional_GGI_CONNECTION_POOL]","jboss.deployment.subunit.\"GGI.ear\".\"GGI-ejb.jar\".component.GGICache.START Missing[JBAS014861: <one or more transitive dependencies>]","jboss.deployment.subunit.\"GGI.ear\".\"GGI-ejb.jar\".component.GGIDBOperation.START Missing[JBAS014861: <one or more transitive dependencies>]"]}
10:11:08,581 INFO [org.jboss.as.osgi] (MSC service thread 1-1) JBAS011908: Unregister module: Module "deployment.GGI.ear.GGI-war.war:main" from Service Module Loader
Below is my application log
2013-04-25 10:11:02,503 DEBUG ge.nbsm.weGGI.common.utility.GGILifeCycleListener - Path for FunctionalLog4j ---- jar:file:/C:/jboss-eap-6.0/modules/com/company/test/main/test.jar!/FunctionalLog4j.xml
2013-04-25 10:11:02,512 DEBUG ge.nbsm.weGGI.common.utility.GGILifeCycleListener - in log testing propertiesnull
2013-04-25 10:11:02,512 INFO ge.nbsm.weGGI.common.utility.GGILifeCycleListener - LOG4J Configuration [OK]..
2013-04-25 10:11:02,532 DEBUG ge.nbsm.weGGI.common.utility.StartupCacher - At the Start of loadCache
2013-04-25 10:11:02,544 DEBUG ge.nbsm.weGGI.common.utility.StartupCacher - At the End of loadCache 2
2013-04-25 10:11:02,552 DEBUG ge.nbsm.weGGI.common.utility.StartupCacher - At the End of loadCache 3
2013-04-25 10:11:02,552 DEBUG ge.nbsm.weGGI.Delegate.CacherDelegate - getCacheValues:1
2013-04-25 10:11:02,553 DEBUG ge.nbsm.weGGI.Delegate.CacherDelegate - getGGICacheManagerRemote:1
2013-04-25 10:11:02,560 DEBUG ge.nbsm.weGGI.common.utility.GGIReader - String Value from Properties file:Start of Value||End of Value
2013-04-25 10:11:02,560 DEBUG ge.nbsm.weGGI.common.utility.GGIReader - Numeric Value from Properties file:Start of Value|-1|End of Value
2013-04-25 10:11:02,570 DEBUG ge.nbsm.weGGI.common.utility.GGIReader - Date Value from Properties file:Start of Value|99991231|End of Value
2013-04-25 10:11:02,570 DEBUG ge.nbsm.weGGI.Delegate.CacherDelegate - GGIConstants.STR_GGICACHEHOME >>> ejb:app/GGI/GGI-ejb/GGICache!ge.nbsm.weGGI.ejb.cache.GGICacheHome
2013-04-25 10:11:02,574 DEBUG ge.nbsm.weGGI.Delegate.CacherDelegate - getGGICacheManagerRemote:1a
2013-04-25 10:11:02,574 DEBUG ge.nbsm.weGGI.Delegate.CacherDelegate - getGGICacheManagerRemote:2
2013-04-25 10:11:07,710 INFO ge.ifm.common.utility.IFMCacheListener - IFM initialize() started
2013-04-25 10:11:08,152 ERROR ge.nbsm.weGGI.common.utility.ResourceLocator - Failed to create remoting connection
javax.naming.NamingException: Failed to create remoting connection [Root exception is java.lang.RuntimeException: Failed to setup EJB remote context]
at org.jboss.naming.remote.client.ClientUtil.namingException(ClientUtil.java:51)
at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:151)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307)
at javax.naming.InitialContext.init(InitialContext.java:242)
at javax.naming.InitialContext.<init>(InitialContext.java:216)
at ge.nbsm.weGGI.common.utility.ResourceLocator.lookUP(ResourceLocator.java:68)
at ge.nbsm.weGGI.DAO.GGIDAO.getDBConnection(GGIDAO.java:56)
at ge.ifm.dao.GenericInterfaceDAO.initialize(GenericInterfaceDAO.java:33)
at ge.ifm.dao.InterfaceDao.initialize(InterfaceDao.java:239)
at ge.ifm.common.utility.IFMCacheListener.contextInitialized(IFMCacheListener.java:75)
at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850)
at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:89)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.RuntimeException: Failed to setup EJB remote context
at org.jboss.naming.remote.client.InitialContextFactory.setupEjbContext(InitialContextFactory.java:468)
at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:145)
... 17 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.jboss.naming.remote.client.InitialContextFactory.setupEjbContext(InitialContextFactory.java:448)
... 18 more
Caused by: java.lang.SecurityException: EJBCLIENT000021: EJB client context selector may not be changed
at org.jboss.ejb.client.EJBClientContext.setSelector(EJBClientContext.java:186)
at org.jboss.naming.remote.client.ejb.RemoteNamingEjbClientContextSelector.setupSelector(RemoteNamingEjbClientContextSelector.java:28)
... 23 more
2013-04-25 10:11:08,191 ERROR ge.ifm.common.exception.GenericInterfaceException - GenericInterfaceException: Throwable-->Occured while loading Interface Configuration information. Exception Message is -->null
2013-04-25 10:11:08,191 DEBUG ge.ifm.dao.GenericInterfaceDAO - closeConnection method called
2013-04-25 10:11:08,191 DEBUG ge.ifm.dao.GenericInterfaceDAO - closeConnection cConn=null
2013-04-25 10:11:08,191 DEBUG ge.ifm.dao.GenericInterfaceDAO - out of if loop
2013-04-25 10:11:08,303 INFO ge.ifm.common.utility.IFMCacheListener - Enterted into contextDestroyed() method
2013-04-25 10:11:08,304 DEBUG ge.ifm.common.utility.IFMCacheListener - contextDestroyed ()--> Context Destroyed Method Called Successfully
2013-04-25 10:11:08,304 INFO ge.ifm.common.utility.IFMCacheListener - Enterted into release() method
2013-04-25 10:11:08,304 DEBUG ge.ifm.common.utility.IFMCacheListener - release()--> Releasing Thread Pool
2013-04-25 10:11:08,304 DEBUG ge.ifm.common.utility.IFMCacheListener - release()--> Closed the Thread Pool [OK]
2013-04-25 10:11:08,304 DEBUG ge.ifm.common.utility.IFMCacheListener - Http Client Connection Pool Releasing
2013-04-25 10:11:08,304 DEBUG ge.ifm.common.utility.IFMCacheListener - Closed the Http Client Connection Pool [OK]
2013-04-25 10:11:08,304 INFO ge.ifm.common.utility.IFMCacheListener - Exit from release() method
2013-04-25 10:11:08,304 INFO ge.ifm.common.utility.IFMCacheListener - Exit from contextDestroyed() method