简体   繁体   中英

maven-jetty-plugin can't bind address under linux

I have added a maven-jetty plugin to my pom as follows:

 <plugin>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>maven-jetty-plugin</artifactId>
            <version>6.1.16</version>
            <configuration>
                <connectors>
                    <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
                        <host>${jetty.host}</host>
                        <port>${jetty.port}</port>
                        <maxIdleTime>30000</maxIdleTime>
                    </connector>
                </connectors>
                <scanIntervalSeconds>10</scanIntervalSeconds>
                <stopPort>${jetty.stop.port}</stopPort>
                <stopKey>STOP</stopKey>
                <contextPath>${jetty.contextpath}</contextPath>
            </configuration>
            <executions>
                <execution>
                    <id>start-jetty</id>
                    <phase>pre-integration-test</phase>
                    <goals>
                        <goal>stop</goal>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <scanIntervalSeconds>0</scanIntervalSeconds>
                        <daemon>true</daemon>
                    </configuration>
                </execution>
                <execution>
                    <id>stop-jetty</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>stop</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

This works fine under windows 7 but if I try to execute it under Linux (SuSE) it always fails with address already in use.

I tried localhost and 127.0.0.1 as jetty.host and a few numbers as ports. I checked the ports on the linux system and they are all not in used by other services.

I use maven 3.0.3 and JDK 1.6_29 on both systems.

Any ideas?

这是我错过检查的STOP端口!

try a different port with the following command

mvn -Djetty.port=7000 jetty:run

You can check which process has opened a port:

http://www.cyberciti.biz/faq/what-process-has-open-linux-port/

With

netstat -tulpn

You'll see the corresponding processes on the right side.

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