#7 Proxool and Castor JDO

closed-fixed
Bill Horsman
5
2003-10-26
2003-05-22
Robert Rodewald
No

This is not necessarily a proxool bug but here's what
happend...

I tried to use Castor JDO with proxool connection
pooling as suggested in the Pooling section on the
Castor JDO website and got a strange behaviour. The
connection pool is set up correctly but is immediately
shut down when the call to jdo.getDatabase() is made.

It seems that the connection pool shuts down because
the connection Driver is finalized by the systems
Finalizer. My debugger shows that its line 285 in the
class Mapping (in the Castor JDO package) that causes
the problem, but I don't understand why...

Can you give me a hint? Why is the ProxoolDriver class
being finalized? Proxool and Castor JDO work fine
without the other but seem to have problems together...

I'm sorry if this is completely the wrong place to ask for
this. I also sent this problem to the Castor JDO team.

Line 285 in Mapping.class

loaderConst = loaderClass.getConstructor( new Class[] {
ClassLoader.class, PrintWriter.class } );

Console output

22.05.2003 15:09:03
org.logicalcobwebs.proxool.ProxoolFacade
registerConnectionPool
INFO: Proxool 0.7.2 (29-Apr-2003 00:33)
22.05.2003 15:09:05
org.logicalcobwebs.proxool.ConnectionPool shutdown
INFO: Shutting down 'testpool' pool immediately
[Finalizer]
WHAT has happend?

Source code (JDOProxoolTest.java)

package playground;

// Imports for the Castor JDO persistence layer
import org.exolab.castor.jdo.*;

// Imports for the Proxool connection pooling mechanism
import
org.logicalcobwebs.proxool.configuration.JAXPConfigurat
or;
import org.logicalcobwebs.proxool.ProxoolException;

public class JDOProxoolTest {

/**
* Constructor
*/
public JDOProxoolTest() {
super();
}

public static void main(String[] args) {
JDO jdo;
Database db;

// Initialize connection pooling
try {

JAXPConfigurator.configure
("etc/proxool.xml", false);
}
catch (ProxoolException e) {
System.err.println
("Error while initializing connection pooling!");
System.exit(1);
}

// Define the JDO object
jdo = new JDO();
jdo.setDatabaseName
( "castor_test" );
jdo.setConfiguration
( "etc/database.xml" );
jdo.setClassLoader(
JDOProxoolTest.class.getClassLoader() );
try {
// Obtain a new
database
db = jdo.getDatabase();
System.out.println
("WHAT has happend?");
db.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
}

Config files

~~~ etc/proxool.xml ~~~

<?xml version="1.0" encoding="ISO-8859-1"?>
<proxool>
<alias>testpool</alias>
<driver-
url>jdbc:postgresql://server3.kopsis.com/db_castor_test
</driver-url>
<driver-class>org.postgresql.Driver</driver-
class>
<driver-properties>
<property name="user"
value="user_test"/>
<property name="password"
value="pwd_test"/>
</driver-properties>
</proxool>

~~~ etc/database.xml ~~~

<database name="castor_test" engine="postgresql">
<driver class-
name="org.logicalcobwebs.proxool.ProxoolDriver"
url="proxool.testpool:org.postgresql.Driver:jdbc:postgresq
l://192.168.0.8/db_castor_test">
<param name="user"
value="someuser"/>
<param name="password"
value="somepassword"/>
</driver>
<mapping href="mapping.xml" />
</database>

Additional information

Package versions:
Java 1.4.1
Castor 0.9.4.3
Proxool 0.7.2

IDE:
Eclipse 2.1


Discussion

  • Bill Horsman
    Bill Horsman
    2003-05-22

    • assigned_to: nobody --> billhorsman
     
  • Bill Horsman
    Bill Horsman
    2003-05-22

    Logged In: YES
    user_id=91747

    Robert, thanks for the very informative bug report. You were
    very clear.

    This looks like a class loader problem to me. Tell me, what
    container are you running all this in? As a standalone app,
    or in an app server, or servlet container? That is very
    relevant.

    I'm hoping that some of my colleagues can help on this one,
    because I am off on vacation shortly and won't be back until
    2 June. My "quick guess" at a fix is to make sure that the
    proxool jar is in the same place as the castor jar. That
    should place them in the same class loader.

    This is a very complex and confusing subject. I know that
    Christian has one or two ideas up his sleeve on a solution
    that might make it go away for ever. In the meantime,
    classpath position and class loading is the key.

    If you want to open up the discussion, I suggest you try one
    of the mailing lists - they have a wider audience than this
    bug list.

    Good luck with Castor and Proxool!

    Bill

     
  • Logged In: YES
    user_id=454746

    I'm also going away for the weekend. I'll have a look early
    next week. Thanks for the detailed bug report Robert!

    Chr

     
  • Bill Horsman
    Bill Horsman
    2003-10-26

    • status: open --> closed-fixed
     
  • Bill Horsman
    Bill Horsman
    2003-10-26

    Logged In: YES
    user_id=91747

    Fixed in 0.8.0