We are Borg
We are Borg

Reputation: 5311

Spring, Maven : Unable to deploy module with tomcat

I wanted to try Spring-MVC with GWT and for that I found this archetype. When I downloaded it locally, and ran a mvn clean && mvn install, it generates a jar file, but the packaging for the project in 2nd pom.xml is of type WAR. For deploying it in tomcat, I added the compile-output for the project, but I am still unable to run the project. I am adding the error log, and screenshots. Can someone also help me understand the project structure. Thank you.

Sorry for the TMI, don't know exactly what's the problem, so trying all possibilities.

Error log :

Connected to server
[2016-12-29 01:52:13,364] Artifact unnamed: Artifact is being deployed, please wait...
[2016-12-29 01:52:13,388] Artifact unnamed: Error during artifact deployment. See server log for details.
[2016-12-29 01:52:13,389] Artifact unnamed: com.intellij.javaee.oss.admin.jmx.JmxAdminException: com.intellij.execution.ExecutionException: /home/akshay/gwt/spring-mvc-quickstart-archetype/out/artifacts/unnamed not found for the web module.
Dec 29, 2016 1:52:23 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /home/akshay/Downloads/apache-tomcat-7.0.69/webapps/examples

Outer POM.xml :

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>pl.codeleak</groupId>
    <artifactId>spring-mvc-quickstart</artifactId>
    <version>1.0.0</version>
    <packaging>maven-archetype</packaging>
    <name>Spring MVC Maven Archetype: Quickstart</name>
    <description>Archetype for creating Spring MVC 4 web application</description>
    <url>https://github.com/kolorobot/spring-mvc-quickstart-archetype</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <build>
        <extensions>
            <extension>
                <groupId>org.apache.maven.archetype</groupId>
                <artifactId>archetype-packaging</artifactId>

                <version>2.2</version>
            </extension>
        </extensions>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-archetype-plugin</artifactId>
                    <version>2.2</version>

                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>2.6</version>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
    <pluginRepositories>
        <pluginRepository>
            <id>apache.snapshots</id>
            <name>Apache Snapshots</name>
            <url>http://repository.apache.org/content/groups/snapshots-group/</url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>
</project>

Inner pom.xml :

<project
        xmlns="http://maven.apache.org/POM/4.0.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
>
    <modelVersion>4.0.0</modelVersion>
    <groupId>${groupId}</groupId>
    <artifactId>${artifactId}</artifactId>
    <packaging>war</packaging>
    <version>${version}</version>
    <name>Spring MVC Application</name>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java-version>1.8</java-version>
        <!-- Override Spring version -->
        <!-- spring.version>4.3.3.RELEASE</spring.version -->
        <!-- Thymeleaf 3 -->
        <org.thymeleaf-version>3.0.2.RELEASE</org.thymeleaf-version>
        <org.thymeleaf.extras.springsecurity4-version>3.0.0.RELEASE</org.thymeleaf.extras.springsecurity4-version>
        <nz.net.ultraq.thymeleaflayout-version>2.0.5</nz.net.ultraq.thymeleaflayout-version>
        <thymeleaf-extras-java8time-version>3.0.0.RELEASE</thymeleaf-extras-java8time-version>
        <!-- AssertJ is not a part of Spring IO platform, so the version must be provided explicitly -->
        <assertj-core-version>3.5.2</assertj-core-version>
    </properties>
    <parent>
        <groupId>io.spring.platform</groupId>
        <artifactId>platform-bom</artifactId>
        <version>Athens-SR1</version>
        <relativePath/>
    </parent>
// And subsequent dependencies

 <plugins>
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <path>/</path>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>${java-version}</source>
                    <target>${java-version}</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1.1</version>
                <configuration>
                    <warName>${artifactId}-${version}</warName>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>deploy</id>
                        <phase>deploy</phase>
                        <goals>
                            <goal>sources</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>
        </plugins>

Screenshots :

enter image description here

enter image description here

enter image description here

Upvotes: 0

Views: 241

Answers (2)

Thomas Broyer
Thomas Broyer

Reputation: 64541

This is not how you use an archetype : you need to run mvn archetype:generate and it'll generate a project for you (based on the "inner" POM). You don't even need to clone and build the archetype project itself. Actually, the exact command is given in the README : https://github.com/kolorobot/spring-mvc-quickstart-archetype/#create-a-project

Upvotes: 2

Daniel Gurianov
Daniel Gurianov

Reputation: 551

As far as i understood question. try to add maven war plugin to maven archetype pom you want to try

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.1.1</version>
            <configuration>
                <warName>${artifactId}-${version}</warName>
            </configuration>
        </plugin>

and put the

<packaging>war</packaging>

into your new pom header . You can also put into header version and artifact id , so maven war plugin could resolve them and fill warName tag

Upvotes: -1

Related Questions