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
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).
Joined: May 28, 2008
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?
Joined: Aug 21, 2008
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.