0

I have Weblogic 10.3.5 installed. I deployed the JSF 2.0 war on the server. In my WebContent folder, I have *.xhtml and *.jsp files, which contain JSF2.0 xhtml and pure JSP code, respectively. When I navigate to http://localhost:7001/MyApp/NewFile123.xhtml, I get a 404 Not found error page. (Nothing informative on the Eclipse console). But http://localhost:7001/MyApp/NewFile.jsp works well and does what it's supposed to do.

I am not mixing JSF and JSP but just wanted to see if JSP is gonna work. I have the appropriate servlet-mapping for the XHTML files.

I also have these on my classpath:

  • glassfish.el_1.0.0.0_2-2.jar

  • glassfish.jsf_1.0.0.0_2-1-5.jar

  • glassfish.jstl_1.2.0.2.jar

  • javax.servlet_1.0.0.0_2-5.jar

Another interesting thing, when I try to edit the *.xhtml files, the auto-complete doesn't work. (i.e it won't autocomplete <h:outp. It used to when I was using Weblogic 12.1 which has JSF2.0 out of the box.

Edit: Here is the relevant part of web.xml

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

So why do I get a 404 when I try to navigate to a JSF page? Any suggestions?

Murat Derya Özen
  • 2,154
  • 8
  • 31
  • 44

1 Answers1

1

I also have these on my classpath:

  • glassfish.el_1.0.0.0_2-2.jar
  • glassfish.jsf_1.0.0.0_2-1-5.jar
  • glassfish.jstl_1.2.0.2.jar
  • javax.servlet_1.0.0.0_2-5.jar

Remove all those container-specific libraries from your /WEB-INF/lib. They do not belong there at all, the container already ships with them. Your /WEB-INF/lib should contain only the webapp-specific libraries which are not shipped with the container.

Your problem is most likely caused by the fact that Weblogic 1.0.3.5 is a Servlet 2.5 container which already ships with JSF 2.0, but that you're supplying a JSF 2.1 library which requires Servlet 3.0. I don't use Weblogic, but I've read that 1.0.3.x requires some specific steps to get JSF 2.0 to work, see also this blog. Here's an extract of relevance:

  • Download and install one of the latest Oracle WebLogic Server 11g Rel 1 (10.3.3) Installers from OTN. (Give the ZIP Installer a try. Aweseome lightweight!)
  • Create a new sample domain (call it whatever you want) and start the admin server
  • Open the administration console (http://localhost:7001/console/)
  • deploy the JSF 2.0 library (Deployments - Install - wlserver_10.3\common\deployable-libraries\jsf-2.0.war
  • Find your favorite JSF 2.0 sample (I'll take the guessNumber thing from the mojarra-2.0.2 distribution)
  • Add a weblogic.xml file to the WEB-INF/ folder with the following content:

    <?xml version="1.0" encoding="UTF-8"?>
    <weblogic-web-app>
      <library-ref>
        <library-name>jsf</library-name>
        <specification-version>2.0</specification-version>
        <implementation-version>1.0.0.0_2-0-2</implementation-version>
        <exact-match>true</exact-match>
      </library-ref>
    </weblogic-web-app>
    

Update as per the comments:

I now suspect that it may be because of the project settings. I created a Dynamic Web Project and chose JSF 1.2. On the next step, where it asked me for the JSF specification and implementation, I pointed him to those glassfish jsf2 jars. The default was 1.2. Maybe I shouldn't have done that?

That might have generated a JSF 1.2 compliant faces-config.xml which would force JSF 2.0 to run in JSF 1.2 modus. You need to redeclare the <faces-config> root declaration to comply JSF 2.0.

<faces-config
    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-facesconfig_2_0.xsd"
    version="2.0">
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • BalusC, thanks for the answer. I did exactly the same things mentioned on that blog to set this all up. I removed the jars from `/WEB-INF/lib`. I deployed the JSF 2.0 library and changed my `weblogic.xml` as the extract says. However, I still get 404 not founds on *.xhtml pages with no luck. Interestingly, my filters, servlets and JSPs work pretty well. – Murat Derya Özen Jan 16 '12 at 12:20
  • Try a different URL pattern. E.g. `*.jsf` or `/faces/*` instead of `*.xhtml`. – BalusC Jan 16 '12 at 12:21
  • I now suspect that it may be because of the project settings. I created a Dynamic Web Project and chose JSF 1.2. On the next step, where it asked me for the JSF specification and implementation, I pointed him to those glassfish jsf2 jars. The default was 1.2. Maybe I shouldn't have done that? – Murat Derya Özen Jan 16 '12 at 12:23
  • Ah that might have generated a JSF 1.2 compliant `faces-config.xml` which would force JSF 2.0 to run in JSF 1.2 modus. Redeclare the `` root declaration to comply JSF 2.0. – BalusC Jan 16 '12 at 12:26
  • Thank you very much! That was part of the problem and a very simple page is now working. That very simple page has ` ` and that's all. And the panel is displayed when I navigate to the page. However, I have a somewhat more complex page with some beans and ajax and all. It still gives me 404 not found. Unfortunately, I cannot post that page here. But why might that be? I mean what could be different in that page that makes it crash and 404? – Murat Derya Özen Jan 16 '12 at 12:53
  • Last but not least, I couldn't get autocomplete working. How do I go about that? – Murat Derya Özen Jan 16 '12 at 12:54
  • If a simple page works, but a complex one gives a 404, then that can only mean that you didn't get the URLs right. As to the autocomplete, that's offtopic and IDE specific. I don't use Netbeans, so I can't give hints about that. – BalusC Jan 16 '12 at 13:01
  • Now I suspect Primefaces 3.0 might be causing some trouble. What about EL 2.2? I have method calls (as in `#{someBean.do()}`) with arguments. Is it possible that this EL 2.2 stuff breaks it? But it would throw an exception wouldn't it? I hate such error/failures without any log... – Murat Derya Özen Jan 16 '12 at 13:01
  • I use Eclipse. And not getting the URLs right? I don't think so. Because I created a page with very simple name: `a.xhtml`. Copy and pasted the erroneous content to it. Now, `a.xhtml` is 404 not found too. :) I triple-check what I write at the address bar, with no luck :( – Murat Derya Özen Jan 16 '12 at 13:05
  • EL 2.2 is part of Servlet 3.0 and not supported in Servlet 2.5 without supplying own EL factory. A commonly used one for Servlet 2.5 is JBoss EL. See also http://stackoverflow.com/questions/3284236/jsf-2-0-method-invocation – BalusC Jan 16 '12 at 13:06
  • Ah you're using Eclipse. The Glassfish server plugin used to ship with useful JSF tools like autocomplete. For other servers like JBoss AS and Tomcat you could use the JBoss Tools plugin. Although I've never used Weblogic and thus can't tell from experience, the JBoss Tools should be server independent. As to the 404 on a complex page, this can also happen if an include file cannot be found. Perhaps you've configured a `FileNotFoundException` or `FaceletFileNotFoundException` as `` pointing to a 404 in `web.xml`? – BalusC Jan 16 '12 at 13:08
  • I don't have a single `` tag in my `web.xml`. I'm wearing out of options :( Could the use of EL 2.2 specific functionality cause such a 404 error? Guess not... – Murat Derya Özen Jan 16 '12 at 13:27
  • I still experience the 404 Not Found error on the page I mentioned. I am now starting with a clean project. At the config screen, would it be better to choose `Minimal Configuration` or `Default Configuration for Oracle Webl....` instead of `JavaServer Faces v1.2 Project`? – Murat Derya Özen Jan 16 '12 at 19:17