I made a small example using weblogic 10.3.6 and EJB 3.0. Define SimpleService class, define weblogic-ejb-jar.xml in order to map SimpleService class to JNDI name, pack it as EJB component in EAR file and deploy on server. Deployment is successful and I can see ejb bean with name SimpleServiceBean. After that using standalone application connect to webloigc server through InitialContext with all necessary environment attributes I try to lookup that bean. I assume that it will be available under name ejb/SimpleService but can't found it under that name and only after I was looking through a JNDI tree name I found out that it available under name SimpleService#ds/base/ejb/SimpleService. Help me to understand what is going on? How should I configure ejb bean in order that it will be available under ejb/SimpleService as it described in the official weblogic manual? Or maybe it's a correct JNDI name for the EJB bean?
My classes and configs are:
ds.base.ejb.SimpleServiceBean:
@Stateless(mappedName = "ServiceBean")
@TransactionAttribute(NEVER)
@ExcludeDefaultInterceptors
@Remote(SimpleService.class)
public class SimpleServiceBean implements SimpleService {
...
}
weblogic-ejb-jar.xml
<weblogic-ejb-jar>
<weblogic-enterprise-bean>
<ejb-name>ServiceBean</ejb-name>
<jndi-name>ejb/ServiceBean</jndi-name>
<enable-call-by-reference>True</enable-call-by-reference>
</weblogic-enterprise-bean>
</weblogic-ejb-jar>
application.xml:
<application>
<display-name>web-app-ear</display-name>
<module>
<ejb>app-ejb-1.0-SNAPSHOT.jar</ejb>
</module>
</application>
Then try to get it from standalone:
InitialContext context = new InitialContext(env);
SimpleService simpleService = (SimpleService)
context.lookup("SimpleService#ds/base/ejb/SimpleService");
assert simpleService != null
there is a good FaQ about the global portal JNDI names on glassfish.org http://glassfish.java.net/javaee5/ejb/EJB_FAQ.html#SessionBeanGlobalJNDINameAssignment It is best practise NOT to assign a jndi name but rely on the ones defined since EE 5 (e.g. SimpleService#ds/base/ejb/SimpleService)
If you add the jndi-name configuration to your weblogic-ejb-jar.xml you could actually make it available as ejb/ServiceBean but you also have to define it "old school" style in ejb-jar.xml. More on the weblogic-ejb-jar.xml can be found http://docs.oracle.com/cd/E23943_01/web.1111/e13719/ejb_jar_ref.htm
There is also a good overview about the dd in the orcl docs. http://docs.oracle.com/cd/E23943_01/web.1111/e13719/understanding.htm#EJBPG129
Assuming, that you are working with 10.3.x server version ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With