Stacked Q&A

WebSphere Application Server for Liberty not finding Context-Root
  • 3 voting
  • 2022-06-26 00:00

    I’m a new starter to using Java EE to build a dynamic web project in Eclipse. At first all was going well, I could run my web project locally on my WebSphere Application Server for Liberty (version 16.0.0.4) and access my webpages from

    localhost:9080/MainApplication

    and push to my remote server on IBM BlueMix and everything also still worked.

    During development I discovered JavaServer Faces capabilities. So I went into my project in eclipse and added the JSF facet using the Mojara 2.2 JSF Implementation library. As soon as I added the JSF facet to my project, every time I tried to run my web application locally, I would be met with a “Context Root Not Found” Error Page. Even trying to access my web pages directly (localhost:9080/MainApplication/index.html) resulted in the same error. However pushing to my remote server still works and my web project runs JSF normally, So this is leading me to believe there’s something wrong with my WebSphere Application Server configuration on my local machine.

    Reverting by removing the JSF facet from my application in Eclipse fixes the problem, and re-adding the facet re-introduces the problem. According to this link, adding a JSF facet only imports the JSF implementation library of your choice into the project, adds a “Faces configuration file” and updates your web.xml with the faces servlet configuration. So I don’t understand why adding the JSF facet is causing the server to not find the context root. Here is my web.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app 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_3_0.xsd" version="3.0">
        <display-name>MainApplication</display-name>
        <welcome-file-list>
            <welcome-file>index.xhtml</welcome-file>
        </welcome-file-list>
        <context-param>
            <description>
            State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
            <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
            <param-value>client</param-value>
        </context-param>
        <context-param>
            <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
            <param-value>resources.application</param-value>
        </context-param>
        <listener>
            <listener-class>com.sun.faces.config.ConfigureListener</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-mapping>
            <servlet-name>Faces Servlet</servlet-name>
            <url-pattern>*.xhtml</url-pattern>
        </servlet-mapping>
    </web-app>
    

    and server.xml:

    <server description="new server">
    
        <!-- Enable features -->
        <featureManager>
            <feature>webProfile-7.0</feature>
            <feature>localConnector-1.0</feature>
            <feature>adminCenter-1.0</feature>
        </featureManager>
    
        <basicRegistry id="basic">
          <user name="admin" password="adminpwd"/>
       </basicRegistry>
    
       <administrator-role>
          <user>admin</user>
       </administrator-role>
    
        <remoteFileAccess>
            <writeDir>${server.config.dir}</writeDir>
        </remoteFileAccess>
    
        <!-- To access this server from a remote client add a host attribute to the following element, e.g. host="*" -->
        <httpEndpoint httpPort="9080" httpsPort="9443" id="defaultHttpEndpoint"/>
    
        <!-- Automatically expand WAR files and EAR files -->
        <applicationManager autoExpand="true"/>
    
        <applicationMonitor updateTrigger="mbean"/>
        <keyStore id="defaultKeyStore" password="adminpwd"/>
    
        <webApplication id="MainApplication" location="MainApplication.war" name="MainApplication" contextRoot="MainApplication" type=""/>
    </server>
    

    I have tried starting a new project and adding the JSF from scratch instead of later on, and I have the same problem. I have tried adding contextRoot=”MainApplication” to my server.xml under my web Project and that also doesn’t work. If I right click on my project -> properties -> Web Project Settings -> Context root: The value is set to MainApplication. One stackoverflow post had a similar issue here: WebSphere Liberty Profile: Context Root Not Found But his fix involved some files that I do not have in my project (ibm-web-ext.xml & ibm-web-bnd.xml). Neverthless I tried creating these files in my WEB-INF directory and still didn’t work.

    I have spent the past 3 days looking for a solution and have gotten nowhere and have exhausted all my ideas. Any help is appreciated.

  • 1 6456 0 0
첨부 파일
답변
총 1개의 답변이있습니다.
  • 답변일: 2022-06-26 00:00

    The webProfile-7.0 feature brings in the jsf-2.2 feature, so the problem might be due to the two jsf implementations. To ensure that that is not the problem, you could list each feature that webprofile provides independently, but removing jsf, so: jsp-2.3, ejbLite-3.2, managedBeans-1.0, beanValidation-1.1, servlet-3.1, ssl-1.0, jndi-1.0, jsonp-1.0, appSecurity-2.0, jdbc-4.1, jaxrs-2.0, jaxrsClient-2.0, el-3.0, json-1.0, jpaContainer-2.1, cdi-1.2, distributedMap-1.0, websocket-1.1, jpa-2.1

    Plus your two other features: adminCenter-1.0, localConnector-1.0

  • 0 0 채택된 답변 퍼블 채택!
Tages
    활동순위
    유저
      파트너사