users@glassfish.java.net

Re: Database url in persistence.xml is ignored

From: Mitesh Meswani <Mitesh.Meswani_at_Sun.COM>
Date: Wed, 23 Jul 2008 16:29:43 -0700

 From the log it seems you are running in Java SE mode. That is you are
calling Persistence.createEMF(). There is no default URL when running
in this mode. You are specifying "jdbc:derby://localhost:1527/myappdb"
and you observe running with
"jdbc:derby://localhost:1527/sun-appserv-samples;;create=true". Can you
check your packaging scripts to see whether it is picking up the
persistence.xml that you think it should.


Marina Vatkina wrote:
> Did you create 'MYAPP' schema in your derby instance? If not, you
> might want to add ';create=true' to the URL.
>
> HTH,
> -marina
>
> glassfish_at_javadesktop.org wrote:
>> 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
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
>> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>