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
Related
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.
I have following configuration:
Wildfly 8.1.0
multi-domain environment
in each domain I've deployed the same EAR, but with different INI files
EAR contains Configuration.jar with config.ini file and RestWS.war with WEB-INF/classes/shiro.ini
I would like to protect these INI files from overwriting. Is it possible to specify external files instead of these from EAR?
The article How to put an external file in the classpath describes how to do this.
Question 1: May I ask what is the difference between deploying a java webapp with it's WAR file vs just copy/pasting the build folder into tomcat webapp folder?
Question 2: Somehow I am told to deploy my project just by renaming my /build/web folder to /build/, then copy and paste this folder into tomcat/webapp folder. Tomcat did serve the web app and I could access it via url. But the problem is that I suspect my System variables were not set. I start up a servlet and put this code in this init(ServletConfig config) method:
System.setProperty("LogPath","D:/Test/logs");
And doing this in my log4j.properties
log4j.appender.file.FILE=${LogPath}/wrapper.log
wrapper.log is not found in the designated directory but a stdout.log is found in tomcat/logs folder.
I am sure the init() method was fired because I have a quartz scheduler there. I am suspecting that my System.setProperty was not set. Any hint?
Update: With all the same source code, I have no problem if I am deploying with a WAR file. The ${LogPath} in log4j.properties work as expected.
Let me answer you the first question.
WAR file is a zip archive with different name. When you deploy this file to the Tomcat server, it unpacks this file to its folder as you would do it by copy-paste. If you are just developing your own project in your own environment and you don't want to distribute it, you don't need to create a war file. But if you want to distribute this project, I recommend you to create a war file. One file is easier to be sent.
Read more on Wikipedia http://en.wikipedia.org/wiki/WAR_%28file_format%29
I'm porting a app that ran in tomcat to Jboss where it will be deployed as a .WAR file. I have a line of code that looks for a configuration .xml file :
appContext = new ClassPathXmlApplicationContext("cmdAppContext.xml");
Now I tried putting it in WEB-INF/classes (After comparing with eclipse generated .WAR file), and also tried the WEB-INF folder as it was referred in that location in the web.xml. However each time I get a NullPointerException. Am I missing anything here?
Please note: I've already seen the similar question in forums which was not resolved
It's not a good idea to look into context.xml from source code. You should use a .properties file to configure your app. .WAR is like a .ZIP file with all sites files inside, so META-INF are inside at root folder from .WAR.
folks,
i am trying to deploy a ear with a ejb in the ear root. the ejb has a persistence.xml file where the tag has to be a jar file in the Glassfish's domain lib. (this i have put it there because the jar is used across ears)
so what exactly should be the content of the <jar-file>*****/myjar.jar</jar-file> tag, for the jar in the glassfish's domain lib directory.
thanks fr yure time,
rajan.
The path should be either an absolute path to a JAR (not recommended) or the simple file name for a JAR inside the EAR deployment file. So, assuming you have an EAR with the jars "ejbs.jar", "jpa.jar" and "myjar.jar", the <jar-file> tag in jpa.jar for myjar.jar should be:
<jar-file>myjar.jar</jar-file>