26

I'm trying to use jetty to host a simple helloworld servlet using maven. I'm very confused.

I followed these instructions, but when I issue mvn jetty:run, I get the following error:

[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 (/Users/abc/.m2/repository), central (http://repo.maven.apache.org/maven2)]

To add to the confusion, when I search the web for examples, some are referring to org.mortbay.jetty, and others to org.eclipse.jetty. I thought that the Eclipse version is the most recent, no?

Is there any documentation that describes what each of the dependencies hosted on maven repo mean? And how they can be used?

After modifying the version number to 9.0.0.v20130308, I get a different error:

Unable to load the mojo 'run' in the plugin 'org.eclipse.jetty:jetty-maven-plugin:9.0.0.v20130308' due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: org/eclipse/jetty/maven/plugin/JettyRunMojo : Unsupported major.minor version 51.0

Here is my updated pom:

<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>com.neon.research</groupId>
        <artifactId>jetty</artifactId>
        <packaging>war</packaging>
        <version>1.0-SNAPSHOT</version>
        <name>jetty Maven Webapp</name>
        <url>http://maven.apache.org</url>
        <properties>
                <jetty.version></jetty.version>
        </properties>
        <dependencies>
                <dependency>
                        <groupId>org.eclipse.jetty.orbit</groupId>
                        <artifactId>javax.servlet</artifactId>
                        <version>3.0.0.v201112011016</version>
                        <scope>provided</scope>
                </dependency>
        </dependencies>

        <build>
                <plugins>
                        <plugin>
                                <groupId>org.eclipse.jetty</groupId>
                                <artifactId>jetty-maven-plugin</artifactId>
                                <version>9.0.0.v20130308</version>
                        </plugin>
                        <plugin>
                                <artifactId>maven-compiler-plugin</artifactId>
                                <configuration>
                                        <source>1.6</source>
                                        <target>jsr14</target>
                                </configuration>
                                <executions>
                                        <execution>
                                                <id>test-compile</id>
                                                <phase>process-test-sources</phase>
                                                <goals>
                                                        <goal>testCompile</goal>
                                                </goals>
                                                <configuration>
                                                        <source>1.6</source>
                                                        <target>1.6</target>
                                                </configuration>
                                        </execution>
                                </executions>
                        </plugin>
                </plugins>
        </build>
</project>
Nathaniel Ford
  • 20,545
  • 20
  • 91
  • 102
hba
  • 7,406
  • 10
  • 63
  • 105
  • did you specify the plugin groupId ? – ben75 Mar 13 '13 at 13:51
  • Yes - here is what i have: org.eclipse.jetty jetty-maven-plugin 9.0.0 – hba Mar 13 '13 at 14:43
  • The version is incorrect, please see my updated answer and comment. – andyb Mar 13 '13 at 15:08
  • 2
    You have a version mismatch with Java now. Jetty 9 requires Java 1.7 – andyb Mar 15 '13 at 08:27
  • Thanks andyb. I installed 1.7 and now it is working. I have no idea how you knew it was a java version :-) – hba Mar 16 '13 at 00:49
  • An error like `Unsupported major.minor version 51.0` always indicates a Java version mismatch - see http://stackoverflow.com/questions/10382929/unsupported-major-minor-version-51-0 – andyb Jan 22 '14 at 10:06

3 Answers3

23

Jetty has moved around a lot - see the History. Eclipse is the most recent home, as of 2009. The Maven artifacts have been renamed along the way, so your searches are finding documentation for older versions of Jetty and the maven plugin.

The latest (v9) jetty-maven-plugin documentation lists the dependency as:

<plugin>
  <groupId>org.eclipse.jetty</groupId>
  <artifactId>jetty-maven-plugin</artifactId>
  <version>9.0.0.v20130308</version> <!-- latest at time of writing -->
</plugin>

The other libraries like jetty-continuation or jetty-jsp are just sub-modules of the Jetty Project. Some documentation exists on the older wiki for Jetty 7 and 8 but I cannot see anything updated for v9 yet. The modular design is the Jetty developer's organisation of their code into well defined modules which have all been made available separately for developers that may want to use just want a small part of Jetty.

andyb
  • 43,435
  • 12
  • 121
  • 150
  • Jetty 9 documentation is here: http://www.eclipse.org/jetty/documentation/current/ – jesse mcconnell Mar 13 '13 at 14:02
  • @jessemcconnell thanks, I have linked to that already. I was attempting to explain that there is nothing like the old wiki documentation for v9. No dependency diagram page and no separate page for [Continuations](http://wiki.eclipse.org/Jetty/Feature/Continuations) for example. – andyb Mar 13 '13 at 14:04
  • I see that, we are still pulling documentation over into the docbook setup which can be contributed to at github (links of bottom of pages). Anything missing you would like added please open a bug at bugs.eclipse.org under RT and we'll get it in...or contribute it :) – jesse mcconnell Mar 13 '13 at 14:10
  • 1
    @adnyb thanks. I'm not sure what I'm missing because I set up my plugin like you've described. I've also indicated the version to be 9.0.0. – hba Mar 13 '13 at 14:45
  • Ah, it's your version that is wrong! It should be one of the versions [listed here](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.eclipse.jetty%22%20AND%20a%3A%22jetty-maven-plugin%22). The most recent is `9.0.0.v20130308` – andyb Mar 13 '13 at 14:49
  • @jessemcconnell Thanks for the update and work on Jetty. I guessed the new (and very nice looking) documentation was work in progress :-) – andyb Mar 13 '13 at 14:54
  • 1
    @andyb - thank you for the followup. I tried your suggestion, but now I'm getting a different error. I've updated the new error and pom file. – hba Mar 15 '13 at 07:37
  • 3
    You have a version mismatch with Java now. Jetty 9 requires Java 1.7 – andyb Mar 15 '13 at 08:25
3

The eclipse version is the more recent one. Follow the instructions on their site.

carlspring
  • 31,231
  • 29
  • 115
  • 197
0

Here is the working config for me. Uses the latest Jetty version.

<plugin>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-maven-plugin</artifactId>
    <version>9.4.0.v20161208</version>
    <configuration>
        <scanIntervalSeconds>0</scanIntervalSeconds>
        <contextXml>${basedir}/src/it/resources/jetty-context.xml</contextXml>
        <webApp>
            <contextPath>/yourContextPath</contextPath>
        </webApp>
        <contextHandlers>
        <contextHandler implementation="org.eclipse.jetty.webapp.WebAppContext">
            <war>your/path.war</war>
            <contextPath>/yourPath</contextPath>
        </contextHandler>
        </contextHandlers>
        <classesDirectory></classesDirectory>
        <webAppSourceDirectory></webAppSourceDirectory>
    </configuration>
</plugin>
Deepu Sahni
  • 479
  • 5
  • 9