Can't get CXF JAX-RS and JSF to work together - jsf

I'm trying to setup a small example application FooTest that uses CXF JAX-RS and JSF. I started with the CXF part, implemented a simple service (works) and a small html page called home.html (I can access it in my browser). The relevant code is as follows:
web.xml
<servlet>
<servlet-name>RestServlet</servlet-name>
<servlet-class>org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet</servlet-class>
<init-param>
<param-name>jaxrs.serviceClasses</param-name>
<param-value>com.test.FooService</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>RestServlet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
FooService.java
#Path("/rest")
public class FooService {
#Path("/foo")
#GET
#Produces("application/json; charset=UTF-8")
public String getFoo() {
// returns json
}
}
Now I can call http://localhost:8080/FooTest/rest/foo and http://localhost:8080/FooTest/home.html. However when I start defining and mapping the FacesServlet to *.html and try to access home.html I get a NullPointerException.
New web.xml
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
... CXF stuff ...
Leads to
Apr 25, 2013 6:08:17 AM org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet Faces Servlet threw exception
java.lang.NullPointerException
at org.apache.myfaces.shared.context.flash.FlashImpl.isKeepMessages(FlashImpl.java:388)
at org.apache.myfaces.shared.context.flash.FlashImpl._saveMessages(FlashImpl.java:665)
at org.apache.myfaces.shared.context.flash.FlashImpl.doPostPhaseActions(FlashImpl.java:269)
at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:254)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:199)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:487)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:412)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339)
at org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:369)
at org.apache.myfaces.view.jsp.JspViewDeclarationLanguage.buildView(JspViewDeclarationLanguage.java:99)
at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:78)
at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:241)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:199)
... infinite loop from FacesServlet:199 on ...
How can I fix this?
Update - More config info
The application runs on the JAX-RS version of TomEE 1.5.2.
src/main/webapp/WEB-INF/faces-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<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_1.xsd"
version="2.1">
</faces-config>
Update - Solution
(Thanks to David Blevins for clarification and pointing me to a useful example)
Remove the CXF configuration part, it is not required. Rename home.html to home.xhtml, since .xhtml is the javax.faces.DEFAULT_SUFFIX for JSF pages. Keep the FacesServlet mapping if you want to access your JSF pages using the .html extension. This is sufficient:
<?xml version="1.0" encoding="UTF-8"?>
<web-app ... >
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
</web-app>

Not sure whether this should be a comment or an answer, but you shouldn't setup CXFNonSpringJaxrsServlet and FacesServlet in your web.xml, all that stuff is there and ready to go. The goal with TomEE is you can skip the server-building and proceed directly to app-building.
CXF is fully integrated into Tomcat in TomEE to the point where even WS-Security works on Tomcat Realms. You just start using it by adding #ApplicationPath annotated components or EJBs annotated with #Path and they will be picked up and deployed automatically.
MyFaces is good to go and fully integrated with CDI so even things like #ConversationScoped work out of the box. You just need your faces-config.xml or some #ManagedBean classes.

Related

Tomcat8 start failure with Primefaces JSF App

I have a JSF2.2 application running fine on Tomcat7. I now have to move it to Tomcat8 and the application is not starting anymore.
The error is:
03-Jul-2019 15:41:47.655 INFO [localhost-startStop-1] org.primefaces.webapp.PostConstructApplicationEventListener.processEvent Running on PrimeFaces 5.1
03-Jul-2019 15:41:47.655 INFO [localhost-startStop-1] org.primefaces.webapp.PostConstructApplicationEventListener.processEvent Running on PrimeFaces 5.1
03-Jul-2019 15:41:47.655 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file
03-Jul-2019 15:41:47.659 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal Context [/NPSAdmin] startup failed due to previous errors
03-Jul-2019 15:41:47.662 SEVERE [localhost-startStop-1] javax.faces.FactoryFinder$FactoryManager.getFactory Application was not properly initialized at startup, could not find Factory: javax.faces.application.ApplicationFactory. Attempting to find backup.
03-Jul-2019 15:41:47.663 SEVERE [localhost-startStop-1] com.sun.faces.config.ConfigureListener.contextDestroyed Unexpected exception when attempting to tear down the Mojarra runtime
java.lang.IllegalStateException: Could not find backup for factory javax.faces.application.ApplicationFactory.
at javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.java:1135)
at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:379)
at com.sun.faces.config.InitFacesContext.getApplication(InitFacesContext.java:140)
at com.sun.faces.config.ConfigureListener.contextDestroyed(ConfigureListener.java:310)
at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4817)
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5474)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:226)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:754)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:730)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:980)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1851)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
I have been searching for similar issues and could not solve it. In my tomcat lib I have the servlet-api.jar, but no other jsf related file.
In my webapp I have:
jsf-api-2.2.2.jar
jsf-impl-2.2.2.jar
primefaces-5.1.jar
No other jar like javax.faces have been found in the lib directories
We can also see from the logs that primefaces is found and activated:
org.primefaces.webapp.PostConstructApplicationEventListener.processEvent Running on PrimeFaces 5.1
So my feeling is that it is not a classpatch issue explaining why the Factory was not found.
I searched the tomcat logs, but there is nothing in it
I am running this issue with Tomcat8 on mac osX and on ubuntu
My web.xml is like this:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" 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>NPSAdmin</display-name>
<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>/faces/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<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>
<context-param>
<param-name>javax.faces.FACELETS_LIBRARIES</param-name>
<param-value>/WEB-INF/springsecurity.taglib.xml</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/applicationContext.xml
/WEB-INF/securityContext.xml
</param-value>
</context-param>
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>npsadmin</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.context.request.RequestContextListener
</listener-class>
</listener>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<!-- JNDI DB Connection -->
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/AnonymDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
Thank you for your comments. I had also tried to remove com.sun.faces.config.ConfigureListener entry in web.xml.
This did not change.
The reason was simple: a spring component could not start because of a configuration issue. This is where the issue was. The error message was misleading.
I corrected the the configuration and it works.
Please be aware that this error message can be misleading

Facelets error page works during ajax request with FullAjaxExceptionHandler, but does not evaluate EL during synchronous request

I am trying to configure a normal (non-ajax) request error page using Omnifaces library. I am able to use the FullAjaxExceptionHandler and with ajax request error and its page as shown in the demo. When I use the same error page with normal request the error page is shown, but the values are displayed as source code (for example Date/time: #{of:formatDate(now, 'yyyy-MM-dd HH:mm:ss')} User agent: #{header['user-agent']} .. are displayed in the browser as it is).
I am using Tomcat 7, JSF 2.2 (MyFaces), Weld 2.6 (for CDI), Omnifaces 2.0 and Primefaces 5.1. The following is the relevant code.
The page:
<h:commandButton value="Throw runtime exception on normal request"
action="#{appbean.throwRuntimeException}"/>
<p:commandButton value="Throw runtime exception on AJAX request"
action="#{appbean.throwRuntimeException}"/>
The bean:
public void throwRuntimeException() {
throw new RuntimeException("peek-a-boo");
}
faces-config:
<factory>
<exception-handler-factory>
org.omnifaces.exceptionhandler.FullAjaxExceptionHandlerFactory
</exception-handler-factory>
</factory>
web.xml:
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<filter>
<filter-name>facesExceptionFilter</filter-name>
<filter-class>org.omnifaces.filter.FacesExceptionFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>facesExceptionFilter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
<error-page>
<exception-type>java.lang.RuntimeException</exception-type>
<location>/WEB-INF/errorpages/error2.xhtml</location>
</error-page>
The <error-page><location> must match the FacesServlet mapping in order to get FacesServlet to run on the error page too during an exception on a synchronous request (which doesn't use ViewHandler#renderView(), but RequestDispatcher#forward()).
Alter the mapping accordingly:
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
Using /faces/* (and *.faces) is soo JSF 1.0/1.1. If you really need to keep /faces/* for some reason (e.g. existing webapp with already published URLs), then just use both (and migrate with 301s accordingly):
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
See also:
JSF returns blank/unparsed page with plain/raw XHTML/XML/EL source instead of rendered HTML output

Declaring custom PDF servlets collides with .xhtml extension

I'm trying to implement a custom PDF file servlet (/fileprovider/name?param1=value&param2=otherValue) on a JSF 2 web application, but when declaring it on web.xml the application always adds .xhtml extension to every request. I believe due to the DEFAULT_SUFFIX context-param.
<!-- ... -->
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<context-param>
<param-name>org.omnifaces.FACES_VIEWS_SCAN_PATHS</param-name>
<param-value>/*.xhtml</param-value>
</context-param>
<servlet>
<servlet-name>faces</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>MyPDFServlet</servlet-name>
<servlet-class>com.company.servlet.MyPDFServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MyPDFServlet</servlet-name>
<url-pattern>/fileprovider/name</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>faces</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<!-- ... -->
The exception thrown is:
FacesFileNotFoundException: /name.xhtml Not Found in ExternalContext as a Resource
So I believe that the path is not mapped correctly, maybe I'm missing something.
Is there any way to specify that I want specific paths to point to custom servlets without adding .xhtml extension?

java.lang.StackOverflowError at javax.faces.context.FacesContext.getAttributes(FacesContext.java:64)

when I hit the application URL (http://localhost:9082/pages/upload.jsf), i am shown nothing but "Error:500 StackOverflowError" on the browser.
From my groundwork on this issue, I could see this could propably be due to some recursion issue.
And the server on which my application is deployed is WAS 8
Somebody please help me on how to proceed with this. I know this is vague, please let me know if I need to share anything. (Eg. error messages on the console and stuff)
at javax.faces.context.FacesContext.getAttributes(FacesContext.java:64)
at javax.faces.context.FacesContext.getAttributes(FacesContext.java:64)
[the same line repeated many times]
at javax.faces.context.FacesContext.getAttributes(FacesContext.java:64)
at javax.faces.context.FacesContext.getAttributes(FacesContext.java:64)
at org.apache.myfaces.application.ResourceHandlerImpl.isResourceRequest(ResourceHandlerImpl.java:416)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:180)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1188)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:763)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:454)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:125)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:92)
at com.lmig.putt.customComponents.UploadFilter.doFilter(UploadFilter.java:61)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:192)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:89)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:919)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1016)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3703)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:962)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:195)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:452)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:511)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:305)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:276)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture$1.run(AsyncChannelFuture.java:205)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1659)
` this is the error message that I find on console once I hit the URL. Please help me as I find it totally new and a hard nut to crack
Web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>PUTT</display-name>
<context-param>
<param-name>log4ConfigLocation</param-name>
<param-value>/WEB-INF/classes/log4j.properties</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/application-context.xml</param-value>
</context-param>
<!-- Log4jConfigListener also tries to
set the webAppRootKey. solve this by adding the following statements in web.xml -->
<context-param>
<param-name>log4jExposeWebAppRoot</param-name>
<param-value>false</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<jsp-config>
<taglib>
<taglib-uri>http://www.lmig.com/PUTT/upload</taglib-uri>
<taglib-location>/WEB-INF/upload.tld</taglib-location>
</taglib>
</jsp-config>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<filter>
<filter-name>Upload Filter</filter-name>
<filter-class>com.lmig.putt.customComponents.UploadFilter</filter-class>
<init-param>
<param-name>com.lmig.putt.customComponents.UploadFilter.sizeThreshold</param-name>
<param-value>1024</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Upload Filter</filter-name>
<url-pattern>/pages/upload.jsf</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>Upload Filter</filter-name>
<url-pattern>/pages/upload.jsp</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>
javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<resource-ref>
<description>DataSource</description>
<res-ref-name>jdbc/db2DS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
</web-app>
faces-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- <faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xi="http://www.w3.org/2001/XInclude"
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_1_2.xsd"> -->
<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">
.
.
.
.
</faces-config>
Based on MyFaces 2.0.5 source code, where the line numbers from your stack trace matches, the FacesContext#getAttributes() look like this:
55 public Map<Object, Object> getAttributes()
56 {
57 FacesContext ctx = _firstInstance.get();
58
59 if (ctx == null)
60 {
61 throw new UnsupportedOperationException();
62 }
63
64 return ctx.getAttributes();
65 }
In other words, the _firstInstance.get() is in your specific case incorrectly returning the current instance. This suggests that at some point in the code elsewhere the following action has taken place in JSF internal code:
FacesContext.setCurrentInstance(FacesContext.getCurrentInstance());
This is not right. The FacesContext's current instance should not be referring to itself. It would only result in an infinite loop of accessing itself everytime, as evident by the stack trace.
Also, the fact that you apparently got your web application to successfully deploy with a Mojarra-specific listener in your web.xml
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
suggests that you've MyFaces' competitor Mojarra in webapp's runtime classpath. In other words, you're mixing two completely distinct JSF implementations! This is definitely not right. It's like mixing gasoline and diesel in one car engine. IBM WebSphere ships with MyFaces bundled. You should remove any Mojarra-related JAR files (jsf-api.jar, jsf-impl.jar and/or javax.faces.jar), configuration entries (com.sun.faces.*) and other artifacts from your webapp. They're conflicting with MyFaces.
See also:
JSF Deploy Error "at javax.faces.context.FacesContext.isProcessingEvents(FacesContext.java:300)"
JSF implementations and component libraries
Difference between Mojarra and MyFaces
This error could be due to class loading issue. Most Likely you are deploying your app in WAS 7.0 or later version.
To fix this,
go to WAS console and open
Applications ==> Enterprise Applications==> Manager Modules==>your war module
select "Classes loaded with local class loader first (parent last)." for Class loader order
Click "Apply" and "Save"

RichFaces GUI displayed as text

I am running a simple RichFaces example. Mainly using Tabs. The example is shown on
JBoss website found at:
http://richfaces-showcase.appspot.com/richfaces/component-sample.jsf?demo=tabPanel&skin=blueSky
Running the code results in the following page:
Overview
«
↓
»
RichFaces is a component library for JSF and an advanced framework for easily integrating
AJAX capabilities into business applications.
100+ AJAX enabled components in two libraries
...
Notice the overview should be a clickable tab. Instead I get
Overview
«
↓
»
There is no error messages from the GlassFish server. I am using Netbeans with Facelets, RichFaces 4.0 and JSF 2.0.
My web.xml is
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.SKIN</param-name>
<param-value>blueSky</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.CONTROL_SKINNING</param-name>
<param-value>enable</param-value>
</context-param>
<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>/faces/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>faces/richexample.xhtml</welcome-file>
</welcome-file-list>
</web-app>
Library:
richfaces-components-api-4.0.0.Final.jar
richfaces-components-ui-4.0.0.Final.jar
richfaces-core-api-4.0.0.Final.jar
richfaces-core-impl-4.0.0.Final.jar
sac-1.3.jar
guava-10.0.1.jar
cssparser-0.9.5.jar
GlassFish 3.x (libraries)
Appreciate any hint or feedback as I do not have a clue why graphics are not displayed.
What URL did you use to access your page? In your web.xml you mapped Faces Servlet to the /faces prefix, so your URL must include this (even though your actual page is not really on that path).
You can add additional mappings in your web.xml, like the common *.jsf or *.xhtml or replace the existing one, e.g.
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>

Resources