WAS 8.5.5.13上的Maven Portlet上下文根

时间:2018-09-26 10:19:35

标签: maven websphere portlet contextroot

我已经在Websphere应用程序服务器8.5.5.13上部署了一些示例Maven Portlet(带有WAR和EAR模块的项目),但是它的上下文根存在问题。

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>

父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模块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模块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>

正如我已经提到的,portlet已成功部署。我期望可以在http:// localhost:9081/Test上访问它,但是它可以在http:// localhost:9081/Test/Test上访问。为什么呢?在EAR模块pom中,我已将Web模块的上下文根显式设置为/Test。我在ibm-web-ext.xml文件中做了同样的事情。如果我删除该文件,则http:// localhost:9081/Testhttp:// localhost:9081/Test/Test上都无法访问portlet。

我应该如何配置Portlet在http:// localhost:9081/Test上可访问?我在做什么错了?

谢谢!

1 个答案:

答案 0 :(得分:0)

我相信我找到了我问题的答案。 Web模块的上下文根显然已正确设置(http:// localhost:9081/Test),URL的其他Test部分代表了portlet.xml文件中分配的portlet名称,因此http:// localhost:9081/Test/Test确实是访问portlet应用程序的正确URL。

相关问题