Error loading Primefaces theme with @Named bean while it wor

UI Components for JSF
Post Reply
non-serviam
Posts: 2
Joined: 14 Sep 2014, 04:21

16 Sep 2014, 23:59

I am having an error on loading a theme using JSF 2.2 and Primefaces 5. I have the below bean:

Code: Select all

 package beans;

    import java.io.Serializable;
    import javax.faces.bean.ManagedBean;
    import javax.faces.bean.SessionScoped;

    @ManagedBean(name = "themeSwitcher")
    @SessionScoped
    public class ThemeSwitcher implements Serializable {

    private String theme;

    public ThemeSwitcher () {      
        theme = "afterdark";                   
    }   
    
    public String getTheme() {
        
        return theme;
    }

    public void setTheme(String theme) {
        this.theme = theme;
    }
}
which works perfectly. When I try to change it to @Named in order to be able to inject it to my other beans am getting this error:

Code: Select all

FATAL:   JSF1073: javax.faces.FacesException caught during processing of RENDER_RESPONSE 6 : UIComponent-ClientId=, Message=Error loading theme, cannot find "theme.css" resource of "primefaces-" library
    FATAL:   Error loading theme, cannot find "theme.css" resource of "primefaces-" library
    javax.faces.FacesException: Error loading theme, cannot find "theme.css" resource of "primefaces-" library
    	at org.primefaces.renderkit.HeadRenderer.encodeTheme(HeadRenderer.java:117)
    	at org.primefaces.renderkit.HeadRenderer.encodeBegin(HeadRenderer.java:72)
    	at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:869)
    	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1854)
    	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
    	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
    	at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:443)
    	at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
    	at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)
    	at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)
    	at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
    	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    	at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
    	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)
    	at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:344)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
    	at filters.AuthenticationFilter.doFilter(AuthenticationFilter.java:136)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:316)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
    	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
    	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
    	at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
    	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
    	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
    	at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
    	at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
    	at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
    	at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
    	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
    	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
    	at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
    	at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
    	at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
    	at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
    	at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
    	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
    	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
    	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
    	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
    	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
    	at java.lang.Thread.run(Thread.java:745)
My web.xml:


Code: Select all

 <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
        <context-param>
            <param-name>javax.faces.PROJECT_STAGE</param-name>
            <param-value>Development</param-value>
        </context-param>
        <context-param>
            <param-name>primefaces.THEME</param-name>
            <param-value>#{themeSwitcher.theme}</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>/PropertyWS/*</url-pattern>
        </servlet-mapping>
        <session-config>
            <session-timeout>
                60
            </session-timeout>
        </session-config>
        <security-constraint>
            <web-resource-collection>
                <web-resource-name>Security</web-resource-name>
                <url-pattern>*.xhtml</url-pattern>
            </web-resource-collection>
            <user-data-constraint>
                <transport-guarantee>CONFIDENTIAL</transport-guarantee>
            </user-data-constraint>
        </security-constraint>
        <welcome-file-list>
            <welcome-file>/public/index.xhtml</welcome-file>
        </welcome-file-list>
    </web-app>
I am using Netbeans 8 and I have added the jars to the Libraries. I also tried to put them in a WEB-INF/lib folder but it did not helped. Any suggestions?

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

17 Sep 2014, 22:06

hmmm, in this forum topic and your previous forum topic, I see no XHTML (p:themeSwitcher, h:head, h:body, h:form, etc...)
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

18 Sep 2014, 14:25

try putting the 'theme="afterdark" from the constructor to a method annotated with @PostConstruct

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 21 guests