cancel
Showing results for 
Search instead for 
Did you mean: 

JSF 2.0 application on NWDS 7.3

Former Member
0 Kudos

Hi All,

I was trying to implement a JSF 2.0 application (using primefaces) in NWDS 7.3, following the blog series written by George Ushakov. I am Using NWDS 7.3 SP04. Initially I had the web page named as Home.html instead of Home.xhtml. So, when I run the application, blank page was getting displayed (without any error) and view source was showing all the tags in the page as is.

I changed the extention of the file to xhtml. After deployment I am getting "503 Service Unavailable" error, when i try to access this home page. The error message is "Error: demo.sap.com~testapp~web/Home.xhtml is temporarily unavailable."

Am I doing anything wrong here? How do we add XHTML pages, to web module in NWDS?

Any pointers on this would be of great help!

Thanks & Regards,

Vishweshwara P.K.M.

 

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Vishweshwara,

You specify which files you want to process with JSF servlet in the web.xml file of the web module, see servlet mapping:

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

The response (error) which you are getting probably means that the xhtml pages are being associated with JSF servlet (if you have configured web.xml the same way) but that there is something which prevents the servlet to execute normally. You need to dig deeper, maybe see the error output on the log console for defaultTrace.

George

Former Member
0 Kudos

Hi George,

I have done the servlet mapping in web.xml, the way you have mentioned. I checked the log files for the error and below are the, two exceptions thrown every time i try running the Home.Xhtml

Exception 1:

Cannot process an HTTP request to servlet [Faces Servlet] in [demo.sap.com~testapp~web] web application.
[EXCEPTION]
javax.servlet.ServletException: while trying to invoke the method javax.faces.context.FacesContext.getExternalContext() of an object loaded from local variable 'context'
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)

...

...

Caused by: java.lang.NullPointerException: while trying to invoke the method javax.faces.context.FacesContext.getExternalContext() of an object loaded from local variable 'context'

at com.sun.faces.renderkit.RenderKitImpl.createResponseWriter(RenderKitImpl.java:188)

at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:189)

at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)

at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)

at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)

at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)

Exception 2:

Oct 16, 2012 11:14:07 AM com.sun.faces.lifecycle.Phase doPhase
SEVERE: JSF1054: (Phase ID: RENDER_RESPONSE 6, View ID: /Home.xhtml) Exception thrown during phase execution: javax.faces.event.PhaseEvent[source=com.sun.faces.lifecycle.LifecycleImpl@605ab827]

I am not sure about these exceptions. Please help me in fixing this.

Thanks & Regards,

Vishweshwara P.K.M.


Former Member
0 Kudos

Hi Vishweshwara,

I'm not sure about these exceptions either, obviously the AS has recognized the xhtml as needed to be processed with the JSF engine. There seems to be the problem with the injection of the external context into your JSF application. It is not clear from the trace if the AS is trying to use the built-in JSF 1.2 library or your JSF 2.0 which you must have deployed to the server and referenced in your EAR's application-j2ee-engine.xml file, see in the post above, especially the prepend attribute:

<reference reference-type="hard" prepend="true">

        <reference-target provider-name="local.j2ee"

            target-type="library">javax~faces~2.1.7</reference-target>

    </reference>

Make sure you have your web.xml declared to version 2.5 and faces-config.xml to version 2.0 like in the post above. Also check in the "Deployment perspective" of your NWDS that your JSF 2.0 library (javax~faces~2.1.7 in my case) is deployed and has a "library" (properties view) Software type.

Hopefully this helps, best regards,

George

Answers (0)