Details
Description
Hi everyone!
I think I may be facing a strange bug using jetty embedded with the maven-jetty-plugin version 6.1.3 and 6.1.4rc0.
I try to use a specific jetty configuration file into my main pom.xml. I know that if I configure jetty through the Pom.xml file everything works great.
But when I use a specific jetty.xml file, somehow it configuration is not applied and the server start on the default jetty.port 8080.
Here is an example of my pom.xml:
<project>
....
<build>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.4rc0</version>
<configuration>
<!-- the specific jetty configuration file I would like to use: -->
<jettyConfig>$
\src\etc\jetty.xml</jettyConfig>
<!-- It works great with the configuration bellow but I prefer a to use a jetty.xml file so it is put as comments-->
<!-- <contextPath>/test</contextPath>
<scanIntervalSeconds>5</scanIntervalSeconds>
<connectors>
<connector
implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<port>8090</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
</connectors>
-->
</configuration>
</plugin>
</build>
....
</project>
and bellow the jetty.xml file:
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<!-- =============================================================== -->
<!-- Configure the Jetty Server -->
<!-- -->
<!-- Documentation of this file format can be found at: -->
<!-- http://docs.codehaus.org/display/JETTY/jetty.xml -->
<!-- -->
<!-- =============================================================== -->
<Configure id="Server" class="org.mortbay.jetty.Server">
<!-- =========================================================== -->
<!-- Server Thread Pool -->
<!-- =========================================================== -->
<Set name="ThreadPool">
<!-- Default bounded blocking threadpool -->
<New class="org.mortbay.thread.BoundedThreadPool">
<Set name="minThreads">10</Set>
<Set name="maxThreads">11</Set>
</New>
</Set>
<!-- =========================================================== -->
<!-- Set connectors -->
<!-- =========================================================== -->
<Unable to render embedded object: File (-- One of each type) not found. -->
<!-- =========================================================== -->
<!-- Use this connector for many frequently idle connections
and for threadless continuations. -->
<Call name="addConnector">
<Arg>
<New class="org.mortbay.jetty.nio.SelectChannelConnector">
<Set name="port">8090</Set>
<Set name="maxIdleTime">30000</Set>
<Set name="Acceptors">1</Set>
<Set name="statsOn">false</Set>
<Set name="confidentialPort">8445</Set>
<Set name="lowResourcesConnections">1000</Set>
<Set name="lowResourcesMaxIdleTime">500</Set>
</New>
</Arg>
</Call>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- To add a HTTPS SSL listener -->
<!-- see jetty-ssl.xml to add an ssl connector. use -->
<!-- java -jar start.jar etc/jetty.xml etc/jetty-ssl.xml -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- =========================================================== -->
<!-- Set handler Collection Structure -->
<!-- =========================================================== -->
<Set name="handler">
<New id="Handlers" class="org.mortbay.jetty.handler.HandlerCollection">
<Set name="handlers">
<Array type="org.mortbay.jetty.Handler">
<Item>
<New id="Contexts" class="org.mortbay.jetty.handler.ContextHandlerCollection"/>
</Item>
<Item>
<New id="DefaultHandler" class="org.mortbay.jetty.handler.DefaultHandler"/>
</Item>
<Item>
<New id="RequestLog" class="org.mortbay.jetty.handler.RequestLogHandler"/>
</Item>
</Array>
</Set>
</New>
</Set>
<!-- =========================================================== -->
<!-- Configure the webapp deployer. -->
<!-- A webapp deployer will deploy standard webapps discovered -->
<!-- in a directory at startup, without the need for additional -->
<!-- configuration files. It does not support hot deploy or -->
<!-- non standard contexts (see ContextDeployer above). -->
<!-- -->
<!-- This deployer is configured to deploy webapps from the -->
<!-- $JETTY_HOME/webapps directory -->
<!-- -->
<!-- Normally only one type of deployer need be used. -->
<!-- -->
<!-- =========================================================== -->
<Call name="addLifeCycle">
<Arg>
<New class="org.mortbay.jetty.deployer.WebAppDeployer">
<Set name="contexts"><Ref id="Contexts"/></Set>
<Set name="webAppDir"><SystemProperty name="jetty.home" default="."/>/webapps</Set>
<Set name="parentLoaderPriority">false</Set>
<Set name="extract">true</Set>
<Set name="allowDuplicates">false</Set>
<Set name="defaultsDescriptor"><SystemProperty name="jetty.home" default="."/>/etc/webdefault.xml</Set>
</New>
</Arg>
</Call>
<!-- =========================================================== -->
<!-- extra options -->
<!-- =========================================================== -->
<Set name="stopAtShutdown">true</Set>
<!-- ensure/prevent Server: header being sent to browsers -->
<Set name="sendServerVersion">true</Set>
</Configure>
and finally the trace I got when I launch the jetty server through the maven plugin:
C:\00-Maven2\hotdeploy\struts\module1>mvn clean jetty:run
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'jetty'.
[INFO] -------------------------------------------------------------------------
—
[INFO] Building module1
[INFO] task-segment: [clean, jetty:run]
[INFO] -------------------------------------------------------------------------
—
[INFO] [clean:clean]
[INFO] Deleting directory C:\00-Maven2\hotdeploy\struts\module1\target
[INFO] Deleting directory C:\00-Maven2\hotdeploy\struts\module1\target\classes
[INFO] Deleting directory C:\00-Maven2\hotdeploy\struts\module1\target\test-clas
ses
[INFO] Preparing jetty:run
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
[INFO] Compiling 6 source files to C:\00-Maven2\hotdeploy\struts\module1\target\
classes
[INFO] [resources:testResources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:testCompile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [jetty:run]
[INFO] Configuring Jetty for project: module1
[INFO] Webapp source directory = C:\00-Maven2\hotdeploy\struts\module1\src\main\
webapp
[INFO] web.xml file = C:\00-Maven2\hotdeploy\struts\module1\src\main\webapp\WEB-
INF\web.xml
[INFO] Classes = C:\00-Maven2\hotdeploy\struts\module1\target\classes
[INFO] Configuring Jetty from xml configuration file = C:\00-Maven2\hotdeploy\st
ruts\module1\src\etc\jetty.xml
2007-06-04 11:01:58.332::INFO: Logging to STDERR via org.mortbay.log.StdErrLog
2007-06-04 11:01:58.441::INFO: Statistics on = false for SelectChannelConnector
@ 0.0.0.0:8090
[INFO] Context path = /module1
[INFO] Tmp directory = C:\00-Maven2\hotdeploy\struts\module1\target\work
[INFO] Web defaults = jetty default
[INFO] Web overrides = none
[INFO] Webapp directory = C:\00-Maven2\hotdeploy\struts\module1\src\main\webapp
[INFO] Starting jetty 6.1.4rc0 ...
2007-06-04 11:01:58.597::INFO: jetty-6.1.4rc0
2007-06-04 11:01:58.832::INFO: No Transaction manager found - if your webapp re
quires one, please configure one.
2007-06-04 11:02:00.019::WARN: Unknown realm: Test Realm
2007-06-04 11:02:00.332::WARN: Unknown realm: Test JAAS Realm
2007-06-04 11:02:00.425::INFO: Started SelectChannelConnector @ 0.0.0.0:8080
[INFO] Started Jetty Server
As you can see above the server start on the default jetty port 8080 instead of mine 8090 specified in the jetty.xml file.
Otherwise, if I use the pom.xml configuration, it works well.
Now I asked the jetty-discuss mailing list and M. Jan Bartel emailed me that:
"It is simply that the plugin is expecting at least one connector
to be configured in the pom, and if it doesn't find one, then it
assumes one on port 8080. It should be changed so that it checks
if any connectors have been configured for the Server already,
and if not, then assume one on port 8080. "
So lets hope it is fixed soon...
Best regards,
Jeremy
Activity
| Field | Original Value | New Value |
|---|---|---|
| Assignee | Jan Bartel [ janb ] |
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Resolution | Fixed [ 1 ] |
| Resolution | Fixed [ 1 ] | |
| Status | Resolved [ 5 ] | Reopened [ 4 ] |
| Status | Reopened [ 4 ] | Resolved [ 5 ] |
| Fix Version/s | 6.1.4rc0 [ 13515 ] | |
| Fix Version/s | 6.1.3 [ 13455 ] | |
| Resolution | Fixed [ 1 ] |
Ensured that a Connector defined in a <jettyConfig> file is used. In fact, Connectors and UserRealms defined in pom.xml now add to, rather than override, those elements defined in a <jettyConfig> file.