0

My current environment uses Linux, CentOS, WildFly 16. There are multiple datasources and it is all established externally in the standalone.xml. The application(s) in WildFly work just fine.

The issue I am dealing with is when I deploy the war file using command line interface (./bin/jboss-cli.sh) the application will use the existing datasource and I would like to change the datasource. For example App1.war uses MySqlDS1 datasource and App2_test.war uses MySqlDS2 datasource. I plan to overwrite App1.war with App2_test.war. The code will be mv App2_test.war App1.war . At that time the App1.war will be pointed to MySqlDS2 datasource, I believe since it now contains the App2_test code - that is the issue.

I need to change the App2_test.war file to point to MySqlDS1. I need to find the file that associates the URL to the datasource in the standalone.xml - I believe. I looked into web.xml but it does not exist in my war file and may not be provided in releases above EAP 6. I also looked into jboss-web.xml but unable to find file. I only have Manifest.mf in /META-INF and nothing in /WEB-INF/lib.

What file needs to be updated?

  • Does your code have `@PersistenceContext` annotations? Normally this is stored in `META-INF/persistence.xml` but that's not a requirement. – stdunbar Sep 23 '20 at 15:05
  • Unfortunately there is no `persistence.xml`. In the `META-INF` directory, only `MANIFEST.MF` is available. – ShedSomeLight Sep 23 '20 at 15:19
  • So the code must have the annotations. This is a bit of a pain as you need to change the code to change persistence providers. – stdunbar Sep 23 '20 at 15:58
  • I understand the `jboss-web.xml` or `web.xml` file would provide the . However I do not see the relation between the WAR file and its datasource, specifically if there are different applications on the server and each have there own database. Maybe I just can't find the existing annotation. – ShedSomeLight Sep 23 '20 at 20:13
  • I found the missing .class files under ImportedClasses. These class files xxServet.class contain the annotations of the hardcoded datasource I was looking for and just what @stdunbar stated. The code is ` @javax.annotation.Resource(lookup="java:jboss/datasources/MySqlDS2")`. Now may I update these class files with the new datasource name? Should I download javax.annotation.jar online and add to my library? Or perhaps use another method. – ShedSomeLight Sep 24 '20 at 18:07

0 Answers0