Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

toplink.jdbc.url ignored in persistence.xml

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I'm trying to set up a JPA-project ith Glassfish and Derby.
I have one problem, the database "sun-appserv-samples" is used all the time, even though I try to set a different value in my persistence.xml

This is printed to the log:
Connected: jdbc erby://localhost:1527/sun-appserv-samples;;create=true
User: user
Database: Apache Derby Version: 10.4.2.0 - (689064)
Driver: Apache Derby Network Client JDBC Driver Version: 10.2.2.1 - (538595)|#]

My persistence.xml looks like this:


As you can see I'm trying to set the db to 'MyDB'. The values for user and password are used though. Any ideas what I'm doing wrong?

Thanks
[ December 01, 2008: Message edited by: Jim Petersson ]
 
Ranch Hand
Posts: 383
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The way you have configured JPA and used it in Glassfish, the optional transaction-type attribute of persistence-unit element is set to JTA (default value when used in a container). If you want to provide the URL as a property in persistence.xml, you should change the transaction-type to RESOURCE_LOCAL. They way it is now, to make it work, you need to create additional connection pool and jdbc resource with the correct URL, or change the default derby pool to point to the database you need it to. If you create a new pool, you also need to specify a jta-data-source element on persistence.xml with the name of you newly configured pool. If you edit the default derby pool, you don't have to do that.
Some properties are taken into account by TopLink even when JTa is used, as logging and db-schema generation. I suppose the reason your user ans password are picked up is because the glassfish team would like you to be able to specify a new pass and user, and override the server defaults, even if you use the default data source.
Hope this helps, it did the trick for me (changing derby to oracle xe, I created a new pool of course).
 
Jim Petersson
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok that makes sense.
I know that you can configure a new datasource using the Glassfish admin console, but I want to be able to deploy my app on a different computer/glassfish server. How can I make it so that my datasource configuration is included with the EAR file?
 
Raf Szczypiorski
Ranch Hand
Posts: 383
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would say you can't contain the data source definition within you EAR file. When you deploy, you first create all server object that your application depends on, in this case - the data source.
One thing you could do is to create an ant build file, that creates all the necessary objects using asant, and then in the end call asadmin deploy, also in the ant build file. The deploy target could depend on the creation targets, so that when sth fails, the app wouldn't be deployed.
reply
    Bookmark Topic Watch Topic
  • New Topic