简体   繁体   中英

Context-root with JSF 2.3 Web Application on GlassFish 5

I have a hard time trying to configure the context-root for my web application consisting of two artifacts, a Web Archive and an EJB.jar (XYZ_war.war and XYZ_ejb.jar)

I can reach the application without any problems using localhost/XYZ
(or on the remote server using www.domain.xy/XYZ)

but

with localhost
(or www.domain.xy)

the Glassfish default website from the docroot directory is displayed ('Your server is now runnning ...')

I do the deployment using the GlassFish Web Admin console. All my searching here or elsewhere didn't help so far. What am I missing?

Any help would be much appreciated. Thanks!

glassfish-web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish 
Application Server 3.1 Servlet 3.0//EN" 
"http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app>
    <context-root>/XYZ</context-root>
</glassfish-web-app>

web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         id="WebApp_ID" version="3.1">
    <display-name>XYZ</display-name>
    <welcome-file-list>
        <welcome-file>index.xhtml</welcome-file>
    </welcome-file-list>

    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.xhtml</url-pattern>
    </servlet-mapping>

    <session-config>
        <session-timeout>15</session-timeout>
    </session-config>
</web-app>

domain.xml:

<network-listeners>
    ...
    <network-listener protocol="http-listener-1" port="80" name="http-listener-1" thread-pool="http-thread-pool" transport="tcp">
    ... 
</networklistener>
...
<applications>
    <application context-root="/XYZ" object-type="user" name="XYZ_war" location="${com.sun.aas.instanceRootURI}/applications/XYZ_war/">
        ...
    </application>
    <application object-type="user" name="XYZ_ejb" location="${com.sun.aas.instanceRootURI}/applications/XYZ_ejb/">
        ...
    </application>
</applications>

So if I understand correctly you are setting your context-root to /XYZ and you expect it to be / ? How about setting it to / ?

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish 
Application Server 3.1 Servlet 3.0//EN" 
"http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app>
    <context-root>/</context-root>
</glassfish-web-app>

Have fun :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM