EJB2 beans and jndi ENC problems
krot-s Mar 7, 2012 10:49 AMHi everybody,
I'm trying to migrate old EJB2-based application from weblogic to jboss 7.1 and can't overcome problems with jndi-lookups.
I want to make beans available under names 'ejb/BeanName'. I mimicked one of unit-tests - https://github.com/jbossas/jboss-as/tree/master/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/ejb2/reference/eararchive that does exactly what I need, but still get an error.
I have a bean OrdersBean that gets CustomersBean like that:
InitialContext context = new InitialContext(); Context env = (Context)context.lookup("java:/comp/env"); CustomersBean o = (CustomersBean)env.lookup("ejb/CustomersBean");
and get an error:
javax.naming.NameNotFoundException: comp/env/ejb/CustomersBean -- service jboss.naming.context.java.comp.env.ejb.CustomersBean
My ejb-jar.xml is:
<?xml version="1.0" encoding="UTF-8"?> <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" version="3.0"> <display-name>EJB TEST</display-name> <enterprise-beans> <session> <ejb-name>CustomersBean</ejb-name> <home>com.pls.CustomersHome</home> <remote>com.pls.CustomersBean</remote> <ejb-class>com.pls.CustomersEJB</ejb-class> <session-type>Stateless</session-type> <transaction-type>Container</transaction-type> </session> <session> <ejb-name>OrdersBean</ejb-name> <home>com.pls.OrdersHome</home> <remote>com.pls.OrdersBean</remote> <ejb-class>com.pls.OrdersEJB</ejb-class> <session-type>Stateless</session-type> <transaction-type>Container</transaction-type> <ejb-ref> <ejb-ref-name>ejb/CustomersBean</ejb-ref-name> <ejb-ref-type>Session</ejb-ref-type> <home>com.pls.CustomersHome</home> <remote>com.pls.CustomersBean</remote> </ejb-ref> </session> </enterprise-beans> </ejb-jar>
jboss-ejb3.jar is:
<?xml version="1.0"?> <jboss:ejb-jar xmlns:jboss="http://www.jboss.com/xml/ns/javaee" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee http://www.jboss.org/j2ee/schema/jboss-ejb3-2_0.xsd http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd" version="3.1" impl-version="2.0"> <enterprise-beans> <session> <ejb-name>OrdersBean</ejb-name> <ejb-ref> <ejb-ref-name>ejb/CustomersBean</ejb-ref-name> <jndi-name>java:module/CustomersBean!com.pls.CustomersBean</jndi-name> </ejb-ref> </session> </enterprise-beans> </jboss:ejb-jar>
Application is deployed as single jar, and I still get an error:
javax.naming.NameNotFoundException: comp/env/ejb/CustomersBean -- service jboss.naming.context.java.comp.env.ejb.CustomersBean
What could causes the problem?
Thank you in advance.