Joan S wrote:
... is that the project was developed to read the connection string of the database from a XML file that should be located in the root of the server, ..
That is not a portable solution. The usual way of doing this is to
- define a datasource in the application server configuration (all enterprise java application servers and even Tomcat support doing this);
- inject the javax.sql.DataSource into your code where needed or perform a JNDI lookup to get it;
- acquire your java.sql.Connection object from the DataSource.
As you mention that you're new to this I recommend that you have a look at The Java EE 6 Tutorial.
Thank you Stephen, the thing with this project is that it's a little bit old, everything that has to do with the database connection is made in a library which code we don't have (long story, but somebody left this library without the source code), so if I have to change the way this app connects to a database, this means decompiling the library, made the changes, re-compile everything and make the changes in the app that uses this library, if I have no choice I would have to make all the changes, but first I'd like to discard the option in which the app continue working as it works now, this is, reading the database connection from the .xml file.
Thank you very much!
The first thing we need to find out is how the code is accessing the file. ie. Is it:
- trying to open the file using java.io.File classes
- or trying to access the file as a class loader resource
If the first then you may need to do some decompiling to work out how it's deriving the path to the file.
If it's the second then Loading resource file from ear-file might be helpful.
Is there any kind of stack trace when it fails?