-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Derek,
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 > http://tomcat.apache.org/tomcat-5.5-doc/jndi-resources-howto.html. That's a good place to start. Pay special attention to this section: http://tomcat.apache.org/tomcat-5.5-doc/jndi-resources-howto.html#Adding%20Custom%20Resource%20Factories > 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 application. " Try moving your factory to Tomcat's common/lib directory to see if that helps. - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkm4MdMACgkQ9CaO5/Lv0PCvbACgoAkiCP9YGdEXw+wlpR0Txeh2 6eUAnjBJylrqjBFk+Lu8NNkr+5jIzUsr =7LLI -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org