I have a an ear file to be deployed on weblogic 12c.
I have following project structure :
1) prop-application which is an .ear file
2) prop-service which is a .jar file
3) prop-framework which is a .jar file
All are maven project.
- prop-service contains prop-framework as one of its maven dependency.
- prop-application which is an ear contains prop-service
so we can say : prop-application.ear = prop-service.jar + prop-framework.jar
prop-service.jar = more java codes + prop-framework.jar
Now there is a class in prop-framework as :
@Stateless(name = "ServiceCallerBean")
public class ServiceCallerBean implements ServiceCaller
@Local
public interface ServiceCaller
Requirement :
Now i want to lookup(call) this EJB from a from a class in *prop-service* i.e a local look. The point here is to note that prop-service.jar contains prop-framework.jar
Following is the jndi names generated by weblogic 12c server :
java:global/ProposalEngine/prop-service-0.0.1-SNAPSHOT/ServiceCallerBean.>
java:module/ServiceCallerBean.>
java:app/prop-service-0.0.1-SNAPSHOT/ServiceCallerBean.>
java:global/ProposalEngine/prop-service-0.0.1-SNAPSHOT/ServiceCallerBean!com.db.serviceframework.ejb.ServiceCaller.>
java:app/prop-service-0.0.1-SNAPSHOT/ServiceCallerBean!com.db.serviceframework.ejb.ServiceCaller.>
java:module/ServiceCallerBean!com.db.serviceframework.ejb.ServiceCaller.>
I can't use those jndi names which contains jar version(eg 0.0.1-SNAPSHOT) because jar version will keep on changing. But if i use any of the jndi names like java:module/ServiceCallerBean , then there lookup fails with javax.naming.NameNotFoundException: While trying to lookup error
I have tried even :
@EJB
ServiceCaller serviceCaller
在prop-service中的必需类中,但serviceCaller在这里是null。搜索了这个问题,发现我们只能在容器托管类中使用@EJB,而不是简单的java类。
我已经尝试了一切,但注意到似乎工作。所以PLZ帮我解决了这个问题。
答案 0 :(得分:1)
This blog包含对JNDI地址来自何处的很好的解释。 prop-service-0.0.1-SNAPSHOT
条目取自JAR或WAR的名称,因此您可以使用Maven JAR插件更改JAR的final name
,您应该能够删除版本号{{3 }}