简体   繁体   中英

Tomcat 7 maven build failed with Jersey

I am trying to setup maven project with Jersey 2.5 in eclipe Luna.

Here is may pom.xml

   <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">
  <modelVersion>4.0.0</modelVersion>
  <groupId>MavenTest</groupId>
  <artifactId>Jersey Project</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>MC-Server Maven Webapp</name>

  <url>http://maven.apache.org</url>   

      <pluginRepositories>
        <pluginRepository>
        <id>apache.snapshots</id>
        <name>Apache Snapshots</name>
        <url>http://people.apache.org/repo/m2-snapshot-repository</url>
        <releases>
        <enabled>false</enabled>
        </releases>
        <snapshots>
        <enabled>true</enabled>
        </snapshots>
        </pluginRepository>
    </pluginRepositories>


    <build>
    <finalName>MavenJerseyTest</finalName>   

    <plugins>        
        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.1</version>    
        </plugin>                     
    </plugins>    

  </build>

  <dependencies>
  <dependency>
 <groupId>org.glassfish.jersey.containers</groupId>
 <artifactId>jersey-container-servlet</artifactId>
 <version>2.5.1</version>
</dependency>
  </dependencies>

</project>    

When I build it

[INFO] Scanning for projects...
[WARNING] The POM for org.apache.tomcat.maven:tomcat7-maven-plugin:jar:7 is missing, no dependency information available
[WARNING] Failed to retrieve plugin descriptor for org.apache.tomcat.maven:tomcat7-maven-plugin:7: Plugin org.apache.tomcat.maven:tomcat7-maven-plugin:7 or one of its dependencies could not be resolved: Failure to find org.apache.tomcat.maven:tomcat7-maven-plugin:jar:7 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
[INFO] Downloading: http://people.apache.org/repo/m2-snapshot-repository/org/apache/maven/plugins/maven-metadata.xml
[INFO] Downloading: http://people.apache.org/repo/m2-snapshot-repository/org/codehaus/mojo/maven-metadata.xml
[WARNING] Could not transfer metadata org.apache.maven.plugins/maven-metadata.xml from/to apache.snapshots (http://people.apache.org/repo/m2-snapshot-repository): connect timed out
[WARNING] Could not transfer metadata org.codehaus.mojo/maven-metadata.xml from/to apache.snapshots (http://people.apache.org/repo/m2-snapshot-repository): connect timed out
[INFO] Downloading: http://people.apache.org/repo/m2-snapshot-repository/org/codehaus/mojo/tomcat-maven-plugin/maven-metadata.xml
[WARNING] Could not transfer metadata org.codehaus.mojo:tomcat-maven-plugin/maven-metadata.xml from/to apache.snapshots (http://people.apache.org/repo/m2-snapshot-repository): connect timed out
[INFO] 
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building MC-Server Maven Webapp 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for org.apache.tomcat.maven:tomcat7-maven-plugin:jar:7 is missing, no dependency information available
[WARNING] Failed to retrieve plugin descriptor for org.apache.tomcat.maven:tomcat7-maven-plugin:7: Plugin org.apache.tomcat.maven:tomcat7-maven-plugin:7 or one of its dependencies could not be resolved: Failure to find org.apache.tomcat.maven:tomcat7-maven-plugin:jar:7 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
[WARNING] Failure to transfer org.apache.maven.plugins/maven-metadata.xml from http://people.apache.org/repo/m2-snapshot-repository was cached in the local repository, resolution will not be reattempted until the update interval of apache.snapshots has elapsed or updates are forced. Original error: Could not transfer metadata org.apache.maven.plugins/maven-metadata.xml from/to apache.snapshots (http://people.apache.org/repo/m2-snapshot-repository): connect timed out
[WARNING] Failure to transfer org.codehaus.mojo/maven-metadata.xml from http://people.apache.org/repo/m2-snapshot-repository was cached in the local repository, resolution will not be reattempted until the update interval of apache.snapshots has elapsed or updates are forced. Original error: Could not transfer metadata org.codehaus.mojo/maven-metadata.xml from/to apache.snapshots (http://people.apache.org/repo/m2-snapshot-repository): connect timed out
[WARNING] Failure to transfer org.codehaus.mojo:tomcat-maven-plugin/maven-metadata.xml from http://people.apache.org/repo/m2-snapshot-repository was cached in the local repository, resolution will not be reattempted until the update interval of apache.snapshots has elapsed or updates are forced. Original error: Could not transfer metadata org.codehaus.mojo:tomcat-maven-plugin/maven-metadata.xml from/to apache.snapshots (http://people.apache.org/repo/m2-snapshot-repository): connect timed out
[INFO] 
[INFO] >>> tomcat-maven-plugin:1.1:run (default-cli) @ MC-Server >>>
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MC-Server ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is plat
form dependent!
[INFO] Copying 3 resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ MC-Server ---
[INFO] No sources to compile
[INFO] 
[INFO] <<< tomcat-maven-plugin:1.1:run (default-cli) @ MC-Server <<<
[INFO] 
[INFO] --- tomcat-maven-plugin:1.1:run (default-cli) @ MC-Server ---
[INFO] Running war on http://localhost:8080/MavenJerseyTest
[INFO] Creating Tomcat server configuration at /myprojects/maven/MavenJerseyTest/target/tomcat    

This seemed to be not working with tomcat 7, but 6.

Any one let me know where I have gone wrong ? (This same project structure could be built as a noraml web project in eclipse and worked calm, also there are same question like this , but I tried them, not working.. I changed the tomcat plugin version as 2.1 which was suggested as an answer in another question, it also not worked.. )

This can't be because of the Jersey. Change the pom.xml for tomcat plugin

<plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.2</version>
        </plugin>   

and for tomcat goal : tomcat7:redeploy

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM