I am building a webapp through Gradle's war plugin. In order to disable Tomcat's session persistence, I need to place the file context.xml in the META-INF directory of the war's root.
I attempted the following:
Create the file src/main/webapp/META-INF/context.xml of the main project
Create the file src/main/resources/META-INF/context.xml of the main project
However, when I build the project using gradle clean war, the produced war file contains a META-INF with only a MANIFEST.MF in it. It is as if my directory gets overridden.
How do I place context.xml in the war?
src/main/webapp/META-INF/context.xml is correct and works fine for me. Chances are that you went wrong somewhere, or that there is a problem with your build script.
Related
I would like to deploy a mock service developed with SoapUI. I have SoapUI project, web.xml and now I would like to add them to WAR archive. I'm using Gradle to prepare this WAR file.
My code below:
war {
archiveName 'mock.war'
webXml file ('src/main/webapp/web.xml')
}
Default filesystem of produced archive is:
META-INF
WEB-INF
lib
some libs...
classes (this folder I would like to rename to 'soapui')
some files...
web.xml
Is there any possibility, to change the name of 'classes' folder?
Thanks in advance,
Patryk
I have a folder named webapps inside my src/main/app in mule project. This webapps folder contains a war which is exposed in mule-config.xml through jetty connector. I tried lot of combinations in my maven build but this webapps folder ends up inside classes in zip file. I want it right inside zip.
Any pointers how to achieve it in pom?
Try using the maven ant plugin.
File can be moved around after compilation and before packaging.
phase: prepare-package (just before packing)
https://maven.apache.org/guides/mini/guide-using-ant.html
Hope this helps.
Since couldn't get maven to build zip file in a way that it would copy webapps folder directly under root. I ended up placing webapps folder containing war file inside src/main/resources. Maven build copied webapps folder under classes. And the mule-config referred it as
<jetty:connector name="Jetty" doc:name="Jetty">
<jetty:webapps port="${jetty.port}" host="${jetty.host}" directory="${app.home}/classes/webapps" />
</jetty:connector>
I'm developing a spring project and I've just encountered serious problems with loading XML config files within junit (but they are accessible from the web controllers) - can't load XML files.
I listed my classpath (in junit tests) and found that, among the rest, there are 2 directories included:
/var/www/Java/lyricsBase/build/web/WEB-INF/classes/
/var/www/Java/lyricsBase/build/test/classes/
There is just one file I want to include in my test:
/WEB-INF/lyricsBaseApp-servlet.xml
and it imports 3 files below:
/WEB-INF/hibernate.xml
/WEB-INF/dataSource.xml
/WEB-INF/beans.xml
I can clearly see that deploying my project on tomcat copies confg files to /var/www/Java/lyricsBase/build/web/WEB-INF/ABC.xml but this directory is not in the classpath, /var/www/Java/lyricsBase/build/web/WEB-INF/classes is included instead. I read that WEB-INF should not be in the classpath (it's just a Java EE principle). OK - so where should I put my config files to access them easily both from web controllers and junit tests? Any good practices?
Place the config files under WEB-INF/classes on the war package, and they will be loaded into the classpath. Consider deploying your code as an exploded war, so the config files can be changed easily.
Also consider using maven war project for your packaging. If you do, you can just place your config files under src/main/resources under the source code, and they will be packaged into WEB-INF/classes for you.
I had the same problem and from then on started putting them in META-INF under resources. This is where the spring template projects which don't run in Tomcat put them and seemed to solve my issues.
I have a Maven project. It is successfully deploying the jar file. I also want it to deploy the contents of src/main/resources.
mvn deploy does not deploy the resources.
How can I make it do that?
I read about using the copy file task and other workaround methods, but I want to use Maven's default behavior for deploying, which I thought would include the resources.
The folder src/main/resources contains resources which will be packaged into the jar file which means in other words it is already deployed within the created jar file.
I am using Maven for creating my project structure. The following is the way I am doing
Generate Archetype
Have the following modules - Ear, War and WarSource (I am deleting the src, ejb and jar folders)
So my EAR will have 2 modules - War and WarSource which inturn have src/main/java and src/main/resource folders
Question is - where should my application context reside so that I avoid the File Not Found error during runtime.
Thanks
If you're using spring mvc it will be in the war src/main/webapp/WEB-INF/ directory. Also if you're using spring you may not even need an ear file, you should read up on that to be sure you're not adding unnecessary complexity.