0

I am using cargo plugin to configure Tomcat. But I am not able to get my application up. Getting 400 while hitting the application URL.

This is how the cargo configuration in pom.xml looks like:

<plugin>
              <!--  Load config files into the target/tomcat/conf directory.
                  Placeholder are resolved. The Cargo plugin definition below
                  tells Tomcat to use this directory. -->
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <version>2.4.2</version>
            <executions>
              <execution>
                <id>configure-tomcat</id>
                <phase>integration-test</phase>
                <goals>
                  <goal>copy-resources</goal>
                </goals>
                <configuration>
                  <outputDirectory>${project.build.directory}</outputDirectory>
                  <overwrite>true</overwrite>
                  <filters>
                    <filter>${config.properties}</filter>
                  </filters>
                  <resources>
                   <resource>  
                      <!-- the https-connector.temp file -->                               
                      <directory>${basedir}/src/test/resources/tomcat</directory>                                                
                      <filtering>true</filtering>                                                 
                      <includes>
                      </includes>
                      <targetPath>${project.build.directory}/tomcat/conf</targetPath>
                    </resource>
                    <resource>     
                        <!--  server.xml, logback.xml, etc -->                            
                      <directory>${basedir}/../installer/tomcat</directory>                                                
                      <filtering>true</filtering>                                                 
                      <includes>
                      </includes>
                      <targetPath>${project.build.directory}/tomcat/conf</targetPath>
                    </resource>
                  </resources>
                </configuration>
              </execution>
            </executions>
          </plugin>


<plugin>

                <groupId>org.codehaus.cargo</groupId>
                <artifactId>cargo-maven2-plugin</artifactId>
                <version>1.6.4</version>
                <configuration>
                    <container>
                        <containerId>tomcat8x</containerId>
                        <zipUrlInstaller>
                            <url>https://repo1.maven.org/maven2/org/apache/tomcat/tomcat/8.5.20/tomcat-8.5.20.zip</url>
                        </zipUrlInstaller>
                        <systemProperties>
                            <!--  these result in -D arguments -->
                            <user.timezone>GMT</user.timezone>

                            <logback.configurationFile>file://${basedir}/../installer/tomcat/logback.xml</logback.configurationFile>
                            <config.properties>${config.properties}</config.properties>
                            <java.awt.headless>true</java.awt.headless>
                            <project.build.finalName>${project.build.finalName}</project.build.finalName>
                            <doc.root>${doc.root}</doc.root>

                            <java.net.preferIPv4Stack>false</java.net.preferIPv4Stack>
                            <version>${VERSION}</version>
                            <build>${BUILD_NUMBER}</build>

                        </systemProperties>
                    </container>
                    <configuration>
                        <home>${project.build.directory}/catalina-base</home>
                        <type>standalone</type>
                        <properties>
                            <!--  hostname and servlet.port are overridden in our custom server.xml
                                  They seem to be used only for the ping URL -->
                            <cargo.hostname>localhost</cargo.hostname>
                            <cargo.servlet.port>4080</cargo.servlet.port>
                            <cargo.protocol>http</cargo.protocol>
                            <cargo.logging>high</cargo.logging>
                            <cargo.rmi.port>4005</cargo.rmi.port>
                        </properties>
                        <files>
                        <file>
                            <!-- the file element also works for directories.
                                 The source directory contains server.xml
                                 and the usual config files, with placeholders resolved -->
                            <file>${project.build.directory}/tomcat/conf</file>
                            <todir>conf</todir>
                            <configfile>true</configfile>
                            <overwrite>true</overwrite>
                        </file>

                        </files>
                    </configuration>
                    <deployables>
                        <deployable>
                            <location>${project.build.directory}/abc.war</location>
                            <type>war</type>
                        </deployable>
                    </deployables>
                    <packager>
                        <outputLocation>${project.build.directory}/tomcat-packaged</outputLocation>
                    </packager>

                </configuration>
                <executions>
                    <execution>
                        <id>start</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin> 

While hitting the URL, http://localhost:4080/cargocpc/index.html, I get the cargo home page. But while hitting http://localhost:4080/abc, I am getting 400.

As I see, the structure of the target folder which is mentioned below, the abc folder (abc being the name of my application) is expanded parallel to catalina-base inside target but the cargocpc is expanded inside /catalina-base/webapps. enter image description here

Can the absence of abc folder inside webapps be the reason for 400 Bad request?

Is there anything wrong with the configuration? If the abc folder should get expanded inside webapps, what configuration should be done for the same?

Zoe
  • 27,060
  • 21
  • 118
  • 148
Random Coder
  • 329
  • 2
  • 5
  • 11

1 Answers1

0

I am able to get my application up now. I don't know how but I am able to see the below mentioned entry in my /etc/hosts file :

127.0.0.1 localhost localhost.localdomain

So when I hit https://localhost.localdomain:4043/abc in place of https://localhost:4043/abc, I get to see the homepage of my application.

2 questions still remain unanswered though : Why abc is not getting expanded inside webapps? How and at which phase this entry got added in my /etc/hosts file.

Random Coder
  • 329
  • 2
  • 5
  • 11