tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexander Saint Croix" <saintx.opensou...@gmail.com>
Subject Resource elements in openejb.xml quietly remapping to Default JDBC Database?
Date Sun, 23 Dec 2007 00:54:52 GMT
Hi!

Good news.  With (lots of) Dain's help, I finally got my example
working.  We did, however, find what appears to be a bug and a
workaround for it.

I specify two <Resource> mappings in my openejb.xml file, which look like this:

<Resource id="myDataSource" type="DataSource">
    JdbcDriver com.mysql.jdbc.Driver
    JdbcUrl jdbc:mysql://localhost/corm
    UserName root
    Password n00p455wyrd
    JtaManaged true
</Resource>

<Resource id="myNonJtaDataSource" type="DataSource">
    JdbcDrive com.mysql.jdbc.Driver
    JdbcUrl jdbc:mysql://localhost/corm
    UserName root
    Password n00p455wyrd
    JtaManaged false
</Resource>

Then, in my persistence.xml file I reference these mappings, like so:

    <jta-data-source>java:openejb/Resource/myDataSource</jta-data-source>
    <non-jta-data-source>java:openejb/Resource/myNonJtaDataSource</non-jta-data-source>

Now, this all looks normal thus far, but when I boot Tomcat, my
openejb logs tell me the following:

...
2007-12-22 18:37:20,636 - INFO  - Configuring Service(id=myDataSource,
type=Resource, provider-id=Default JDBC Database)
2007-12-22 18:37:20,638 - INFO  - Configuring
Service(id=myNonJtaDataSource, type=Resource, provider-id=Default JDBC
Database)
...

This seems to indicate that the two resources are getting
automatically pointed at the Default JDBC Database.  On further
inspection, it turns out that the Default JDBC Database and Default
Unmanaged JDBC Database is listed as a <Connector> elements.  Dain's
writing more information about this in another thread on the dev list.
 I think that if the resources are going to get pointed elsewhere,
that should be obvious, or loudly noted somewhere.  I ended up
filtering down the logs with apple's log viewer to find that
reassignment.  Never would have found it otherwise.

So, I switched the Default JDBC Database <Connector> to a <Resource>
and changed its internals to point at MySQL instead of HSQLDB:

<Resource id="Default JDBC Database" >
    JdbcDriver com.mysql.jdbc.Driver
    JdbcUrl jdbc:mysql://localhost/corm
    UserName root
    Password n00p455wyrd
    JtaManaged true
</Resource>

And, for consistency, the unmanaged version:

<Resource id="Default Unmanaged JDBC Database">
    JdbcDriver com.mysql.jdbc.Driver
    JdbcUrl jdbc:mysql://localhost/corm
    UserName root
    Password n00p455wyrd
    JtaManaged false
</Resource>

Finally, I switch the persistence.xml to read:

    <jta-data-source>java:openejb/Resource/Default JDBC
Database</jta-data-source>
    <non-jta-data-source>java:openejb/Resource/Default Unmanaged JDBC
Database</non-jta-data-source>

And now, the app is pointing at the MySQL DataSource correctly.

Thanks, guys!
--
Alexander R. Saint Croix

Mime
View raw message