ova2 / primefaces-cookbook

PrimeFaces Cookbook - recipes to leading JSF component suite
http://ova2.github.com/primefaces-cookbook/
99 stars 92 forks source link

cannot find "theme.css" resource of "primefaces-" library #7

Open limsongjing opened 8 years ago

limsongjing commented 8 years ago

Hi

I use tomcat 9 on top of jdk1.8, after download the package, I un-comment the mojarra profile section and run "mvn install -P mojarra"

war file is successfully build. However when running, it give me the error shown below.

[Error] 29-Aug-2016 01:13:53.279 SEVERE [http-nio-8080-exec-6] com.sun.faces.application.view.FaceletViewHandlingStrategy.handleRenderException Error Rendering View[/views/chapter11/errors/throwable.xhtml] javax.faces.FacesException: Error loading css, cannot find "theme.css" resource of "primefaces-" library at org.primefaces.renderkit.HeadRenderer.encodeCSS(HeadRenderer.java:145) at org.primefaces.renderkit.HeadRenderer.encodeBegin(HeadRenderer.java:77) at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:864)

Firstly it seem like the them 1.0.10 is not available in Maven repo, so I changed to 1.0.8 https://mvnrepository.com/artifact/org.primefaces.extensions/all-themes

But still same error. Any help?

So far the workaround is modify web.xml to hard code the theme name as shown below.

primefaces.THEME cupertino

Rgds SJ

dianmorales commented 7 years ago

To make it run in Tomcat9 you also have to take care of the dependencies as well.

<dependencies>
                <dependency>
                    <groupId>com.sun.faces</groupId>
                    <artifactId>jsf-api</artifactId>
                    <version>${mojarra.version}</version>
                    <scope>provided</scope>
                </dependency>
                <!--
                <dependency>
                    <groupId>com.sun.faces</groupId>
                    <artifactId>jsf-impl</artifactId>
                    <version>${mojarra.version}</version>
                    <scope>provided</scope>
                </dependency>
                -->
            </dependencies>

should looks like

<dependencies>
                <dependency>
                    <groupId>com.sun.faces</groupId>
                    <artifactId>jsf-api</artifactId>
                    <version>${mojarra.version}</version>
                </dependency>
                <dependency>
                    <groupId>com.sun.faces</groupId>
                    <artifactId>jsf-impl</artifactId>
                    <version>${mojarra.version}</version>
                </dependency>
            </dependencies>

and @limsongjing said, the theme must be hardcoded otherwise won't work.

    <context-param>
        <param-name>primefaces.THEME</param-name>
        <param-value>cupertino</param-value>
    </context-param>