Where is Cargo generating context XML for Jetty 6.x?

只谈情不闲聊 提交于 2019-12-04 19:17:44

I am not 100% sure what your problem is, but here is what cargo does on my system for Jetty6.

The directory where the Jetty installation is NOT where the runtime context and webapp files are. In my case, they are stored in the Java temp directory (i.e. java.io.tmpdir). On my Ubuntu system this is /tmp. Under this directory, there is a cargo/conf directory. Under /tmp/cargo/conf I have a contexts directory where the context.xml file is stored -- although the actual name of the file is never context.xml it is always named after the web app context.

In my case, this file is given the same name as the context I configured cargo with. Herein may lie your problem because I noticed that you did not supply a context as I do:

<deployables>
    <deployable>
       <properties>
         <!-- Web root context URL -->
         <context>${build.appserver.context}</context>
       </properties>
    </deployable>
</deployables>

Secondly, I also noticed you have commented out the section that places the context.xml file in the right place. Unless you uncomment that, this isn't going to work.

Thirdly, did you set the value of the ${jetty6.context} Maven property?

Fourthly - I think for this to work you need to use a standalone configuration of Jetty. This shouldn't be a problem as Cargo will automatically download and install it for you. See my config here:

                      <container>
                          <containerId>jetty6x</containerId>
                          <!-- Using Jetty for build portability so type != "remote". For Jetty
                              would prefer type = "embedded" but we must go with "installed" because jetty-env.xml
                              file would be ignored. See http://jira.codehaus.org/browse/CARGO-861 -->
                          <type>installed</type>
                          <zipUrlInstaller>
                              <url>http://dist.codehaus.org/jetty/jetty-6.1.26/jetty-6.1.26RC0.zip</url>
                              <installDir>${build.working}</installDir>
                          </zipUrlInstaller>
                          <dependencies>
                              <!-- The following dependencies are added to the servlet container's
                                  classpath as if they were installed by a system admin. In order to be included
                                  here, they need to be listed as dependencies in this pom.xml. -->
                              <dependency>
                                  <groupId>com.h2database</groupId>
                                  <artifactId>h2</artifactId>
                              </dependency>
                              <dependency>
                                  <groupId>com.oracle</groupId>
                                  <artifactId>ojdbc5</artifactId>
                              </dependency>
                              <dependency>
                                  <groupId>mysql</groupId>
                                  <artifactId>mysql-connector-java</artifactId>
                              </dependency>
                              <dependency>
                                  <groupId>net.sourceforge.jtds</groupId>
                                  <artifactId>jtds</artifactId>
                              </dependency>
                          </dependencies>
                      </container>
                      <!-- Do not hang and wait for a client, just do it -->
                      <wait>false</wait>
                      <configuration> <!-- Deployer configuration -->
                          <!-- Running Jetty container with type=installed (e.g. local) so
                              type != "runtime", and we are installing it during this execution for the
                              sake of portability so type != "existing" -->
                          <type>standalone</type>
                          <properties>
                              <!-- Use the port number from settings.xml -->
                              <cargo.servlet.port>${build.appserver.port}</cargo.servlet.port>
                          </properties>
                          <deployables>
                              <deployable>
                                  <properties>
                                      <!-- Web root context URL -->
                                      <context>${build.appserver.context}</context>
                                  </properties>
                              </deployable>
                          </deployables>
                          <configfiles>
                              <configfile>
                                  <file>${basedir}/target/jetty-context.xml</file>
                                  <todir>contexts</todir>
                                  <tofile>${build.appserver.context}.xml</tofile>
                              </configfile>
                          </configfiles>
                      </configuration>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!