This may have been asked before (if it is please link me), but when I search I'm finding a bunch of how to run maven on tomcat, how to hook up an IDE to do this (nearly all of them are ide / configuration questions), how to use maven plugin in tomcat, etc related questions.
I know I can use an IDE like intellij or eclipse to create a web app project with maven, and tomcat and they will just run because of the settings configurations. I'm playing around and trying to see how to do it manually (hopefully to learn something).
Right now I have a running tomcat project. Essentially I downloaded tomcat 8 from http://tomcat.apache.org/. I then pulled the example files, and have it running my own files.
I want to wrap this in maven.
I created a typical maven project (example):
. |____WebApp | |____pom.xml | |____src | | |____main | | | |____resources | | | |____webapp | | | | |____index.jsp | | | | |____WEB-INF | | | | | |____web.xml
Where do I put my tomcat file? in webApp?
To run tomcat I am using
From my tomcat file. Can I run it from my pom, or would I need to create a java file to call it somehow?
If I do it in Intellij (through the automated creation process) it all runs. But I can't figure out how each file is linked other than through .idea related means. There is no tomcat file for example. No server.xml that I can see although it is referenced in the pom.xml.
<plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat6-maven-plugin</artifactId> <version>2.3-SNAPSHOT</version> </plugin> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.3-SNAPSHOT</version> <executions> <execution> <id>tomcat-run</id> <goals> <goal>exec-war-only</goal> </goals> <phase>package</phase> <configuration> <path>foo</path> <!-- optional, needed only if you want to use a preconfigured server.xml file --> <serverXml>src/main/tomcatconf/server.xml</serverXml> <!-- optional values which can be configurable --> <attachArtifactClassifier>default value is exec-war but you can customize</attachArtifactClassifier> <attachArtifactClassifierType>default value is jar</attachArtifactClassifierType> </configuration> </execution> </executions> </plugin>
But in this case it's a plugin which appears to be slightly different than I'm doing (correct me if that's wrong, I'm new to maven / tomcat)
My interpretation of what is going on in intellij is that the maven project is being run on tomcat. Where as I want to use maven to run my tomcat project that has its own files. (if you can explain this better or correct me here, I would be very appreciative) They both reference in some way the server.xml file.
------ EDIT Ok so I reread: mkyong.com/maven/how-to-deploy-maven-based-war-file-to-tomcat
I believe that running my tomcat catalina.sh in my tomcat file (as downloaded from apache example) will allow me to keep my paths. The problem I am struggling with is the following:
<plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat6-maven-plugin</artifactId> <version>2.2</version> <configuration> <url>http://localhost:8080/manager</url> <server>TomcatServer</server> <path>/mkyongWebApp</path> </configuration> </plugin>
The way that the example uses tomcat is by using it as a plugin. This means that it will never read my tomcat file. How do I get it to run my local tomcat file.