openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Sutter <kwsut...@gmail.com>
Subject Re: Webapp restart problem
Date Fri, 22 May 2009 14:59:27 GMT
So, this looks to be a Classloader issue with Tomcat.  As you have found
out, putting the OpenJPA provider jars in your application will get around
this issue.  But, it's still an issue.  Does anybody know if Tomcat defines
how to install and configure JPA providers?  I know that WebSphere has
defined steps for supporting various JPA providers [1].  I wonder if Tomcat
has something similar?

Kevin

[1]
http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/topic/com.ibm.websphere.nd.multiplatform.doc/info/ae/ae/tejb_configpp.html

2009/5/22 Daryl Stultz <daryl@6degrees.com>

> On Fri, May 22, 2009 at 8:18 AM, MiƂosz Tylenda <mtylenda@o2.pl> wrote:
>
> > That rings me on Tomcat clearing static variables [1] after reload, see
> > org.apache.catalina.loader. WebappClassLoader.ENABLE_CLEAR_REFERENCES
> > property. Maybe this explains something.
> >
>
> That does in fact change the behavior but only reinforces my suspicion that
> after the redeploy, there are references to the static member from the
> first
> start. Here are some print statements with ENABLE_CLEAR_REFERENCES=false:
> *
> (See note at bottom before wasting your time reading next block)*
>
> FIRST START
> Created new EM Factory
> org.apache.openjpa.persistence.EntityManagerFactoryImpl@3f7ede
> Instantiated JpaDataSource com.sixdegreessoftware.sql.JpaDataSource@1a1cf5
> JpaDataSource.getConnection()
> com.sixdegreessoftware.sql.JpaDataSource@1a1cf5
> dbRegistryMap = {default=com.sixdegreessoftware.sql.DbJdbc@e05748}
> db = com.sixdegreessoftware.sql.DbJdbc@e05748
>
> REDEPLOY
>
> Created new EM Factory
> org.apache.openjpa.persistence.EntityManagerFactoryImpl@ca1676
> Instantiated JpaDataSource com.sixdegreessoftware.sql.JpaDataSource@ee411c
> JpaDataSource.getConnection()
> com.sixdegreessoftware.sql.JpaDataSource@ee411c
> dbRegistryMap = {default=com.sixdegreessoftware.sql.DbJdbc@e05748}
> db = com.sixdegreessoftware.sql.DbJdbc@e05748
>
> Note after redeploy the JpaDataSource instance has changed but
> dbRegistryMap
> and db are the instances from the FIRST START. dbRegistryMap is the static
> member coming up null when ENABLE_CLEAR_REFERENCES=true (the default). It
> should be null, really, it's a member of a class that got reloaded and
> should not be referenced anymore.
>
> Maybe someone can try this with ENABLE_CLEAR_REFERENCES=true (the default).
> If you have a Tomcat application with OpenJPA and a DataSource, subclass
> your DataSource with this:
>
> import java.io.PrintWriter;
> import java.sql.*;
> import java.sql.Connection;
>
> import javax.sql.DataSource;
>
> public class MyDataSource extends YourExistingDataSource {
>
>    private static String testValue = "Shazaam!";
>
>    public MyDataSource() {
>        super();
>        System.out.println("Instantiated MyDataSource " + this);
>    }
>
>    public Connection getConnection() throws SQLException {
>        System.out.println("MyDataSource.getConnection() " + this + "
> testValue " + testValue);
>        return super.getConnection();
>    }
>
> }
>
> Note that Shazaam! is printed in the first start phase but null after
> redeploy.
>
> *Hey WAAAAAIIIIIIIT a minute! *The class with the member coming up null is
> in my webapp/WEB-INF/lib folder. openjpa.jar and geronimo.jar (et al) are
> in
> catalina/lib. If I move openjpa jars to webapp/WEB-INF/lib the problem goes
> away. DANG! Sorry to bother everyone.
>
> --
> Daryl Stultz
> _____________________________________
> 6 Degrees Software and Consulting, Inc.
> http://www.6degrees.com
> mailto:daryl@6degrees.com
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message