1

I have been trying to work with BootsFaces. I have ensured the following requirements are satisfied:

  1. Java EE 1.6 above
  2. Jsf-api and jsf-impl 2.2 above JAR file
  3. MyFaces api and impl 2.2 above JAR file
  4. BootsFaces 0.7.0 JAR file

Also I've followed the steps for correct rendering as listed on the BootsFaces document (changes to web.xml and faces-config file)

I had created a sample jsf (medium) file and had tried to run it.

I got an error saying

javax.servlet.ServletException: Error loading theme, cannot find "css/theme.css" resource of "bsf" library
javax.faces.webapp.FacesServlet.service(FacesServlet.java:321)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

*Project Structure

Faces-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<faces-config
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-facesconfig_2_2.xsd"
version="2.2">
<application>
   <resource-handler>net.bootsfaces.render.UnmappedResourceHandler</resource-handler>
</application>    
</faces-config>

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"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID"
version="3.0">
<context-param>
    <param-name>BootsFaces_USETHEME</param-name>
    <param-value>true</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>*.jsf</url-pattern>
    <url-pattern>/javax.faces.resource/*</url-pattern>
</servlet-mapping>    
</web-app>

medium.jsf

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:b="http://bootsfaces.net/ui" xmlns:f="http://java.sun.com/jsf/core"> 
<h:head />

<h:body>
    <b:container>
      <b:row>
        <b:column span="8">
           <b:panel look="primary" title="b:column span='8'">
            Eight columns on medium screens (e.g. small desktop and notebook screens).<br /> Stacked on screens smaller than 992 pixels width.
            <br />

           </b:panel>
        </b:column>
      </b:row>
    </b:container>
</h:body>

Blessen George
  • 270
  • 3
  • 18

1 Answers1

1

When BootsFaces doesn't find its resources, I recommend to use the CombinedResourceHandler of OmniFaces. You're already using the UnmappedResourceHandler of BootsFaces, which should do the trick, but I suggest you try the OmniFaces version nonetheless (and report back if it helps).

Here's a checklist checking the most frequent pitfalls we've seen so far:

  1. Make sure you've added a <h:head></h:head> tag (even if it's empty). Do not use the HTML tag (<head />).
  2. Check the URL pattern of the web.xml. Many tutorials recommend to put the JSF files into a virtual folder, such as <url-pattern>/pages/</url-pattern> . Don't do that. There's nothing wrong with simple patterns like <url-pattern>*.jsf</url-pattern>. By the way, this is the default, so you can safely omit the url-pattern altogether.
  3. If that fails, add the CombinedResourceHandler of OmniFaces. This always does the trick for me.
  4. Check the URL in your browser. Maybe you entered localhost:8080/index.xhtml instead of localhost:8080/index.jsf?
  5. If you're still stuck, open an issue on the BootsFaces GitHub repository (https://github.com/TheCoder4eu/BootsFaces-OSP/issues). But first read https://github.com/TheCoder4eu/BootsFaces-OSP/issues/157 - your problem is probably already fixed there.
Stephan Rauh
  • 3,069
  • 2
  • 18
  • 37