In Java EE (happens to be WAS 6.1, but can be any application server) I need to put an XML file, which is a configuration file, so that I can read and write to it.
This should be available in a clustered environment, so I am considering using a class path to upload a file.
I think I can store this file in the root of the EAR, reference it in the manifest, and then load and save it.
I tried this approach by installing my file in the JAR and making it accessible via MANIFES, and I can load the configuration file from the class path without problems using the following.
this.getClass().getClassLoader().getResourceAsStream("configFileName");
This uploads a file that is in a JAR, which is fantastic. But if I want to edit this file programmatically, I can’t access the JAR file (the root of the EAR), it returns me the interpreted path as follows:
/usr/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/localhostNode01Cell/MyApp.ear/MyApp.war/TB_config.jar
This is the wrong JAR location, the correct location is in MyApp.ear.
So the question is: how can I access and update (copy content, create new, save, delete old) JAR with my configuration file. Or should I put the configuration file in another place?
What is the standard Java EE for creating files that require read / write access, available for WAR in a cluster?