shankar
shankar

Reputation: 73

Oracle weblogic 12c + local EJB lookup

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

in the required class in prop-service but serviceCaller comes out to be null here. Searched on this issue and found that we can use @EJB in only container managed classes, not in simple java class.

I have tried everything but noting seems to be working. So plz help me to solve this issue.

Upvotes: 2

Views: 1584

Answers (1)

hugh
hugh

Reputation: 2280

This blog contains a nice explanation of where the JNDI addresses come from. The prop-service-0.0.1-SNAPSHOT entry is taken from the name of the JAR or WAR, so you can use the Maven JAR plugin to change the final name of your JAR you should be able to remove the version number, like this.

Upvotes: 1

Related Questions