Hebert_Coelho 30 de mai. de 2012
Como você está chamando a pagina xhtml?
gambazinho 30 de mai. de 2012
Ivan_Sotelo_Codo 30 de mai. de 2012
Então, tenho uma index.html que redireciona para uma inclusao.xthml, mas no redirecionamento uso inclusao.jsf.
O retorno é que o recurso não existe.
O código que usei é justamente o que encontrei no site indicao acima pelo gambazinho.
Hebert_Coelho 30 de mai. de 2012
Cara, eu não vi lá o link.
Mas quando você redireciona, você está adicionando o faces? /faces/*
Ivan_Sotelo_Codo 31 de mai. de 2012
Tentei de duas formas, na primeira:
web.xml
& lt ;? xml version = "1.0" encoding = "UTF-8" ?& gt ;
& lt ; web-app xmlns : xsi = "http://www.w3.org/2001/XMLSchema-instance"
xmlns = "http://java.sun.com/xml/ns/javaee" xmlns : web = "http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
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" & gt ;
& lt ; display-name & gt ; Educor & lt ;/ display-name & gt ;
& lt ; context-param & gt ;
& lt ; param-name & gt ; javax . faces . DEFAULT_SUFFIX & lt ;/ param-name & gt ;
& lt ; param-value & gt ; . jsp & lt ;/ param-value & gt ;
& lt ;/ context-param & gt ;
& lt ;! -- Facelets pages will use the . xhtml extension -- & gt ;
& lt ; context-param & gt ;
& lt ; param-name & gt ; javax . faces . FACELETS_VIEW_MAPPINGS & lt ;/ param-name & gt ;
& lt ; param-value & gt ;* . xhtml & lt ;/ param-value & gt ;
& lt ;/ context-param & gt ;
& lt ; servlet & gt ;
& lt ; servlet-name & gt ; Faces Servlet & lt ;/ servlet-name & gt ;
& lt ; servlet-class & gt ; javax . faces . webapp . FacesServlet & lt ;/ servlet-class & gt ;
& lt ;/ servlet & gt ;
& lt ;! -- Use prefix mapping for Facelets pages , e . g . http :// localhost : 8080 / webapp / faces / mypage . xhtml -- & gt ;
& lt ; servlet-mapping & gt ;
& lt ; servlet-name & gt ; Faces Servlet & lt ;/ servlet-name & gt ;
& lt ; url-pattern & gt ;/ faces /*& lt ;/ url-pattern & gt ;
& lt ;/ servlet-mapping & gt ;
index.html
& lt ; html & gt ;
& lt ; head & gt ;
& lt ; meta http-equiv = "refresh" content = "0; url=http://localhost:8080/Educor/faces/inclusao.xhtml" & gt ;
& lt ;/ head & gt ;
& lt ;/ html & gt ;
inclusao.xhtml
& lt ;! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" & gt ;
& lt ; html xmlns : ui = "http://java.sun.com/jsf/facelets"
xmlns : h = "http://java.sun.com/jsf/html"
xmlns : f = "http://java.sun.com/jsf/core"
xmlns : ice = "http://www.icesoft.com/icefaces/component" & gt ;
& lt ; h : head & gt ;
& lt ; link rel = "StyleSheet" type = "text/css" href = "css/estilos.css" media = "screen" /& gt ;
& lt ; / h : head & gt ;
& lt ; h : body & gt ;
& lt ; h : form & gt ;
& lt ; h : outputText id = "teste" value = "#{testeBean.nome}" & gt ; & lt ; / h : outputText & gt ;
& lt ; h : commandButton value = "teste" action = "#{testeBean.teste}" /& gt ;
& lt ; / h : form & gt ;
& lt ; / h : body & gt ;
& lt ; / html & gt ;
E o erro que dá é o seguinte:
31 / 05 / 2012 10 : 20 : 22 org . apache . catalina . core . StandardWrapperValve invoke
GRAVE : Servlet . service () for servlet [ Faces Servlet ] in context with path [ / Educor ] threw exception
com . sun . faces . context . FacesFileNotFoundException : / inclusao . xhtml Not Found in ExternalContext as a Resource
at com . sun . faces . facelets . impl . DefaultFaceletFactory . resolveURL ( DefaultFaceletFactory . java : 232 )
at com . sun . faces . facelets . impl . DefaultFaceletFactory . resolveURL ( DefaultFaceletFactory . java : 273 )
at com . sun . faces . facelets . impl . DefaultFaceletFactory . getMetadataFacelet ( DefaultFaceletFactory . java : 209 )
at com . sun . faces . application . view . ViewMetadataImpl . createMetadataView ( ViewMetadataImpl . java : 114 )
at com . sun . faces . lifecycle . RestoreViewPhase . execute ( RestoreViewPhase . java : 233 )
at com . sun . faces . lifecycle . Phase . doPhase ( Phase . java : 101 )
at com . sun . faces . lifecycle . RestoreViewPhase . doPhase ( RestoreViewPhase . java : 116 )
at com . sun . faces . lifecycle . LifecycleImpl . execute ( LifecycleImpl . java : 118 )
at javax . faces . webapp . FacesServlet . service ( FacesServlet . java : 593 )
at org . apache . catalina . core . ApplicationFilterChain . internalDoFilter ( ApplicationFilterChain . java : 305 )
at org . apache . catalina . core . ApplicationFilterChain . doFilter ( ApplicationFilterChain . java : 210 )
at org . apache . catalina . core . StandardWrapperValve . invoke ( StandardWrapperValve . java : 225 )
at org . apache . catalina . core . StandardContextValve . invoke ( StandardContextValve . java : 169 )
at org . apache . catalina . authenticator . AuthenticatorBase . invoke ( AuthenticatorBase . java : 472 )
at org . apache . catalina . core . StandardHostValve . invoke ( StandardHostValve . java : 168 )
at org . apache . catalina . valves . ErrorReportValve . invoke ( ErrorReportValve . java : 98 )
at org . apache . catalina . valves . AccessLogValve . invoke ( AccessLogValve . java : 927 )
at org . apache . catalina . core . StandardEngineValve . invoke ( StandardEngineValve . java : 118 )
at org . apache . catalina . connector . CoyoteAdapter . service ( CoyoteAdapter . java : 407 )
at org . apache . coyote . http11 . AbstractHttp11Processor . process ( AbstractHttp11Processor . java : 999 )
at org . apache . coyote . AbstractProtocol$AbstractConnectionHandler . process ( AbstractProtocol . java : 565 )
at org . apache . tomcat . util . net . JIoEndpoint$SocketProcessor . run ( JIoEndpoint . java : 309 )
at java . util . concurrent . ThreadPoolExecutor$Worker . runTask ( ThreadPoolExecutor . java : 886 )
at java . util . concurrent . ThreadPoolExecutor$Worker . run ( ThreadPoolExecutor . java : 908 )
at java . lang . Thread . run ( Thread . java : 662 )
Caso eu altere na index.html para redirecionar para inclusao.jsf aí o erro é outro:
HTTP Status 404 - /Educor/inclusao . jsf
--------------------------------------------------------------------------------
type Status report
message /Educor/inclusao . jsf
description The requested resource (/Educor/inclusao . jsf) is not available .
A página inclusao.xhtml está no diretório faces.
Alguma idéia do que possa ser?
Abraços
Hebert_Coelho 31 de mai. de 2012
Você fez o teste como eu falei? Não adianta o arquivo está no diretório faces, ele não irá mapear.
você declarou com /faces/ na url, é assim que você deve chamar.
Ivan_Sotelo_Codo 31 de mai. de 2012
Sim, coloquei sim, olha lá em cima no web.xml a declaração e no redirect da index.html também, não faço a mínima idéia do que seja, mas mudou uma coisa aqui, se eu tirar só o mapeamento da JSP
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.jsp</param-value>
</context-param>
aí tudo funciona normalmente.
Ivan_Sotelo_Codo 31 de mai. de 2012
Galera,
Resolvi, ficou assim o código do meu web.xml:
& lt ; servlet & gt ;
& lt ; servlet - name & gt ; Faces Servlet & lt ; / servlet - name & gt ;
& lt ; servlet - class & gt ; javax . faces . webapp . FacesServlet & lt ; / servlet - class & gt ;
& lt ; load - on - startup & gt ; 1 & lt ; / load - on - startup & gt ;
& lt ; / servlet & gt ;
& lt ; servlet - mapping & gt ;
& lt ; servlet - name & gt ; Faces Servlet & lt ; / servlet - name & gt ;
& lt ; url - pattern & gt ; *. jsf & lt ; / url - pattern & gt ;
& lt ; / servlet - mapping & gt ;
& lt ; context - param & gt ;
& lt ; param - name & gt ; javax . faces . DEFAULT_SUFFIX & lt ; / param - name & gt ;
& lt ; param - value & gt ; . jsp . xhtml & lt ; / param - value & gt ;
& lt ; / context - param & gt ;
Era só adicionar o .jsp .xhtml (com espaço em branco mesmo) entre os dois sufixos, para ele adicionar os sufixos quando direcionar.
Descobri aqui:
http://myfaces.apache.org/core20/myfaces-impl/webconfig.html
Fica aí a solução para quem precisar.
Abraços e obrigado a todos que colaboraram.