有一个无法通过JNDI查找创建的spring bean。例外是:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'beanRefFactoryEjb' defined in URL [vfs:/C:/work/wildfly-10.0.0.Final/bin/content/authorization-service-1.1.1.ear/authorization-service-core-1.1.1.jar/beanRefFactory.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.context.support.ClassPathXmlApplicationContext]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authorizationService' defined in class path resource [applicationContext-localEjb.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: authorization-service-1.1.1/ejb/org.drake.authorization.AuthorizationService -- service jboss.naming.context.java.global."authorization-service-1.1.1".ejb."org.drake.authorization.AuthorizationService"
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:451)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
... 38 more
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.context.support.ClassPathXmlApplicationContext]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authorizationService' defined in class path resource [applicationContext-localEjb.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: authorization-service-1.1.1/ejb/org.drake.authorization.AuthorizationService -- service jboss.naming.context.java.global."authorization-service-1.1.1".ejb."org.drake.authorization.AuthorizationService"
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:100)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authorizationService' defined in class path resource [applicationContext-localEjb.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: authorization-service-1.1.1/ejb/org.drake.authorization.AuthorizationService -- service jboss.naming.context.java.global."authorization-service-1.1.1".ejb."org.drake.authorization.AuthorizationService"
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1175)
... 51 more
Caused by: javax.naming.NameNotFoundException: authorization-service-1.1.1/ejb/org.drake.authorization.AuthorizationService -- service jboss.naming.context.java.global."authorization-service-1.1.1".ejb."org.drake.authorization.AuthorizationService"
at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:106)
这是我的 applicationContext-localEJB.xml 文件:
<bean id="authorizationService" class="org.springframework.ejb.access.LocalStatelessSessionProxyFactoryBean">
<property name="jndiName"><value>java:global/authorization-service-1.1.1/ejb/org.dcri.authorization.AuthorizationService</value></property>
<property name="businessInterface"><value>org.dcri.authorization.AuthorizationService</value></property>
</bean>
<!-- AuthorizationAdminService -->
<bean id="authorizationAdminService" class="org.springframework.ejb.access.LocalStatelessSessionProxyFactoryBean">
<property name="jndiName"><value>java:global/authorization-service-1.1.1/ejb/org.dcri.authorization.AuthorizationAdminService</value></property>
<property name="businessInterface"><value>org.dcri.authorization.AuthorizationAdminService</value></property>
</bean>
<!-- AccountService -->
<bean id="accountService" class="org.springframework.ejb.access.LocalStatelessSessionProxyFactoryBean">
<property name="jndiName"><value>java:global/authorization-service-1.1.1/ejb/org.dcri.authorization.AccountService</value></property>
<property name="businessInterface"><value>org.dcri.authorization.AccountService</value></property>
</bean>
当Wildfly启动时,这些是JNDI名称:
19:13:01,117 INFO [org.jboss.as.ejb3.deployment] (MSC service thread 1-5) WFLYEJB0473: JNDI bindings for session bean named 'AuthorizationService' in deployment unit 'subdeployment "authorization-service-core-1.1.1.jar" of deployment "authorization-service-1.1.1.ear"' are as follows:
java:global/authorization-service-1.1.1/authorization-service-core-1.1.1/AuthorizationService!org.drake.authorization.ejb.AuthorizationService
java:app/authorization-service-core-1.1.1/AuthorizationService!org.drake.authorization.ejb.AuthorizationService
java:module/AuthorizationService!org.drake.authorization.ejb.AuthorizationService
java:global/authorization-service-1.1.1/authorization-service-core-1.1.1/AuthorizationService!org.drake.authorization.ejb.AuthorizationServiceHome
java:app/authorization-service-core-1.1.1/AuthorizationService!org.drake.authorization.ejb.AuthorizationServiceHome
java:module/AuthorizationService!org.drake.authorization.ejb.AuthorizationServiceHome
19:13:01,119 INFO [org.jboss.as.ejb3.deployment] (MSC service thread 1-5) WFLYEJB0473: JNDI bindings for session bean named 'AuthorizationAdminService' in deployment unit 'subdeployment "authorization-service-core-1.1.1.jar" of deployment "authorization-service-1.1.1.ear"' are as follows:
java:global/authorization-service-1.1.1/authorization-service-core-1.1.1/AuthorizationAdminService!org.drake.authorization.ejb.AuthorizationAdminService
java:app/authorization-service-core-1.1.1/AuthorizationAdminService!org.drake.authorization.ejb.AuthorizationAdminService
java:module/AuthorizationAdminService!org.drake.authorization.ejb.AuthorizationAdminService
java:global/authorization-service-1.1.1/authorization-service-core-1.1.1/AuthorizationAdminService!org.drake.authorization.ejb.AuthorizationAdminServiceHome
java:app/authorization-service-core-1.1.1/AuthorizationAdminService!org.drake.authorization.ejb.AuthorizationAdminServiceHome
java:module/AuthorizationAdminService!org.drake.authorization.ejb.AuthorizationAdminServiceHome
19:13:01,124 INFO [org.jboss.as.ejb3.deployment] (MSC service thread 1-5) WFLYEJB0473: JNDI bindings for session bean named 'AccountService' in deployment unit 'subdeployment "authorization-service-core-1.1.1.jar" of deployment "authorization-service-1.1.1.ear"' are as follows:
java:global/authorization-service-1.3.3/authorization-service-core-1.1.1/AccountService!org.drake.authorization.ejb.AccountService
java:app/authorization-service-core-1.1.1/AccountService!org.drake.authorization.ejb.AccountService
java:module/AccountService!org.drake.authorization.ejb.AccountService
java:global/authorization-service-1.3.3/authorization-service-core-1.1.1/AccountService!org.drake.authorization.ejb.AccountServiceHome
java:app/authorization-service-core-1.1.1/AccountService!org.drake.authorization.ejb.AccountServiceHome
java:module/AccountService!org.drake.authorization.ejb.AccountServiceHome
非常感谢任何帮助。我试图将JNDI名称更改为 java:/ global 。
答案 0 :(得分:0)
将JNDI名称设置为:
java:app/authorization-service-core-1.1.1/AuthorizationService!org.drake.authorization.ejb.AuthorizationServiceHome
现在找到名字。