0

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>

1 Answers1

0

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 :)

unwichtich
  • 13,712
  • 4
  • 53
  • 66
  • Thank you very much for trying to help. I changed the context-root in glassfish-web.xml as you suggested. Unfortunately it still doesn't work (still displaying the GlassFish 'Welcome page'). – Ingi from INGiSOFT Apr 04 '18 at 19:23
  • Finally solved. I found the solution here on Stackoverflow. https://stackoverflow.com/questions/41585188/setting-context-root-with-glassfish-application-server?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa Thank you! – Ingi from INGiSOFT Apr 09 '18 at 12:19