Context root path not working in Jboss 7 ear

2019-08-22 07:33发布

问题:

<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.abc</groupId>
        <artifactId>MyProjectEar</artifactId><version>0.0.1-SNAPSHOT</version>
    </parent>
    <properties>
        <build.plugin.maven.ear.version>2.10.1</build.plugin.maven.ear.version>
    </properties>
    <artifactId>MyProjectEarModule</artifactId><packaging>ear</packaging>
    <dependencies>
        <dependency>
            <groupId>com.abc</groupId>
            <artifactId>MyProjectJar</artifactId><version>0.0.1-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>com.abc</groupId>
            <artifactId>MyProjectWar</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>${build.plugin.maven.ear.version}</version>
                    <configuration>
                        <applicationXml>${project.basedir}/src/main/application/META-INF/application.xml</applicationXml>
                        <finalName>MyProjectEar</finalName>
                        <defaultLibBundleDir>/lib</defaultLibBundleDir>
                        <modules>
                            <webModule>
                                <groupId>com.abc</groupId>
                                <artifactId>MyProjectWar</artifactId>
                                <contextRoot>/testcontextroot</contextRoot>
                            </webModule>
                            <jarModule>
                                <groupId>com.abc</groupId>
                                <artifactId>MyProjectJar</artifactId>
                                <bundleDir>/</bundleDir>
                            </jarModule>
                        </modules>
                    </configuration></plugin></plugins></build>
</project>

I am working on a project where an ear contains both jar and after deploying ear to jboss7, when i try to access the web project with contextroot, I am not able to access and nothing prints at all in server log too. I believe the request itself is not going to my server when I hit http://localhost:8080/testcontextroot.

I have given all the info needed and also the pom.xml code where I am building the ear.


\MyProjectEar.ear\
  META-INF 
     jboss-deployment-structure.xml
     application.xml
  lib
  MyProjectWar.war
     WEB-INF
        lib
        classes
        web.xml
        jboss-web.xml
        jboss-deployment-structure.xml
        facesconfig.xml
        beans.xml
    Pages
        registration.xhtml
        registration_success.xhtml
        decorator.xhtml
     META-INF
  MyProjectJar.jar

\MyProjectEar.ear\ META-INF jboss-deployment-structure.xml

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
    <deployment>
        <dependencies>
            <module name="org.apache.commons.collections" export="true" />
            <module name="com.sun.jsf-impl" />
            <module name="asm.asm" export="true" />
            <module name="org.codehaus.jackson.jackson-mapper-asl" export="true" />
            <module name="org.apache.cxf" export="true" />
            <module name="org.apache.cxf.impl" export="true" />
        </dependencies>
    </deployment>
    <sub-deployment name="MyProjectJar.jar"></sub-deployment>
</jboss-deployment-structure>

\MyProjectEar.ear\ META-INF applicaton.xml

    <?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="6"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd">
    <display-name>testdisplayname</display-name>
    <module>
        <ejb>MyProjectJar.jar</ejb>
    </module>
    <module>
    <web>
      <web-uri>MyProjectWar.war</web-uri>
      <context-root>/testconetextroot</context-root>
    </web>
   </module>
    <library-directory>lib</library-directory>

web.xml

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" 
   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">


    <display-name>testdisplay</display-name>
     <welcome-file-list>
    <!--   <welcome-file>/registration.xhtml</welcome-file> -->
    <welcome-file>pages/registration.jsf</welcome-file> 
     </welcome-file-list>
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>

     <security-constraint>
        <display-name>Restrict direct access .xhtml.</display-name>
        <web-resource-collection>
          <web-resource-name>Facelets</web-resource-name>
          <url-pattern>*.xhtml</url-pattern>
          </web-resource-collection>
        <auth-constraint/>
  </security-constraint>  
</web-app>

jboss-web.xml

<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
    <context-root>testcontextroot</context-root>
</jboss-web>

jboss-deployment-structure.xml

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <deployment>
    <exclude-subsystems> 
        <subsystem name="webservices" />
     </exclude-subsystems> 
      <exclusions>
      </exclusions>
         <dependencies>
        <module name="org.apache.cxf"/>
    </dependencies> 
    </deployment>
</jboss-deployment-structure>

faces-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<faces-config version="2.2" xmlns="http://xmlns.jcp.org/xml/ns/javaee"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd">
 <name>app</name>
 <navigation-rule>
  <from-view-id>/registration.xhtml</from-view-id>
  <navigation-case>
   <from-outcome>success</from-outcome>
   <to-view-id>/registration_success.xhtml</to-view-id>
  </navigation-case>
 </navigation-rule>
</faces-config>

beans.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
       version="1.1" bean-discovery-mode="all">
</beans>