0

我正在使用带有 Cargo 1.3.3 插件的 Maven 3.0.3。我正在尝试配置嵌入式 JBoss 7.1 容器。我想自定义 JBoss 侦听请求的端口,通常是 8080。但是,我不能t似乎自定义它,使用配置部分中的“cargo.servlet.port”属性。下面是我的配置

                <plugin>
                    <groupId>org.codehaus.cargo</groupId>
                    <artifactId>cargo-maven2-plugin</artifactId>
                    <version>1.3.3</version>
                    <configuration>
                        <home>${project.build.directory}/jboss-${jboss.version}/container</home>
                        <properties>
                            <cargo.logging>high</cargo.logging>
                            <cargo.servlet.port>${jboss.servlet.port}</cargo.servlet.port>
                        </properties>
                        <container>
                            <containerId>jboss${jboss.major}x</containerId>
                            <zipUrlInstaller>
                                <url>http://download.jboss.org/jbossas/7.1/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final.zip</url>
                                <downloadDir>${project.basedir}/downloads</downloadDir>
                                <extractDir>${project.build.directory}/extracts</extractDir>
                            </zipUrlInstaller>
                            <output>${project.build.directory}/jboss${jboss.major}x.log</output>
                            <log>${project.build.directory}/cargo.log</log>
                        </container>
                        <deployables>
                            <deployable>
                                <location>target/${project.artifactId}.${project.packaging}</location>
                                <pingURL>http://localhost:${jboss.servlet.port}/${project.artifactId}</pingURL>
                                <pingTimeout>60000</pingTimeout>
                                <properties>
                                    <context>${project.artifactId}</context>
                                </properties>
                            </deployable>
                        </deployables>
                    </configuration>
                    <executions>
                        <execution>
                            <id>start-container</id>
                            <phase>pre-integration-test</phase>
                            <goals>
                                <goal>start</goal>
                                <goal>deploy</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>stop-container</id>
                            <phase>post-integration-test</phase>
                            <goals>
                                <goal>stop</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

这是我在应用程序服务器日志中得到的绑定异常(我已经在端口 8080 上运行了一个 JBoss 实例)。

16:45:41,913 INFO  [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-10) JBoss Web Services - Stack CXF Server 4.0.2.GA
16:45:42,010 ERROR [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-3) Error initializing endpoint: java.net.BindException: Address already in use /0.0.0.0:8080
    at org.apache.tomcat.util.net.JIoEndpoint.init(JIoEndpoint.java:983) [jbossweb-7.0.13.Final.jar:]
    at org.apache.coyote.http11.Http11Protocol.init(Http11Protocol.java:190) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.connector.Connector.init(Connector.java:983) [jbossweb-7.0.13.Final.jar:]
    at org.jboss.as.web.WebConnectorService.start(WebConnectorService.java:267) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) [classes.jar:1.6.0_41]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) [classes.jar:1.6.0_41]
    at java.lang.Thread.run(Thread.java:680) [classes.jar:1.6.0_41]

16:45:42,025 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC00001: Failed to start service jboss.web.connector.http: org.jboss.msc.service.StartException in service jboss.web.connector.http: JBAS018007: Error starting web connector
    at org.jboss.as.web.WebConnectorService.start(WebConnectorService.java:271)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) [classes.jar:1.6.0_41]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) [classes.jar:1.6.0_41]
    at java.lang.Thread.run(Thread.java:680) [classes.jar:1.6.0_41]
Caused by: LifecycleException:  Protocol handler initialization failed: java.net.BindException: Address already in use /0.0.0.0:8080
    at org.apache.catalina.connector.Connector.init(Connector.java:985)
    at org.jboss.as.web.WebConnectorService.start(WebConnectorService.java:267)
    ... 5 more

我喜欢 Cargo 插件的原因是它允许我使用我自己的 JBoss Standalone.xml 配置,但我对 Cargo 的替代品持开放态度,前提是我可以自定义我的配置。感谢您的指导, - 戴夫

4

1 回答 1

0

您的配置中似乎只有一个小错误。属性是 Cargo 配置的一部分,它是插件配置的子/属性,所以实际上,您必须在配置标签内放置一个配置标签。这是我的(部分):

    <plugin>
      <groupId>org.codehaus.cargo</groupId>
      <artifactId>cargo-maven2-plugin</artifactId>
      <version>1.3.3</version>
      <configuration>
        <container>
          <!-- Add your container here, we use a custom one -->
        </container>
        <configuration>
          <properties>
            <cargo.servlet.port>5556</cargo.servlet.port>
            <!-- other properties -->
          </properties>
          <configfiles combine.children="append">
            <!-- here we add our configuration files -->
            <configfile>
              <!-- Expect configfiles to be filtered and gathered in 
                target/jboss71x (in the respective subdirectories) -->
              <file>${project.build.directory}/cargo/jboss71x</file>
            </configfile>
          </configfiles>
        </configuration>
      </configuration>
    </plugin>
于 2013-05-15T07:30:28.227 回答