tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ManojS <>
Subject Service locator problem while EJB lookup ...
Date Sat, 03 May 2008 05:19:59 GMT


I have an issue while looking up an EJB using service locator pattern. I
have a "ServiceLocator" class which is being used everywhere in my code to
lookup any EJB. But now when I use openEJB (version 3.0) it is throwing a
"javax.naming.NamingException" with message, "Name GenConfigFacadeEJB not

My service locator class is as follows:
//imports I removed for here ...
public class ServiceLocator {
	private static Context context = null;
	static {
		System.setProperty( javax.naming.Context.INITIAL_CONTEXT_FACTORY, 
		System.setProperty( javax.naming.Context.URL_PKG_PREFIXES,
"org.openejb.client" );
		context =  new InitialContext();
	public static EJBHome getEJB(String ejbName, Class homeClass) throws
NamingException {
		Object objref = null;
		try {
			objref = context.lookup(ejbName);
		} catch (NamingException e) {
			objref = context.lookup("java:comp/env/" + ejbName);
		EJBHome home = (EJBHome)PortableRemoteObject.narrow(objref, homeClass);
		return home;

In other places wherever I need to access the EJB, I will be calling this
API as follows:

My ejb-jar.xml is as follows:


And my openejb-jar.xml configuration is as follows:

<?xml version="1.0" encoding="UTF-8"?>
	     openejb.deploymentId.format = {ejbName}
	     openejb.jndiname.format = {deploymentId}

I am using openEJB embedded in Tomcat 6.0.16. While starting the tomcat, it
is showing that this respective EJB is deployed, as follows:
34391 INFO  [main] OpenEJB.startup - Created
Ejb(deployment-id=GenConfigFacadeEJB, ejb-name=GenConfigFacadeEJB,
container=Default Stateless Container)

Can anyone help me to find out why the service locator class is failing to
find the EJB objects ?

Thanks in advance.


View this message in context:
Sent from the OpenEJB User mailing list archive at

View raw message