tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Davidson" <stephen.david...@etcc.com>
Subject RE: Include Classpath not sharing Deployed EJBs?
Date Tue, 26 Jan 2010 17:24:56 GMT
Just realized, you might need the getInitialContext() method for the
previous routine.

Regards,
Steve

    protected InitialContext getInitialContext() throws NamingException
{
        Properties properties = new Properties();
        properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.client.LocalInitialContextFactory");

        InitialContext initialContext = new InitialContext(properties);
        return initialContext;
    }


-----Original Message-----
From: Stephen Davidson [mailto:stephen.davidson@etcc.com] 
Sent: Tuesday, January 26, 2010 11:16 AM
To: users@openejb.apache.org
Subject: RE: Include Classpath not sharing Deployed EJBs?

Sure.

The odd thing is, this works when there IS a ejb-jar.xml file.  Only
when there is no ejb-jar.xml does this fail.  I think I still have
Jason's(?) test case around.  If needed, I can probably modify that to
produce this if you would like.

Regards,
Steve

    protected <T extends ServiceInterface> T getImpl(Class<T>
theInterface) {
        if (logger.isTraceEnabled())
            logger.trace("Getting EJB Client for: " +
theInterface.getName());
        InitialContext initialContext = null;
        try {
            initialContext = getInitialContext();
            @SuppressWarnings("unchecked")
            T service = (T)initialContext.lookup("com/etcc/" +
getServiceName(theInterface) + "Local");
            return service;
        } catch (NamingException e) {
          String msg = "Unable to access EJB " +
getServiceName(theInterface) + ": " + e.getMessage();
          throw new RuntimeException(msg, e);
        } finally {
            if (initialContext != null){
                try {
                    initialContext.close();
                } catch (NamingException e) {
                    logger.warn("Exception closing initial context: " +
e.getMessage(), e);
                }
            }
        }

    }


Mime
View raw message