将远程EJB注入Spring时出错

时间:2017-02-19 11:35:39

标签: java spring ejb

我正在尝试将EJB注入到Spring 4应用程序上下文中。我已经阅读了几本手册和教程,我已经结束了。我不知道为什么Spring无法通过JDNI名称获取Remote Bean。当我使用WildFly 10启动应用程序时,我收到404错误。

我的Bean定义是: JNDI bindings for session bean named 'CursoServiceBean' in deployment unit 'subdeployment "gestion-docente-ejb.jar" of deployment "gestion-docente-ear-1.0.0-SNAPSHOT.ear"' are as follows:

java:global/gestion-docente-ear-1.0.0-SNAPSHOT/gestion-docente-ejb/CursoServiceBean!
com.formacion.ipartek.curso.CursoServiceRemote
java:app/gestion-docente-ejb/CursoServiceBean!
com.formacion.ipartek.curso.CursoServiceRemote
java:module/CursoServiceBean!
com.formacion.ipartek.curso.CursoServiceRemote
java:jboss/exported/gestion-docente-ear-1.0.0-SNAPSHOT/gestion-docente-ejb/CursoServiceBean!
com.formacion.ipartek.curso.CursoServiceRemote
java:global/gestion-docente-ear-1.0.0-SNAPSHOT/gestion-docente-ejb/CursoServiceBean
java:app/gestion-docente-ejb/CursoServiceBean
java:module/CursoServiceBean

bean id ="cursoServiceRemote"  class="org.springframework.ejb.access.SimpleRemoteStatelessSessionProxyFactoryBean">
   property name="jndiName" value="java:module/CursoServiceBean!com.formacion.ipartek.curso.CursoServiceBean" />
   property name="jndiEnvironment">
        props>
           prop key="java.naming.factory.initial">com.sun.jndi.ldap.LdapCtxFactory</prop>
           prop key="java.naming.provider.url">ldap://localhost:9990</prop>
           prop key="java.naming.security.principal">*******/prop>
           prop key="java.naming.security.authentication">simple/prop> 
           prop key="java.naming.security.credentials">******/prop>
        /props>
    /property>
   property name="businessInterface" value="com.formacion.ipartek.curso.CursoServiceRemote" />
</bean>
<bean id="cursoServiceImp" class="com.ipartek.formacion.service.CursoServiceImp">
    property name="cursoServiceRemote" ref="cursoServiceRemote" />
</bean>

java:global/gestion-docente-ear-1.0.0-SNAPSHOT/gestion-docente-ejb/CursoServiceBean! com.formacion.ipartek.curso.CursoServiceRemote java:app/gestion-docente-ejb/CursoServiceBean! com.formacion.ipartek.curso.CursoServiceRemote java:module/CursoServiceBean! com.formacion.ipartek.curso.CursoServiceRemote java:jboss/exported/gestion-docente-ear-1.0.0-SNAPSHOT/gestion-docente-ejb/CursoServiceBean! com.formacion.ipartek.curso.CursoServiceRemote java:global/gestion-docente-ear-1.0.0-SNAPSHOT/gestion-docente-ejb/CursoServiceBean java:app/gestion-docente-ejb/CursoServiceBean java:module/CursoServiceBean bean id ="cursoServiceRemote" class="org.springframework.ejb.access.SimpleRemoteStatelessSessionProxyFactoryBean"> property name="jndiName" value="java:module/CursoServiceBean!com.formacion.ipartek.curso.CursoServiceBean" /> property name="jndiEnvironment"> props> prop key="java.naming.factory.initial">com.sun.jndi.ldap.LdapCtxFactory</prop> prop key="java.naming.provider.url">ldap://localhost:9990</prop> prop key="java.naming.security.principal">*******/prop> prop key="java.naming.security.authentication">simple/prop> prop key="java.naming.security.credentials">******/prop> /props> /property> property name="businessInterface" value="com.formacion.ipartek.curso.CursoServiceRemote" /> </bean> <bean id="cursoServiceImp" class="com.ipartek.formacion.service.CursoServiceImp"> property name="cursoServiceRemote" ref="cursoServiceRemote" /> </bean>

请帮忙。

1 个答案:

答案 0 :(得分:0)

虽然jdni:jee我能够将EJB bean注入Spring。

<jee:jndi-lookup id="cursoServiceRemote" jndi-name="java:app/gestion-docente-ejb/CursoServiceBean" />

<bean id="cursoServiceImp" class="com.ipartek.formacion.service.CursoServiceImp">
    <property name="cursoServiceRemote" ref="cursoServiceRemote" />
</bean>