Hi,

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
found".

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, 
"org.openejb.client.LocalInitialContextFactory");
                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:
        ServiceLocator.getEJB("GenConfigFacadeEJB",GenConfigFacadeHome.class);

My ejb-jar.xml is as follows:

<ejb-jar>
        <enterprise-beans>
        <session>
                <ejb-name>GenConfigFacadeEJB</ejb-name>
                <home>com.company.GenConfigFacadeHome</home>
                <remote>com.company.GenConfigFacade</remote>
                <local-home>com.company.GenConfigFacadeLocalHome</local-home>
                <local>com.company.GenConfigFacadeLocal</local>
                <ejb-class>com.company.GenConfigFacadeEJB</ejb-class>
                <session-type>Stateless</session-type>
                <transaction-type>Container</transaction-type>
        </session> 
        ........
        </enterprise-beans>
</ejb-jar>

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

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

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.

Manoj.

-- 
View this message in context: 
http://www.nabble.com/Service-locator-problem-while-EJB-lookup-...-tp17031873p17031873.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Reply via email to