So I've been struggeling with this for hours, till I found one ultimate solution to run and debug a tomcat servlet in Eclipse, so here it is:
First a parent pom should look something like this:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.nu.art.software</groupId> <artifactId>nu-art-maven-deploy-project</artifactId> <version>0.0.1</version> </parent> <groupId>com.nu.art.software</groupId> <artifactId>tomcat-servlet-maven-parent</artifactId> <version>0.0.1</version> <packaging>pom</packaging> <name>Tomcat Servlet Parent Pom</name> <dependencies> <dependency> <groupId>org.apache.tomcat</groupId> <artifactId>tomcat-catalina</artifactId> <version>7.0.27</version> <scope>provided</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>tomcat-maven-plugin</artifactId> <version>1.1</version> <configuration> <webXml>src/main/webapp/WEB-INF/web.xml</webXml> </configuration> </plugin> </plugins> <finalName>${project.name}</finalName> </build> </project>
Note the location of the web.xml & project name...
Next is the child project pom, which should like something like this:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <parent> <artifactId>tomcat-servlet-maven-parent</artifactId> <groupId>com.nu.art.software</groupId> <version>0.0.1</version> </parent> <modelVersion>4.0.0</modelVersion> <groupId>com.nu.art.software.cyborg.androidServicesUtility</groupId> <artifactId>android-services-utility-server</artifactId> <packaging>war</packaging> <version>0.1.0</version> <name>Android-Services-Utility-Server</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>com.nu.art.software.arttpServer</groupId> <artifactId>arttp-servlet</artifactId> <version>0.0.1</version> <scope>compile</scope> </dependency> <dependency> <groupId>com.nu.art.software</groupId> <artifactId>dbator</artifactId> <version>0.0.1</version> <type>jar</type> <scope>compile</scope> </dependency> <dependency> <groupId>com.nu.art.software.cyborg</groupId> <artifactId>cyborg-crash-report-core</artifactId> <version>0.0.1</version> <type>jar</type> <scope>compile</scope> </dependency> <dependency> <groupId>com.nu.art.software.cyborg.server</groupId> <artifactId>cyborg-server-module-crash-report</artifactId> <version>0.0.1</version> <type>jar</type> </dependency> <dependency> <groupId>com.nu.art.software.cyborg.server</groupId> <artifactId>cyborg-server-module-c2dm</artifactId> <version>0.0.1</version> <type>jar</type> </dependency> </dependencies> </project>
And finally goto Project -> Properties -> Deployment Assembly, And remove all the content from it. Add the following folder to the assembly: target/${project.name}
This would result in debugging the latest servlet build by Maven. so in order to launch it install your project, and Run/Debug on server...
NOTE!!!
This is not a perfect working setup, but if you are struggling with the bugger, and want to be able to quickly evaluate your project, this works fine.
Why do the parent and child use diferent xsi:schemaLocations?
ReplyDeleteHa... didn't even notice...
DeleteIt seems though that it still work, there are multiple references to the same schemaLocation.
This glitch is probably dragged from the first days of my Maven development, and has no effect on the outcome...
I have seen the same thing on lots of other blogs - the parent pom uses http://maven.apache.org/xsd/maven-4.0.0.xsd and the child poms use http://maven.apache.org/maven-v4_0_0.xsd. Maybe it was a mistake one person made years ago that has been copy-pasted all over the Internet. If there is a reason for it, I can't figure it out.
Delete