Maven and Cargo: start a Jetty-Container with a war file

I just started a new Maven project that is designed to run a Jetty containing a war-file from a dependent project. For this you need the right plugin.

Unfortunately, this does not work for me. It starts Jetty successfully, but it contains only the default-war-war file, not the expected one.

This is an important part of my war file:

<dependencies> <dependency> <groupId>com.group</groupId> <artifactId>my-webapp</artifactId> <version>0.1.0-SNAPSHOT</version> <type>war</type> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.codehaus.cargo</groupId> <artifactId>cargo-maven2-plugin</artifactId> <version>1.0.5</version> <configuration> <container> <containerId>jetty7x</containerId> <type>embedded</type> </container> <configuration> <properties> <cargo.servlet.port>7070</cargo.servlet.port> <cargo.logging>high</cargo.logging> </properties> </configuration> <deployer> <type>embedded</type> <deployables> <deployable> <groupId>com.group</groupId> <type>war</type> <artifactId>my-webapp</artifactId> <properties> <context>/path</context> </properties> </deployable> </deployables> </deployer> </configuration> </plugin> </plugins> </build> 

I use the plugin by running mvn cargo: start.

No error log output.

 [INFO] [cargo:start] [INFO] [beddedLocalContainer] Jetty 7.x Embedded starting... 2011-01-17 18:57:44.586:INFO::jetty-7.2.0.v20101020 2011-01-17 18:57:44.663:INFO::Extract jar:file:/tmp/cargo/conf/cargocpc.war!/ to /tmp/jetty-0.0.0.0-7070-cargocpc.war-_cargocpc-any-/webapp 2011-01-17 18:57:45.082:INFO::Started SelectChannelConnector@0.0.0.0 :7070 [INFO] [beddedLocalContainer] Jetty 7.x Embedded started on port [7070] 

How can I transfer Cargo to load the specified war file?

+4
source share
4 answers

Try it. Configure the configuration type stand-alone and install deployables in the configuration. Make sure that there is the right project dependency to resolve the war.

  <configuration> <type>standalone</type> <properties> <cargo.servlet.port>7070</cargo.servlet.port> <cargo.logging>high</cargo.logging> </properties> <deployables> <deployable> <groupId>com.group</groupId> <type>war</type> <artifactId>my-webapp</artifactId> <properties> <context>/path</context> </properties> </deployable> </deployables> </configuration> 
+1
source

OK, now I succeeded.

It seems that the load silently ignores any snapshot dependencies. Therefore, you must release a project before using it in a freight project.

Perhaps this is a mistake. I cannot imagine a reasonable reason for this behavior.

(also the pom file I wrote above was wrong, you need to adapt the changes Robin suggests in his answer)

+1
source

If you just want to deploy on the built-in Jetty, you may not need Cargo. Just use this in your pom.xml web application:

  <build> ... ... <plugins> <plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>7.2.2.v20101205</version> <configuration> <scanIntervalSeconds>10</scanIntervalSeconds> <webAppConfig> <contextPath>/path</contextPath> </webAppConfig> <connectors> <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector"> <port>7070</port> <maxIdleTime>60000</maxIdleTime> </connector> </connectors> </configuration> </plugin> ... ... </plugins> ... ... </build> 

to create and run a Jetty user

  mvn clean install jetty:run 
0
source

It seems that this might work better if you do the deployment first, say run the command "mvn cargo: deploy", then run "mvn cargo: start"

0
source

Source: https://habr.com/ru/post/1335873/


All Articles