15

In order to easily run my webapp, I decided to add Jetty to my single POM file.

Following the official documentation, I added this to my <plugins>:

  <plugin>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-maven-plugin</artifactId>
    <version>9.4.0-SNAPSHOT</version>
  </plugin>

PROBLEM: mvn jetty:run fails:

$ mvn jetty:start
[INFO] Scanning for projects...
[WARNING] The POM for org.eclipse.jetty:jetty-maven-plugin:jar:9.4.0-SNAPSHOT is missing, no dependency information available
[WARNING] Failed to retrieve plugin descriptor for org.eclipse.jetty:jetty-maven-plugin:9.4.0-SNAPSHOT: Plugin org.eclipse.jetty:jetty-maven-plugin:9.4.0-SNAPSHOT or one of its dependencies could not be resolved: Could not find artifact org.eclipse.jetty:jetty-maven-plugin:jar:9.4.0-SNAPSHOT
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml
Downloading: https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml (13 KB at 2.1 KB/sec)
Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml (20 KB at 3.2 KB/sec)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.013 s
[INFO] Finished at: 2016-08-17T16:49:28+09:00
[INFO] Final Memory: 14M/307M
[INFO] ------------------------------------------------------------------------
[ERROR] No plugin found for prefix 'jetty' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/home/nico/.m2/repository), central (https://repo.maven.apache.org/maven2)] -> [Help 1]

Another approach at https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-maven-plugin/9.4.0.M0 suggests to add this in <dependencies>:

            <dependency>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>9.4.0.M0</version>
            </dependency>

It fails too, mvn jetty:start says:

[ERROR] No plugin found for prefix 'jetty' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/home/nico/.m2/repository), central (https://repo.maven.apache.org/maven2)] -> [Help 1]

I removed my .m2 folder and let Maven recreate it, no better. I have no settings.xml in ~/.m2 and here is the content of ~/.m2/repository/org/eclipse/jetty/jetty-maven-plugin/9.4.0.M0/:

-rw-rw-r-- 1 nico nico 101524  8月 24 17:29 jetty-maven-plugin-9.4.0.M0.jar
-rw-rw-r-- 1 nico nico     40  8月 24 17:29 jetty-maven-plugin-9.4.0.M0.jar.sha1
-rw-rw-r-- 1 nico nico   5526  8月 24 17:28 jetty-maven-plugin-9.4.0.M0.pom
-rw-rw-r-- 1 nico nico     40  8月 24 17:28 jetty-maven-plugin-9.4.0.M0.pom.sha1
-rw-rw-r-- 1 nico nico    215  8月 24 17:29 _remote.repositories

Note: There are several questions on the same topic, all have outdated answers containing Maven ids (mortbay, codehaus) dating from before Jetty moved to Eclipse, or suggest adding the <plugin> block seen at the top of my question.

Nicolas Raoul
  • 55,003
  • 52
  • 197
  • 338
  • Well, the Maven central DOES have this jar under the right path, I just checked. I assume your settings.xml file hasn't changed recently, or proxy settings, and that all your other dependencies download successfully. How about downloading it manually and putting it in your local repository under the right path? I don't want to be too quick to blame Maven, but I HAVE had times in the past where it seemed to behave very unpredictably. – Chris Neve Aug 29 '16 at 22:50
  • @ThomCunningham: I don't have a `settings.xml` file, at least not in `~/.m2`. I never had a proxy, just a direct Internet connection. I was going to follow your advice and download manually, and it made me realize that actually the files are already present, please see my edited post. Thanks a lot! – Nicolas Raoul Aug 30 '16 at 03:48

2 Answers2

22

You are using the Plugin version 9.4.0-SNAPSHOT. This version is not available in the central repo (available versions).

To add a dependency doesn't solve the problem because a dependency is not the same as a plugin. A dependency is used or required by the code you want to compile and a plugin is something that would compile, build or analyze your code.

In short:

  • you don't need a dependency on jetty-maven-plugin
  • you have to change the version of the plugin to a version which is available in the central or your local repo.
    For example:

    <plugin>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>
        <version>9.4.0.M0</version>
    </plugin>
    
Josef Reichardt
  • 1,270
  • 1
  • 16
  • 31
  • Indeed my app does not need Jetty to run, and I would better not see Jetty inside the .war file. Thanks a lot, I will try this! – Nicolas Raoul Aug 30 '16 at 06:09
  • Thanks a lot, @CptS. I will never understand how this "dependency resolver" works. For me it rarely solves anything. I always have to resolve all dependencies by hand, using the strangest and obscurest possible methods... PD: after adding this and waiting for another bunch of downloads, Eclipse keeps complaining about "no plugin for prefix 'jetty'"... – Pere Nov 22 '16 at 10:30
  • I found this to be a useful answer describing the difference is between a dependency and a plug-in (the latter of which I could never actually find a description of). But, what it does not explain is why a search for jetty maven plug-in takes one to the Maven site which lists it as a dependency ready to copy into the POM. Deleting the dependency and putting in the above plug-in worked for me. – Richard Bradley Smith Oct 26 '19 at 23:27
4

Please edit the settings.xml file in the local repository with the following information

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <localRepository>${user.home}/.m2/repository</localRepository>
  <interactiveMode>true</interactiveMode>
  <usePluginRegistry>false</usePluginRegistry>
  <offline>false</offline>
  <pluginGroups>
    <pluginGroup>org.mortbay.jetty</pluginGroup>
  </pluginGroups>
</settings>

It's working for me.

supi
  • 1,667
  • 16
  • 12