문제

I develop enterprise project in NetBeans on GlassFish (J2EE_1.4). There are some entity beans, a couple of session beans and message driven bean in my project. I use entity beans from servlet (in same project, from web-component) in way like this:

InitialContext ic;
ic = new InitialContext();
UserLocalHome userHome = (UserLocalHome) ic.lookup("java:comp/env/ejb/User");

Everything works just fine. But when I try to do lookup from session bean or MDB I get naming error. No bean can lookup any other bean. There are some references in web deployment descriptors, but AFAIK there's no need to define references for EJB. Also all entity beans have only local interface.

도움이 되었습니까?

해결책

Each EJB has its own java:comp namespace, so in J2EE 1.4, each <entity/> or <message-driven/> must have its own <ejb-ref/> (or <ejb-local-ref/>).

In JavaEE 6, a single EJB (or the servlet), can declare an ejb-ref with a java:module (or java:app) prefix to allow any component in that scope to be able to share the reference.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top