0

I created a dynamic web application then converted it to maven project. When I try to deploy it using with maven build, It creates the war file and others(META-INF, WEB-INF) but Maven doesn't deploy the xhtml files and the web.xml file which are under the WEB-INF folder.

I can manually copy the xhtml files to target(tomcat/webapps) and it works.. but when i copy the web.xml file manually, the web application crashes.

this is my pom.xml file

<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>my_group_ıd</groupId>
    <artifactId>my_artifact_id</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <name>My_Webapp_name</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <!-- Servlet -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
        </dependency>

        <!-- Faces Implementation -->
        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-impl</artifactId>
            <version>2.2.4</version>
        </dependency>
        <!-- Faces Library -->
        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-api</artifactId>
            <version>2.2.4</version>
        </dependency>
        <!-- Primefaces Version 5 -->
        <dependency>
            <groupId>org.primefaces</groupId>
            <artifactId>primefaces</artifactId>
            <version>5.1</version>
        </dependency>
        <!-- JSP Library -->
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>javax.servlet.jsp-api</artifactId>
            <version>2.3.1</version>
        </dependency>
        <!-- JSTL Library -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.1.2</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.23</version>
        </dependency>
        <dependency>
            <groupId>com.lowagie</groupId>
            <artifactId>itext</artifactId>
            <version>2.1.7</version>
        </dependency>

        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.7</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-el</artifactId>
            <version>7.0.63</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-core</artifactId>
            <version>8.0.24</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <repositories>
        <repository>
            <id>prime-repo</id>
            <name>Prime Repo</name>
            <url>http://repository.primefaces.org</url>
        </repository>
    </repositories>


<build>
        <finalName>my_final_name</finalName>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.tomcat.maven</groupId>
                    <artifactId>tomcat7-maven-plugin</artifactId>
                    <version>2.2</version>
                    <configuration>
                        <url>http://localhost:8080/manager/text</url>
                        <server>TomcatServer</server>
                        <username>username</username>
                        <password>password</password>
                        <path>/my_path</path>
                    </configuration>
                </plugin>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.1</version>
                    <configuration>
                        <source>1.6</source>
                        <target>1.6</target>
                    </configuration>
                </plugin>
                <plugin>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.3</version>
                    <configuration>
                        <warSourceDirectory>webapp</warSourceDirectory>
                    </configuration>
                    <executions>
                        <execution>
                            <id>default-war</id>
                            <phase>package</phase>
                            <goals>
                                <goal>war</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

</project>

I have tried many things to deploy them automatically with maven. I couldn't be successful, so far..

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Ahmet Ozkal
  • 39
  • 1
  • 5
  • Apparently project structure is plain wrong. Hard to tell without seeing it. This has at least nothing to do with JSF as it's just a HTML form based MVC framework, not a build system producing WAR files. That's Maven. Moreover, JSF hasn't even had the chance to run ;) – BalusC Mar 15 '16 at 12:55
  • Why are you changing the structure of the default layout...follow the conventions makes life easier...Remove `webapp` and don't make executions if you don't know what the do...so in the consequence remove the whole definition of the maven-war-plugin which is automatically picked up by using `war`. You might define a new version by using pluginManagement... – khmarbaise Mar 15 '16 at 12:58
  • My web project based on this example [link](http://www.javaknowledge.info/authentication-based-secure-login-logout-using-jsf-2-0-and-primefaces-3-4-1/) So i think if it works properly my project should work too.. – Ahmet Ozkal Mar 15 '16 at 13:45
  • Could you please provide your project structure? – António Ribeiro Mar 15 '16 at 13:52
  • http://imgur.com/o6NKKXm – Ahmet Ozkal Mar 15 '16 at 14:04

2 Answers2

1

I removed this plugin and changed various things in web.xml.. it works

<plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <warSourceDirectory>webapp</warSourceDirectory>
                </configuration>
                <executions>
                    <execution>
                        <id>default-war</id>
                        <phase>package</phase>
                        <goals>
                            <goal>war</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

thanks everyone

Ahmet Ozkal
  • 39
  • 1
  • 5
1

I have converted web application to maven and added your plugin but jars are added into target folders web-inf/jars folder not in web-content folder.

Rohit K
  • 11
  • 2