Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

changing maven cargo plugin deployment path

I want to have my integration test hit cargo's tomcat at http://localhost:8080/messaging but cargo (cargo-maven2-plugin:1.0.5) prefers to deploy my messaging project as /messaging-0.0.7-SNAPSHOT, as seen in the tomcat admin console and in the target\tomcat6x\webapps directory.

So I tried adding these lines to the cargo config, figuring that it will pick up the default artifact:

 <deployer>
  <deployables>
   <deployable>
     <properties>
     <context>/messaging</context>
    </properties>
   </deployable>
  </deployables>
 </deployer>

but it doesn't. It doesn't even attempt to since I don't see the messaging or messaging-0.0.7-SNAPSHOT in the target\tomcat6x\webapps directory.

The same thing happens when I set it up like so:

<configuration>
  <type>standalone</type>
 <wait>false</wait>
 <properties>
  <cargo.servlet.port>8080</cargo.servlet.port>
  <cargo.logging>high</cargo.logging>
 </properties>
 <deployer>
  <deployables>
   <deployable>
     <groupId>com.company.platform</groupId>
     <artifactId>messaging</artifactId>
     <type>war</type>
     <properties>
     <context>/messaging</context>
    </properties>
   </deployable>
  </deployables>
 </deployer>
</configuration>

Here's the full plugin config:

  <plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<executions>
 <execution>
  <id>start</id>
  <phase>pre-integration-test</phase>
  <goals>
   <goal>start</goal>
  </goals>
 </execution>
 <execution>
  <id>stop</id>
  <phase>post-integration-test</phase>
  <goals>
   <goal>stop</goal>
  </goals>
 </execution>
</executions>
<configuration>
  <type>standalone</type>
 <wait>false</wait>
 <properties>
  <cargo.servlet.port>8080</cargo.servlet.port>
  <cargo.logging>high</cargo.logging>
 </properties>
 <deployer>
  <deployables>
   <deployable>
     <properties>
     <context>/messaging</context>
    </properties>
   </deployable>
  </deployables>
 </deployer>
</configuration>

My integration test looks like this:

import junit.framework.TestCase;

import java.io.InputStream;
import java.net.URL;
import java.net.HttpURLConnection;
import java.sql.Time;

public class WebappTest extends TestCase
{
    public void testCallIndexPage() throws Exception
    {
        URL url = new URL("http://localhost:8080/messaging/");
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.connect();
        assertEquals(200, connection.getResponseCode());
        InputStream is = connection.getInputStream();
        System.out.println(connection.getContent().getClass());

    }
}

What's the best way to proceed? Knowing that it will successfully deploy as hxxp://localhost:8080/messaging-0.0.7-SNAPSHOT, I could alter the test, but what would be a quick way to pull the artifact version in?

Ideally, I'd like to have cargo deploy it correctly, but it is unclear how.

like image 388
dols Avatar asked Jan 18 '11 22:01

dols


1 Answers

From Cargo Plugin Reference,

About WAR contexts

    Many containers have their specific files for redefining context roots (Tomcat 
has context.xml, JBoss has jboss-web.xml, etc.). If your WAR has such a file, the 
server will most probably use the context root defined in that file instead of the 
one you specify using the CARGO deployer.

Could you be hitting this issue?

Also, I think context name should not have a leading /.

like image 136
Raghuram Avatar answered Sep 25 '22 14:09

Raghuram