Application not accessible with just the application name in the url on maven install

97 views Asked by At

Problem:

I am trying out a sample JSF bean-validation application from the git hub location https://github.com/javaee-samples/javaee7-samples/tree/master/jsf/bean-validation. I made the necessary custom changes with respect to the pom.xml file and settings.xml to point to my own local .m2/repository. After deploying the application on Wildfly 10 and acessing it over url as http://localhost:8180/bean-validation/faces I am not able to access the welcome page.

But when I rewrite the url as http://localhost:8180/bean-validation-1.0-SNAPSHOT/faces I am able to access the welcome page.

I see that in the Server--->Deployment folder the bean-validation .war has been deployed by maven (through mvn install command in command line) as bean-validation-1.0-SNAPSHOT.war

What do I need to change in my pom.xml file to be able to access the page with only the web application name in the url?

My customised pom.xml file looks as below:

<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
<!--     <parent>
        <groupId>org.javaee7.jsf</groupId>
        <artifactId>jsf-samples</artifactId>
        <version>1.0-SNAPSHOT</version>
        <relativePath>../pom.xml</relativePath>
    </parent> -->

    <groupId>org.javaee7.jsf</groupId>
    <artifactId>bean-validation</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>

    <dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-api</artifactId>
        <version>2.1.11</version>
    </dependency>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-web-api</artifactId>
        <version>6.0</version>
    </dependency>
<!--    <dependency>
        <groupId>javax.enterprise</groupId>
        <artifactId>javaee-api</artifactId>
        <version>6.0</version>
    </dependency> -->
    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-impl</artifactId>
        <version>2.1.11</version>
    </dependency>
</dependencies>
        <build>
        <plugins>
            <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.3</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1.1</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>
1

There are 1 answers

1
Steve C On

For immediate deployment from the target directory of your build, you can fix the name by adding a finalName in your pom.xml file:

 <build>
      <finalName>bean-validation</finalName>
      ...
 </build>

However if in the future you have an application deployment process that deploys your application from either your local repository or a remote repository then you may have to deal with configuring the application web context in a vendor dependent way.

If you're deploying the web application in an EAR file then you can also specify the web-module's context root by adding a

  <context-root>bean-validation</context-root>

to it's definition in the application.xml file.