I have a war project. A few static HTMLs need to be copied into the webapp folder before building war. To achieve this, added maven-resources-plugin copy-resources goal (process-resources phase). This is working fine as I can see the built war includes the copied files.
When I run this war using mvn tomcat7:run the path is not recognised (404).
However, when I deploy the war into a tomcat server, the path is accessible.
Any thoughts? Looks like tomcat7 plugin does not use the built war but accesses the files directly from src folder. Is this a bug or just how tomcat7 plugin works?
Have you tried using the additionalClasspathDirs param? from https://tomcat.apache.org/maven-plugin-2.2/tomcat7-maven-plugin/run-mojo.html
additionalClasspathDirs:
Additional optional directories to add to the embedded tomcat classpath.
Type: java.util.List
Since: 2.0
Required: No
if that doesn't work you can use maven-antrun-plugin see how to copy a file to tomcat webapp folder using maven?
Related
I am developing a web application consisting of the following structure:
enter image description here
When i execute mvn clean package, there is no file in webapp packaged into the jar.
If you are using jar as the packaging structure , put all your static resources under src/main/resources/static and it will automatically get copied into the final jar when you use the command mvn clean install. The webapp folder structure is suitable for war deployment. When the packaging is war , maven will look for the webapp folder and copy it's contents to the resulting war package.
I have been reading about building rpm from war files & use them for installation. As part of it I downloaded sample war and trying to create rpm. My tomcat version is 7.0. I ran rpmdev-setuptree which creates the directory hierarchy needed for rpm build. All I intend to do by installing the rpm is : stop tomcat, delete the sample.war & sample folder from webapps, copy new war to webapps & start tomcat. Can I accomplish it? or rather I would like to know, is this the correct way of using rpm build from the war? Or am I missing something?
If you are using maven you can use the RPM maven plugin
I've build a spring-based web project in Eclipse using Maven. Dependencies and class path are correct and the deployment assembly also lists spring-web*.jar correctly. However, when I deploy it using WebSphere 8 from within Eclipse the mentioned JAR file is missing from the created libs folder under .metadata.plugins\org.eclipse.wst.server.core\tmp2*\WEB-INF\lib . This JAR however is listed under the module section as a submodule for the container. I wasn't able to find out, why this JAR is listed there and why it is not copied to the LIB folder.
It works with a Tomcat server, it works when I export the WAR and deploy it manually and it also works when I manually copy the JAR to the lib folder.
Q1: Is this specific to Websphere?
Q2: Why is SPRING-WEB listed as submodule and what effect has this?
Q3: How can I automatically deploy it correctly?
This seems to be a bug in WAS as reported here
You can either copy the missing JARs manually or you can use the "Run server with resources on server" option in the "Publishing settings for WebSphere Application Server" server settings.
When i make the war i see the XCV.Jar, but I add the project on Tomcat (IDE eclipse), and when I deploy it, I have all jars except XCV.Jar (This jar is the parent of the project I deployed).
When you deploy to Tomcat from Eclipse it often fails to clean up the work directory directory. Try to clean $TOMCAT_HOME/work/Catalina// and the web apps directory then try redeploying.
If you are running tomcat inside eclipse you're asking for trouble. Its often better to build and validate the .war independently(with ant or maven) then deploy manually or with a script.
I'm using SubClipse for Eclipse for my project.
And in this project I've added my own package "com.mytestpkg.www"
I then use TortoiseSVN to deploy my project on the TomCat server where the project is running, because i the easily can update the site with "SVN Update".
But using this method I always have to manually update my package by copying it from my Eclipse workspace build path to the WEB-INF folder classes/com/mytestpkg/www.
Is there a way to make Subclipse/SVN update this file directly with the other files?
Why don't you do this a more conventional way; e.g.
get Eclipse to create and deploy a WAR file
use Ant or Maven to build the WAR file and deploy it by hand. (The Maven way of building WAR files is really slick!)
Doing a checkout into a Tomcat server's webapps directory is ... weird. And you've got the problem of stopping the world seeing the .svn directories.