0

I am fairly new to JPA and in my project the applciation server is Glassfish 3.1.2 .So when i encountered persitence.xml in my project ,I have gone through http://en.wikibooks.org/wiki/Java_Persistence/Runtime to get basic idea of how it is used in JavaSE and JavaEE. However i came across few properties that are configured via ${}.

<jta-data-source>${dataSource}</jta-data-source>  
<property name="javax.persistence.jdbc.user" value="${testDBUser}" />

So i am confused where these variables (dataSource,testDBUser..etc) are defined. And so i have gone through this http://tomee.apache.org/configuring-persistenceunits-in-tests.html and http://forcedotcom.github.io/java-sdk/connection-url. I understood that these are either system varibales and environmental variables / initial context variables.

However i do not know where they are configured/declared ,i searched my entire project for these variables but of no luck.

Are these variables are configured during the start-up of the application server / are they declared in any *.xml of the application server.

Can you please brief where these are declared?

chebus
  • 762
  • 1
  • 8
  • 26

1 Answers1

0

It is usually are declared in .properties file. Mainly, it can be named like database.properties. But it is not enough to make it work. You need somehow to map it. So, Spring takes a role and offer a nice way to make it : use PropertyPlaceholderConfigurer and syntax is something like this:

    <property name="location">
        <value>HERE DECLARE YOUR PROPERTY FILE</value>
        <value>HERE DECLARE YOUR PROPERTY FILE</value>
                      ...
    </property>

But the best way is to declare it in your server.xml :)

user3252538
  • 110
  • 1
  • 9
  • Thanks for the response. Spring is not used in my project. EJB,JPA with Glassfish webserver. I checked entire project (which included .properties files as well) but i did not come across the variables. However can you tell what is server.xml ? You mean to say application.xml in application server ? – chebus Feb 28 '14 at 07:03
  • Try to find if project has ResourceLink, also try this: http://stackoverflow.com/questions/12655842/configuring-a-mysql-datasource-in-glassfish-3-application-server – user3252538 Feb 28 '14 at 07:11