maven调整jbsos插件二

maven整合jbsos插件二

之前也过maven整合jboss插件,当时采用的是jboss-maven-plugin插件,现在采用cargo插件进行jboss整合。

 

具体的pom代码配置如下:

<build>
    <plugins>
     <plugin>
      <groupId>org.codehaus.cargo</groupId>
      <artifactId>cargo-maven2-plugin</artifactId>
      <version>1.2.3</version>
      <executions>
       <execution>
        <id>cargo-run</id>
        <phase>pre-integration-test</phase>
        <goals>
         <goal>run</goal>
        </goals>
        <configuration>
         <container>
          <containerId>jboss42x</containerId>
          <home>${env.JBOSS_HOME}</home>
          <timeout>${cargo.container.timeout}</timeout>
         </container>
         <configuration>
          <type>standalone</type>
          <home>${project.build.directory}/jboss-4.2.3.GA</home>
          <properties>
           <cargo.jvmargs>
            -Xdebug
            -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8787
             </cargo.jvmargs>
                  <cargo.servlet.port>8088rgo.servlet.port>
          </properties>
         </configuration>
        </configuration>
       </execution>
      </executions>
     </plugin>
    </plugins>
   </build>

 

配置完成后执行 mvn deploy 即可,然后访问jboss主页是否正确。

 

遇到的问题如下:

 

1.时在配置jbsos4.0的时候配置的containerId为jboss4x导致,应用在启动jboss时出现了

在配置DBCP时遇到了JNDI的问题,javajava:comp is not bound in this Context ,不能绑定相关的JNDI数据源。

 

原因是在配置jboss4.2是cargo中的containerId配置错误导致。

 

如果配置的jboss4.2.3 那么<containerId>jboss42x</containerId> 为jboss42x,如果是jboss4.0 那么containerId为jboss4x,本来中的配置都是以maven3为准。


 

2.[ERROR] Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.2.3:run (cargo-run) on project task-web-dist: Execution cargo-run of
goal org.codehaus.cargo:cargo-maven2-plugin:1.2.3:run failed: Failed to start the JBoss 4.2.3 container. Deployable [http://localhost:8080/cargocpc/index.html]
 failed to finish deploying within the timeout period [60000]. The Deployable state is thus unknown. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :task-web-dist

 

 

关于这个问题在网上查询了相关的资料都说是应用在deploy时超时,我通过<timeout>${cargo.container.timeout}</timeout>设置相关的超时时间,但是错误任然出现,后来仔细查看错误的一行语句

 

http://localhost:8080/cargocpc/index.html 

 

是由于这个URL不能部署成功才发现问题的根本原因,由于cargo默认监听的端口是8080所以产生的url为8080端口,但是我的jboss中的端口已经修改为8088,所以才导致index.html发布失败。

 

解决问题的办法可以设置cargo监听的端口

    <cargo.servlet.port>8088rgo.servlet.port>
重新启动即可,或者修改jboss的端口为808。