Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error loading theme, cannot find "theme.css" resource of primefaces theme library

I use primefaces-5.1.jar andjavax.faces-2.2.0.jar(i got some error forjavax.faces-2.2.9.jar`)

Put this also in web.xml

<context-param>
    <param-name>primefaces.THEME</param-name>
    <param-value>#{Helper.theme}</param-value>
</context-param>

then i got error:

Error loading theme, cannot find "theme.css" resource of "primefaces-bootstrap" library

javax.faces.FacesException: Error loading theme, cannot find "theme.css" resource of "primefaces-bootstrap" library
    at org.primefaces.renderkit.HeadRenderer.encodeTheme(HeadRenderer.java:134) ~[primefaces-5.1.jar:5.1]
    at org.primefaces.renderkit.HeadRenderer.encodeBegin(HeadRenderer.java:81) ~[primefaces-5.1.jar:5.1]
    at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:869) ~[javax.faces-2.2.0.jar:2.2.0]
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1854) ~[javax.faces-2.2.0.jar:2.2.0]
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859) ~[javax.faces-2.2.0.jar:2.2.0]
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:443) ~[javax.faces-2.2.0.jar:2.2.0]
    at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131) ~[javax.faces-2.2.0.jar:2.2.0]
    at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337) ~[javax.faces-2.2.0.jar:2.2.0]
    at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337) ~[javax.faces-2.2.0.jar:2.2.0]
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120) ~[javax.faces-2.2.0.jar:2.2.0]
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) ~[javax.faces-2.2.0.jar:2.2.0]

But when i use javax.faces-2.1.25.jar the error above is solved but get another error:

com.sun.faces.context.flash.ELFlash getCurrentFlashManager
SEVERE: JSF1094: Could not decode flash data from incoming cookie value Invalid characters in decrypted value.  Processing will continue, but the flash is unavailable for this request.

My question is what compatible library for primefaces-5.1.jar ?

Thanks

like image 756
Diana Avatar asked Mar 13 '15 05:03

Diana


3 Answers

Put Primefaces Theme Maven dependecy into your pom.xml

<dependency>
  <groupId>org.primefaces.extensions</groupId>
  <artifactId>all-themes</artifactId>
  <version>1.0.8</version>
  <scope>compile</scope>
</dependency>

Official documentation suggests use the 10.0.10 version of Primefaces themes, requesting add their own repository, which is not working properly and I was still receiving an error and this version of themes is not available in the Maven Central Repository.

After much research without an effective solution, I had need to opt to the last version of Maven repository whose is available only up to version 1.0.8. but my project still getting the following warning:

WARNING: JSF1064: Unable to find or serve resource, images/ui-bg_highlight-hard_70_000000_1x100.png, from library, primefaces-bootstrap.

WARNING: JSF1064: Não foi possível encontrar ou fornecer o recurso, images/ui-bg_highlight-hard_70_000000_1x100.png, pela biblioteca, primefaces-bootstrap.

Thinking a little bit I found a simple solution that solves the bootstrap theme problem.

The solution is :

  • Pass a new path to the image that is missed
  • Replace the property background of ui-widget-shadow css class

Steps:

  1. Download missed image : | Link 1 | Link 2 | Link 3 |
  • All links refer to: ui-bg_highlight-hard_70_000000_1x100.png
  1. Place this image in a folder of your project (Suggestion: /resources/images/)
  2. Overwrite only the property that has the invalid reference to the image

Use the following code:

.ui-widget-shadow {
   background-image: url("images/ui-bg_highlight-hard_70_000000_1x100.png.jsf") !important;
}

That problem is discussed in:

  • https://forum.primefaces.org/viewtopic.php?f=9&t=19250&start=10
like image 138
ℛɑƒæĿᴿᴹᴿ Avatar answered Nov 09 '22 00:11

ℛɑƒæĿᴿᴹᴿ


Add dependency to pom.xml

<dependency>
    <groupId>org.primefaces</groupId>
    <artifactId>primefaces</artifactId>
    <version>5.0</version>
</dependency>
<dependency>  
    <groupId>org.primefaces.themes</groupId>  
    <artifactId>cupertino</artifactId>  
    <version>1.0.8</version>  
</dependency>

Add configuration to web.xml

<context-param>
    <param-name>primefaces.THEME</param-name>
    <param-value>#{LayoutBean.applicationTheme}</param-value>
</context-param>

Create an application scoped eager bean to load when the JSF application loads

@ManagedBean(name = "LayoutBean", eager = true)
@ApplicationScoped
public class LayoutBean {

    private String theme = "cupertino";

    public String getApplicationTheme() {
        return theme;
    }
}
like image 29
conteh Avatar answered Nov 09 '22 00:11

conteh


  • Make sure that the dependency is well added in pom.xml (Add manually jar to maven local repository if this is premium theme, more info here)

    <dependency>
      <groupId>org.primefaces.themes</groupId>
      <artifactId>{theme-name-here}</artifactId>
      <version>{version-here}</version>
    </dependency>
    
  • Add the correct configuration in web.xml for use this theme.

    <context-param>
      <param-name>primefaces.THEME</param-name>
      <param-value>#{theme-name-here}</param-value>
    </context-param>
    

I had a case where everything was set up correctly but the message "Error loading theme, cannot find “theme.css” resource of primefaces theme library" still appeared. I solved it:

  • Project in Eclipse --> clean... --> Clean all projects
  • Right click in project --> refresh
  • Go to servers view --> right click in Tomcat installation --> Clean and Publish
  • Run app.

This remove all cache files, works for me.

like image 1
Deoxyseia Avatar answered Nov 08 '22 22:11

Deoxyseia