guy mograbi
guy mograbi

Reputation: 28598

Jetty Maven Plugin ignores my jetty.xml for no apparent reason

I am getting a bit frustrated from this Jetty Maven Plugin..

I am trying to configure the jetty-maven-plugin with my jetty.xml file. ( see below ).

I expect Jetty to start on port 8081.

However I keep getting 8080 in the console when I run

mvn jetty:run

I also expect to see a log print

Configuring Jetty from xml configuration file

Which I found in jetty-maven-plugin sources. But I don't see it anywhere.

I verified all the files are in the correct place and I tried numerous variations of the configuration so far.

My Maven configuration is :

...
<plugin>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>maven-jetty-plugin</artifactId>
    <version>${jettyVersion}</version>
    <configuration>                       
           <jettyConfig>${project.basedir}/src/main/resources/jetty.xml</jettyConfig>
    </configuration>
</plugin>
.....
<properties>
    <jettyVersion>7.2.0.v20101020</jettyVersion>
</properties>

and my jetty.xml file is :

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">

<Configure id="Server" class="org.eclipse.jetty.server.Server">
        <Call name="addConnector">
  <Arg>
      <New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
        <Set name="host"><SystemProperty name="jetty.host" /></Set>
        <Set name="port"><SystemProperty name="jetty.port" default="8081"/></Set>
        <Set name="maxIdleTime">300000</Set>
        <Set name="Acceptors">4</Set>
        <Set name="statsOn">false</Set>
        <Set name="confidentialPort">8443</Set>
    <Set name="lowResourcesConnections">20000</Set>
    <Set name="lowResourcesMaxIdleTime">5000</Set>
      </New>
  </Arg>
</Call>
</Configure>

I read almost every resource possible including all of stackoverflow's Q&A. I must be missing something.

Even though Eclipse document the configuration parameter for jetty.xml in the POM as "jettyXml" - I downloaded their source. It is most definitely "jettyConfig".

Looking at their code I see the following

public void applyJettyXml() throws Exception
    {
        if (getJettyXmlFile() == null)
            return;

        getLog().info( "Configuring Jetty from xml configuration file = " + getJettyXmlFile() );        
        XmlConfiguration xmlConfiguration = new XmlConfiguration(getJettyXmlFile().toURL());
        xmlConfiguration.configure(this.server);   
    }

And I am adding the implementation for the getter

public File getJettyXmlFile ()
{
    return this.jettyConfig;
}

So I expect at least to see the printing Configuring Jetty from xml... - but it does not appear as well..

I managed to override the port from the command line, but I am interested in the XML configuration.

Upvotes: 1

Views: 1997

Answers (3)

Varis
Varis

Reputation: 254

Rename jettyConfig to webAppXml.

Upvotes: 1

Erwan Leroux
Erwan Leroux

Reputation: 132

You should try to change the artifactid from

<artifactId>maven-jetty-plugin</artifactId>

to

<artifactId>jetty-maven-plugin</artifactId>

because the classes you use in jetty.xml are prefixed with org.eclipse.jetty introduced with jetty 7

Upvotes: 0

spiraleddy
spiraleddy

Reputation: 307

If you are still pursuing this, there are two things to try from http://wiki.eclipse.org/Jetty/Feature/Jetty_Maven_Plugin.

1) "You must be explicit enable Jetty extensions by adding a dependency on jetty-servlets"

<plugin>
...
    <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-server</artifactId>
        <version>7.2.0.v20101020</version>
    </dependency>
</plugin>

2) If you do step 1, instruct maven on the proper groupId by putting it (the org.mortbay.jetty, not org.eclipse.jetty) into settings.xml

<profile>
      ...
    <pluginGroups>
        <pluginGroup>org.mortbay.jetty</pluginGroup>
    </pluginGroups>
</profile>

Upvotes: 0

Related Questions