5

I created a Java JSF application in NetBeans 8.02 with GlassFish 4.1. One of the web pages created as a facelet contains the following tags:

   <h:head>
      <title>Address Book: Add Entry</title>
      <h:outputStylesheet name="style.css" library="css"/>
   </h:head>

When I run the application I get the error:

Unable to find resource css, style.css

I look in the Web Pages/ resources /css folder in my project and style.css is present. If I add the style.css folder from another project, everything works fine.

What do I need to do so that either style.css is automatically placed in the correct folder instead of me manually having to do it --- or is there something missing in how I set up my project or wrote the xhtml tag?

jisteinberg
  • 71
  • 1
  • 3
  • 10
  • 1
    If the `style.css` file is really available under `/ resources /css` on the application root, then check out the deployed WAR file to see, if `style.css` is really available there in the desired directory. If it is unavailable in the deployed WAR, then you may have accidentally forgotten to do a hard deploy after `style.css` had been created which NetBeans basically requires whenever you create new folders/directories and put some files into them. – Tiny Apr 03 '15 at 19:52

4 Answers4

11

Seems to me that you are not using the correct /resources folder, you should use the /resources directory in the root of your web application as mentionned by Tiny's comment (subfolder of WebContent), And not the resources folder which contain your java classes. Here is an example:

enter image description here

However, you are not correctly using the h:outputStylesheet, you should better use it like this:

<h:outputStylesheet name="css/styles.css" />

A detailled answer regarding the JSF resource library was provided by BalusC: What is the JSF resource library for and how should it be used?

Community
  • 1
  • 1
Tarik
  • 4,961
  • 3
  • 36
  • 67
  • In the Project view resources/css is under the Web Pages folder. In the File view resources/css is under build/web/, web/ and in the .war file under dist/. In each case, it only contains cssLayout.css and default.css, not style.css. Even after I change h:outputStylesheet per Tarik and do a hard deploy style.css does is not added to any resources/css folder. – jisteinberg Apr 06 '15 at 15:55
  • @jisteinberg I can't understand what you are saying, please go to your WebContent folder, if you don't have a sub folder named resources then create one, after that create a css folder and put your styles.css file in it. which part is not clear ? – Tarik Apr 06 '15 at 15:59
  • I manually placed the styles.css file in the resources/css folder and it worked. Thanks. So that file is not automatically created under the css folder when you reference it in the facelet and deploy the project? – jisteinberg Apr 06 '15 at 19:11
  • @jisteinberg NO. Why it will be created and how? The styles.css file include your css parameters and preferences, it could be any other name (myCss.css, ...) that you reference in your facelet in order to include it. Please refer to the link in my answer, and see the answer provided by BalusC, that will help you more to understand the process – Tarik Apr 06 '15 at 19:17
2

I had the same problem with NetBean 8.1. I solved this problem by writing

h:outputStylesheet name="resources/css/default.css"

h:outputStylesheet name="resources/css/cssLayout.css"

I did not change the location to the style files: the path to the stylesheet files in the project view of NetBean 8.1

1

This seems to be an issue with Netbeans 8.1. However, version 7 generates the template page correctly.

Try replacing h:outputStylesheet tag with one below:

<link href="./resources/css/style.css" rel="stylesheet" type="text/css"/> 
0

Try this:

I had the same problem but easy to solve if You aware of the attribute library to get the default path for Me.

The default location for css StyleSheets is "./resources/css/yourcss.css"