tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: Resource with custom factory
Date Wed, 11 Mar 2009 21:49:07 GMT
Hash: SHA1


On 3/8/2009 4:31 PM, Derek Potts wrote:
> JPA allows you to create and configure an EntityManagerFactory, then
> store it in a Java Naming and Directory Interface (JNDI) tree for
> later retrieval and use.
> I would like to do something like this:
> Context initCtx = new InitialContext();
> Context envCtx = (Context) initCtx.lookup("java:comp/env");
> EntityManagerFactory emf = (EntityManagerFactory) envCtx.lookup("emf");

Sounds reasonable.

> I started off by reading

That's a good place to start. Pay special attention to this section:

> Unfortunately, I still receive the same NamingException, thrown by
> ResourceEnvFactory. I was hoping to at least get an exception from my
> custom factory. The fact that tomcat is still calling the
> ResourceEnvFactory is why I thought that my question is for the Tomcat
> mailing list and not the OpenJPA list.

Yeah, this is almost definintely a Tomcat question, not an OpenJPA
question (unless you want to ask if someone has ever done what you are
trying to do using Tomcat over on the other list... it couldn't hurt).

> EMFFactory is a class I wrote that implements
> javax.naming.spi.ObjectFactory, which is then placed in my
> WEB-INF/classes path.

I think here's where you made your mistake. I would have expected Tomcat
to give you a NoClassDefFoundError or something similar because,
according to the documentation, your class should go here:

When you are through, place the factory class (and the corresponding
bean class) unpacked under $CATALINA_HOME/common/classes, or in a JAR
file inside $CATALINA_HOME/common/lib. In this way, the required class
files are visible to both Catalina internal resources and your web

Try moving your factory to Tomcat's common/lib directory to see if that

- -chris
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla -


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message