My Oracle Support Banner

WLS 6.1, 7.0, 8.1 - Is it possible to specify multiple JNDI names for the same EJB? (Doc ID 773349.1)

Last updated on SEPTEMBER 13, 2023

Applies to:

Oracle WebLogic Server - Version 10.3.1 and later
Information in this document applies to any platform.
Information in this document applies to any platform


Goal

Is it possible to specify multiple JNDI names for the same EJB?

It is required to have the same EJB with different JNDI names like jndiA, jndiB and jndiC. All deployed on the same
server, with the JNDI name being the only difference between each deployment.

A sample entry from the weblogic-ejb-jar.xml Deplyoment Descriptor reads:

	<weblogic-ejb-jar>
		<weblogic-enterprise-bean>
			<ejb-name>statelessSession</ejb-name>
			<jndi-name>SampleEJB</jndi-name>
		</weblogic-enterprise-bean>
		<weblogic-enterprise-bean>
			<ejb-name>statelessSession</ejb-name>
			<jndi-name>ejb20-statelessSession-SampleEJB</jndi-name>
		</weblogic-enterprise-bean>
	</weblogic-ejb-jar>

However, the following exception appears in the log file while looking up the home interface:

javax.naming.NameNotFoundException: Unable to resolve 'SampleEJB'
Resolved: '' Unresolved:'SampleEJB' ; remaining name 'SampleEJB'
		at weblogic.rmi.internal.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:109)
		at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:262)
		at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:229)
		at weblogic.jndi.internal.ServerNamingNode_WLStub.lookup(UnknownSource)
		at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:337)
		at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:332)
		at javax.naming.InitialContext.lookup(InitialContext.java:345)
		at examples.ejb20.basic.statelessSession.Client.lookupHome1(Client.java:169)
		at examples.ejb20.basic.statelessSession.Client.<init>(Client.java:42)
		at examples.ejb20.basic.statelessSession.Client.main(Client.java:71)

The client was unable to lookup the EJBHome.SampleEJB.

Solution

To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!


In this Document
Goal
Solution

My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.