users@glassfish.java.net

Database url in persistence.xml is ignored

From: <glassfish_at_javadesktop.org>
Date: Tue, 22 Jul 2008 19:26:36 PDT

Hello,

I am getting an exception that appears to result from glassfish/toplink not reading the database url specified in my persistence.xml file. The exception is:

oracle.toplink.essentials.exceptions.DatabaseException Internal Exception: java.sql.SQLSyntaxErrorException: Schema 'MYAPP' does not exist
Error Code: -1

It appears that the app server is using an incorrect value for the database url, rather than the value specified in the persistence.xml file. However, the username and password values specified in the persistence.xml file are used, and the database url works when accessing the database from outside of the app server.

The relevant lines of the persistece.xml file are:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="myapp_remote">

<properties>
        <property name="toplink.jdbc.url"
                value="jdbc:derby://localhost:1527/myappdb" />
        <property name="toplink.jdbc.user" value="myapp" />
        <property name="toplink.jdbc.password" value="myapp" />
        <property name="toplink.logging.level" value="FINEST"/>
</properties>

</persistence-unit>
</persistence>

The console output generated when attempting to access the ejbs includes the following (somewhat abridged):

[#|...|FINEST|sun-appserver9.1|oracle.toplink.essentials.session.file:...|property=toplink.target-server; value=oracle.toplink.essentials.platform.server.sunas.SunAS9ServerPlatform|#]
[#|...|FINEST|sun-appserver9.1|oracle.toplink.essentials.session.file:...|property=toplink.logging.level; value=FINEST; translated value=FINEST|#]
[#|...|FINEST|sun-appserver9.1|oracle.toplink.essentials.session.file:...|property=toplink.jdbc.user; value=myapp|#]
[#|...|FINEST|sun-appserver9.1|oracle.toplink.essentials.session.file:...|property=toplink.jdbc.password; value=xxxxxx|#]
[#|...|INFO|sun-appserver9.1|oracle.toplink.essentials.session.file:...|TopLink, version: Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))|#]

It's odd that the user, password, and logging level properties appear to be picked up from persistence.xml, but not the url. Instead, the app server seems to be using the a default url (jdbc:derby://localhost:1527/sun-appserv-samples), as shown in the console output below:

[#|...|CONFIG|sun-appserver9.1|oracle.toplink.essentials.session.file:...|connecting(DatabaseLogin(
        platform=>JavaDBPlatform
        user name=> "myapp"
        connector=>JNDIConnector datasource name=>null))|#]
[#|...|CONFIG|sun-appserver9.1|oracle.toplink.essentials.session.file:...|Connected: jdbc:derby://localhost:1527/sun-appserv-samples;;create=true
        User: myapp
        Database: Apache Derby Version: 10.2.2.1 - (538595)
        Driver: Apache Derby Network Client JDBC Driver Version: 10.2.2.1 - (538595)|#]

Any help with getting glassfish/toplink to use the url specified in the persistence.xml would be most appreciated.

I'm using:
JVM 1.6.0_03
Glassfish V2
Toplink Essentials 2.0
Deploying from Eclipse 3.4

-Christoph
[Message sent by forum member 'choashierhardt' (choashierhardt)]

http://forums.java.net/jive/thread.jspa?messageID=288565