Search code examples
jndiwildfly

JNDI name not found WildFly 10


Have a spring bean that is not able to be created from a JNDI lookup. Exception is:

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)

Here is my applicationContext-localEJB.xml file:

<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>

And when Wildfly starts up, these are the JNDI names:

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

Any help would be greatly appreciated. I've tried to change the JNDI name to be java:/global.


Solution

  • Set the JNDI name to be:

    java:app/authorization-service-core-1.1.1/AuthorizationService!org.drake.authorization.ejb.AuthorizationServiceHome
    

    Finds the name now.