2014-06-17 12 views
5

Iv ha letto molti post ma non ha avuto successo nel risolvere questo problema. Un aiuto per favore ....RES_NOT_FOUND in JSF

Eclipse Juno/JSF

Struttura Progetto: enter image description here

teste.xhtml:

<!DOCTYPE html[ 
    <!ENTITY nbsp "&#160;"> 
    <!ENTITY copy "&#169;"> 
] > 
<html xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:f="http://java.sun.com/jsf/core" 
    xmlns:h="http://java.sun.com/jsf/html" 
    xmlns:ui="http://java.sun.com/jsf/facelets"> 
<h:head> 
    <h:outputScript library="js" name="slides.min.jquery.js"/> 
    <h:graphicImage value="images/blog.png" /> 
    <h:outputStylesheet name="css/estilo.css"/> 
    </h:head> 
    <h:body> 
    #{javax.faces.resource} 
    </h:body> 
    </html> 

L'output è:

<link type="text/css" rel="stylesheet" href="RES_NOT_FOUND"> 

Lo stesso res_not_found a js e image

pom.xml:

<dependencies> 
    <dependency> 
     <groupId>javax</groupId> 
     <artifactId>javaee-api</artifactId> 
     <version>6.0</version> 
     <scope>provided</scope> 
    </dependency> 

<dependency> 
    <groupId>org.primefaces</groupId> 
    <artifactId>primefaces</artifactId> 
    <version>4.0</version> 
</dependency> 

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

<dependency> 
    <groupId>com.sun.facelets</groupId> 
    <artifactId>jsf-facelets</artifactId> 
    <version>1.1.14</version> 
</dependency> 


<dependency> 
    <groupId>com.sun.faces</groupId> 
    <artifactId>jsf-impl</artifactId> 
    <version>2.1.23</version> 
    <scope>provided</scope> 
</dependency> 

<dependency> 
    <groupId>com.sun.faces</groupId> 
    <artifactId>jsf-api</artifactId> 
    <version>2.1.23</version> 
    <scope>provided</scope> 
</dependency>  

<dependency> 
    <groupId>javax.faces</groupId> 
    <artifactId>javax.faces-api</artifactId> 
    <version>2.2</version> 
</dependency> 

<dependency> 
    <groupId>javax.servlet</groupId> 
    <artifactId>servlet-api</artifactId> 
    <version>3.0-alpha-1</version> 
    <scope>provided</scope> 
</dependency> 
<dependency> 
    <groupId>rome</groupId> 
    <artifactId>rome</artifactId> 
    <version>1.0</version> 
</dependency> 

<dependency> 
    <groupId>org.apache.pdfbox</groupId> 
    <artifactId>pdfbox</artifactId> 
    <version>1.8.3</version> 
</dependency> 

<!-- REPOSITORIOS MAVEN --> 
<repositories> 
    <repository> 
     <id>prime-repo</id> 
     <name>PrimeFaces Maven Repository</name> 
     <url>http://repository.primefaces.org</url> 
     <layout>default</layout> 
    </repository> 
    <repository> 
     <id>jboss-repo</id> 
     <name>Jboss Maven Repository</name> 
     <url>http://repository.jboss.org</url> 
    </repository> 
</repositories> 

<build> 
    <plugins> 
     <!-- -CONFIGURANDO PLUGIN PARA GERACAO DOCUMENTAÇÃO --> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-war-plugin</artifactId> 
      <version>2.3</version> 
      <configuration> 
        <outputDirectory>/srv/jboss-as-7.1.0.Final/standalone/deployments</outputDirectory> 
      </configuration> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-site-plugin</artifactId> 
      <version>3.2</version> 
      <configuration> 
       <locales>pt-BR</locales> 
      </configuration> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-deploy-plugin</artifactId> 
      <version>2.7</version> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-assembly-plugin</artifactId> 
      <version>2.4</version> 
      <configuration> 
       <!-- <descriptorRefs> <descriptorRef> jar-with-dependencies </descriptorRef> 
        </descriptorRefs> --> 
      </configuration> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>3.0</version> 
      <configuration> 
       <executable>${JAVA_HOME}/bin/javac</executable> 
       <compilerVersion>1.6</compilerVersion> 
       <source>1.6</source> 
       <target>1.6</target> 
      </configuration> 
     </plugin> 
     <plugin> 
      <artifactId>maven-resources-plugin</artifactId> 
      <version>2.6</version> 
      <executions> 
       <execution> 
        <id>copy-resources</id> 
        <phase>validate</phase> 
        <goals> 
         <goal>copy-resources</goal> 
        </goals> 
        <configuration> 
         <outputDirectory>${basedir}/target/abc/resources 
         </outputDirectory> 
         <resources> 
          <resource> 
           <directory>src/main/resources</directory> 
           <filtering>true</filtering> 
          </resource> 
         </resources> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 

</build> 

<properties> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
</properties> 

jboss-web.xml

<?xml version="1.0" encoding="UTF-8"?> 

<jboss-web xmlns="http://www.jboss.com/xml/ns/javaee" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee 
           http://www.jboss.org/j2ee/schema/jboss-web_5_1.xsd"> 
    <!-- URL to access the web module --> 
    <context-root>/</context-root> 
</jboss-web> 

web.xml

<servlet> 
    <servlet-name>Faces Servlet</servlet-name> 
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> 
    </servlet> 
    <servlet-mapping> 
    <servlet-name>Faces Servlet</servlet-name> 
    <url-pattern>*.xhtml</url-pattern> 
    </servlet-mapping> 

Ive ha provato un sacco di impostazioni per h: outputStyleSheet ma senza successo .....

grazie in anticipo

risposta

7

La cartella Resources deve essere all'interno della cartella webapp, non nel package principale main.

resources folder inside webapp

e mantenere il codice stesso

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

Non usare il css come una libreria.

guarda anche:

+0

Quando creare un progetto Java Maven ha creato automaticamente le risorse al di fuori webapp e ho un altro progetto con risorse esterne webapp, ma non so come questo progetto è ricevendo questo errore – Al2x

+0

La cartella delle risorse nella root principale viene utilizzata per i pacchetti di messaggi con i file '.properties', ad esempio, non per le risorse Web. –

+0

Vedi anche questo link: http://www.mkyong.com/jsf2/jsf-2-0-and-resource-bundles-example/ –