4

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
  • What about if you remove the webapplication from your server.xml and move the war into the dropins directory?
    – Pete
    Commented Mar 10, 2017 at 1:57

1 Answer 1

3

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

4
  • Thanks, setting jsf to not be packaged with the .war in the project properties fixed the issue. Commented Mar 11, 2017 at 0:26
  • @JerryB.no.1intern How fix the problem? Can you explain me it in details
    – JGarnica
    Commented Jul 5, 2017 at 18:35
  • @Crack81 I solved it by removing the <feature>webProfile-7.0<feature> if you have it and add features explicitly as mentioned above making sure you have no duplicates (this is what caused my problem) between features provided in your .war and those provided by your server Commented Jul 5, 2017 at 22:13
  • Thanks for your answer, I removed the feature but the problem continues
    – JGarnica
    Commented Jul 6, 2017 at 3:44

Not the answer you're looking for? Browse other questions tagged or ask your own question.