I have deployed a Spring Web based application in WAS. So WEB-INF/lib contains lot of jar files. One of the jar file trying to load properties file. Means that java file loading test.properties file by using getClassLoader().getResource().
How to supply that test.properties to that jar file ?
Please help me.
Thank you.
Related
I compiled a Java application into a WAR file, there is a configuration file inside the WAR file. The configuration file is required to change something after deployed to the production server, because it still contains the UAT server parameters.
However, I don't know where to edit the configuration file after deployed in Tomcat. Please help. Thanks.
It doesn't sound like a correct design. You should -
Load configuration file based on some System parameter (e.g. -Denvironment=UAT or PROD). This will be the decision factor for loading the right configuration file.
Do not package the file inside war itself, if possible externalize it to some other directory where amending is lot easier.
I need to read a properties file located inside an ear. In jboss 5.1 I put the file in the root of the ear and it works, but in wildfly it doesn´t.
In wildfly, I managed to read the property file outside the ear according to this
http://blog.jyore.com/?p=58
But I haven´t found the way to do the same but with the file inside the ear. I´ve tried without success putting the file in the METAINF folder, also tried with the "Class-Path: ." in the manifest...
Please any ideas?? Do I have to put the file in any specific location??
I found the solution:
In WildFly 8, to get those properties available in the classpath, package them within your application. For example, if you are deploying a .war then package those properties in WAR WEB-INF/classes/ folder. If you want those properties accessible to all components in a .ear, then package them at the root of some .jar and place that jar in EAR lib/ folder.
https://docs.jboss.org/author/display/WFLY8/How+do+I+migrate+my+application+from+AS5+or+AS6+to+WildFly
Thanks for your help
I deployed a Java EE project thru a .war file and now it's uploaded online but the new File("directory") is missing. How to properly set the path of a file?
The current path is at
"/home/jebard/chabacano/Chabacano1/src/en-pos-maxent.bin"
After deploying your application can't access to your file system, it has an access only to content of .war file. So, to get access to some file you have to include it to .war archive while building.
I have war which working in production. I need to change the web.xml and again i need to make war file to deploy.Since we are changing xml file, so no need compliation at all..But i don't have source code to create war file again.
if change the xml file which will work again ? if yes how to create war file in command prompt ?
WARs are just zip files with .waras extension, so you just have to :
extract the WAR into some directory
replace web.xml in WEB-INF
zip the directory content into a file using the same filename than before.
BTW, try to deploy your repackaged WAR into some production-like environment to test if application is running like you want.
I created a Java project that contains three configuration file
log4j.XML
QueueConfig.xml
rabbitmq.properties
I put these three files into a resource folder.
Then I created a jar file of my project. This jar file is added to another project. It isn't able to find the correct location of the configuration files.
My file structure:
Thanks
you can use it like.
ClassFromWhichYouAreACcessingTheseFiles.class.getResources("resources/log4j.properties");
than if you add this jar to another project you will be able to access it.
If your config files end up in the WEB-INF/classes folder
ClassFromWhichYouAreACcessingTheseFiles.class.getClassLoader().getResources("log4j.properties");
otherwise it include the "package-path" from the ClassFromWhichYouAreACcessingTheseFiles