Maven portlet context root on WAS 8.5.5.13

337 Views Asked by At

I've deployed some sample Maven portlet (project with WAR and EAR modules) on Websphere application server 8.5.5.13, but I'm having problem with it's context root.

web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
        <display-name>Test</display-name>
        <context-param>
                <param-name>javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE</param-name>
                <param-value>true</param-value>
        </context-param>
        <context-param>
                <description>Development, Production</description>
                <param-name>javax.faces.PROJECT_STAGE</param-name>
                <param-value>Production</param-value>
        </context-param>
        <context-param>
                <param-name>org.apache.myfaces.ERROR_HANDLING</param-name>
                <param-value>false</param-value>
        </context-param>
        <context-param>
                <param-name>facelets.SKIP_COMMENTS</param-name>
                <param-value>true</param-value>
        </context-param>
        <context-param>
                <param-name>org.apache.myfaces.EXPRESSION_FACTORY</param-name>
                <param-value>org.jboss.el.ExpressionFactoryImpl</param-value>
        </context-param>
        <context-param>
                <param-name>org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION</param-name>
                <param-value>1000</param-value>
        </context-param>
        <context-param>
                <param-name>org.apache.myfaces.NUMBER_OF_SEQUENTIAL_VIEWS_IN_SESSION</param-name>
                <param-value>1000</param-value>
        </context-param>
        <context-param>
                <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
                <param-value>client</param-value>
        </context-param>
        <listener>
                <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
        </listener>
        <servlet>
                <servlet-name>Faces Servlet</servlet-name>
                <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
                <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet>
                <servlet-name>ProxyServlet</servlet-name>
                <servlet-class>com.ibm.ws.ajaxproxy.servlet.ProxyServlet</servlet-class>
        </servlet>
        <servlet-mapping>
                <servlet-name>Faces Servlet</servlet-name>
                <url-pattern>/faces/*</url-pattern>
        </servlet-mapping>
        <servlet-mapping>
                <servlet-name>ProxyServlet</servlet-name>
                <url-pattern>/proxy/*</url-pattern>
        </servlet-mapping>
</web-app>

parent 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/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.example</groupId>
        <artifactId>Test</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <packaging>pom</packaging>

        <modules>
                <module>Test-WAR</module>
                <module>Test-EAR</module>
        </modules>


        <dependencyManagement>
                <dependencies>
                        ...
                </dependencies>
        </dependencyManagement>

        <repositories>
                ...
        </repositories>

        <build>
                <plugins>
                        ...
                </plugins>
        </build>
</project>

WAR module 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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
            <groupId>com.example</groupId>
            <artifactId>Test</artifactId>
            <version>0.0.1-SNAPSHOT</version>
    </parent>
    <artifactId>Test-WAR</artifactId>
    <packaging>war</packaging>

    <dependencies>
            ...
    </dependencies>

    <build>
            <plugins>
                    ...
            </plugins>
    </build>

EAR module 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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
            <groupId>com.example</groupId>
            <artifactId>Test</artifactId>
            <version>0.0.1-SNAPSHOT</version>
    </parent>
    <artifactId>Test-EAR</artifactId>
    <packaging>ear</packaging>

    <dependencies>
            <dependency>
                    <groupId>com.example</groupId>
                    <artifactId>Test-WAR</artifactId>
                    <version>0.0.1-SNAPSHOT</version>
                    <type>war</type> 
            </dependency>
    </dependencies>

    <build>
            <plugins>
                    <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-ear-plugin</artifactId>
                            <version>2.9</version>
                            <configuration>
                                    <generateApplicationXml>true</generateApplicationXml>
                                    <modules>
                                            <webModule>
                                                    <groupId>com.example</groupId>
                                                    <artifactId>Test-WAR</artifactId>
                                                    <contextRoot>/Test</contextRoot>
                                            </webModule>
                                    </modules>
                                    <version>5</version>
                                    <finalName>Test</finalName>
                            </configuration>
                    </plugin>
            </plugins>
    </build>

ibm-web-ext.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-ext
        xmlns="http://websphere.ibm.com/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-ext_1_0.xsd"
        version="1.0">

        <reload-interval value="3"/>
        <context-root uri="Test" />
        <enable-directory-browsing value="false"/>
        <enable-file-serving value="true"/>
        <enable-reloading value="true"/>
        <enable-serving-servlets-by-class-name value="false" />
</web-ext>

As I've already mentioned, portlet is successfully deployed. I've expected to be accessible on http:// localhost:9081/Test, but it's on http:// localhost:9081/Test/Test. Why is that so? In EAR module pom, I've explicitly set context root of a web module to /Test. I did the same in ibm-web-ext.xml file. If I remove that file, portlet is not accessible on neither http:// localhost:9081/Test nor http:// localhost:9081/Test/Test.

How should I configure portlet to be accessible on http:// localhost:9081/Test? What am I doing wrong?

Thanks!

1

There are 1 best solutions below

0
On BEST ANSWER

I believe I found an answer to my question. Context root of a web module is obviously set correctly (http:// localhost:9081/Test), the other Test part of an URL represent portlet name assigned in portlet.xml file, so http:// localhost:9081/Test/Test is indeed the right URL to access portlet application.