Solucionado (ver solução)
Solucionado
(ver solução)
12
respostas

HTTP Status 500 - /jsf-livraria/livro.xhtml Not Found in ExternalContext as a Resource

Depois de seguir as orientações do vídeo da primeira aula e criar o arquivo livro.xhtml, tentei iniciar o tomcat para executar a aplicação, porém, o mesmo retorna o seguinte erro: HTTP Status 500 - /jsf-livraria/livro.xhtml Not Found in ExternalContext as a Resource O arquivo livro.xhtml está no diretório WebContent (workspace\jsf-livraria\WebContent\livro.xhtml)

Gostaria de saber a causa do erro.

Abaixo o detalhamento do erro:

dez 05, 2016 9:47:16 AM org.apache.catalina.core.StandardWrapperValve invoke
GRAVE: Servlet.service() for servlet [FacesServlet] in context with path [] threw exception
java.io.FileNotFoundException: /jsf-livraria/livro.xhtml Not Found in ExternalContext as a Resource
    at com.sun.faces.facelets.impl.DefaultFaceletFactory.resolveURL(DefaultFaceletFactory.java:224)
    at com.sun.faces.facelets.impl.DefaultFaceletFactory.resolveURL(DefaultFaceletFactory.java:265)
    at com.sun.faces.facelets.impl.DefaultFaceletFactory.getMetadataFacelet(DefaultFaceletFactory.java:201)
    at com.sun.faces.application.view.ViewMetadataImpl.createMetadataView(ViewMetadataImpl.java:114)
    at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:227)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:111)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:508)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:301)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:136)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:78)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:526)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1033)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:652)
    at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1566)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1523)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)
12 respostas

Cara eu acho que o seu erro é a url digitada errada...

A pagina xhtml está dentro da sua pasta webContent? Faz um teste, copia e cola sua pagina do xhtml dentro do webContent, sem criar outras pastas... Só joga sua pagina criada dentro do webContent, e sua url tenta algo assim.

localhost:8080/jsf-livraria/livro.xhtml

Posta o seu arquivo xml pra gente dar uma olhada?

Seguem os arquivos faces-config.xml e web.xml

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">
</faces-config>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">
  <display-name>jsf-livraria</display-name>
  <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>*.xhtml</url-pattern>
  </servlet-mapping>
</web-app>

Verifiquei se o arquivo livro xhtml consta na pasta WebContent e ele está lá.

Em qual diretório está a sua página xhtml? Coloque o caminho dela aqui.

o arquivo livro.xhtml está em:

C:\Users\wbento\workspace\jsf-livraria\WebContent\livro.xhtml

Vi que o console do tomcat está gerando vários erros na inicialização. Acredito que possa estar relacionado ao problema:

GRAVE: Critical error during deployment: 
com.sun.faces.config.ConfigurationException: Factory 'javax.faces.context.FacesContextFactory' was not configured properly.
    at com.sun.faces.config.processor.FactoryConfigProcessor.verifyFactoriesExist(FactoryConfigProcessor.java:305)
    at com.sun.faces.config.processor.FactoryConfigProcessor.process(FactoryConfigProcessor.java:219)
    at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:361)
    at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:223)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4748)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5170)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1396)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1386)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: javax.faces.FacesException: com.sun.faces.context.InjectionFacesContextFactory
    at javax.faces.FactoryFinder.getImplGivenPreviousImpl(FactoryFinder.java:632)
    at javax.faces.FactoryFinder.getImplementationInstance(FactoryFinder.java:508)
    at javax.faces.FactoryFinder.access$400(FactoryFinder.java:138)
    at javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.java:995)
    at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:342)
    at com.sun.faces.config.processor.FactoryConfigProcessor.verifyFactoriesExist(FactoryConfigProcessor.java:303)
    ... 12 more
Caused by: java.lang.IllegalArgumentException: argument type mismatch
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at javax.faces.FactoryFinder.getImplGivenPreviousImpl(FactoryFinder.java:625)
    ... 17 more

dez 05, 2016 11:29:05 AM org.apache.catalina.core.StandardContext listenerStart
GRAVE: Exception sending context initialized event to listener instance of class com.sun.faces.config.ConfigureListener
java.lang.RuntimeException: com.sun.faces.config.ConfigurationException: Factory 'javax.faces.context.FacesContextFactory' was not configured properly.
    at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:290)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4748)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5170)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1396)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1386)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: com.sun.faces.config.ConfigurationException: Factory 'javax.faces.context.FacesContextFactory' was not configured properly.
    at com.sun.faces.config.processor.FactoryConfigProcessor.verifyFactoriesExist(FactoryConfigProcessor.java:305)
    at com.sun.faces.config.processor.FactoryConfigProcessor.process(FactoryConfigProcessor.java:219)
    at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:361)
    at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:223)
    ... 9 more
Caused by: javax.faces.FacesException: com.sun.faces.context.InjectionFacesContextFactory
    at javax.faces.FactoryFinder.getImplGivenPreviousImpl(FactoryFinder.java:632)
    at javax.faces.FactoryFinder.getImplementationInstance(FactoryFinder.java:508)
    at javax.faces.FactoryFinder.access$400(FactoryFinder.java:138)
    at javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.java:995)
    at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:342)
    at com.sun.faces.config.processor.FactoryConfigProcessor.verifyFactoriesExist(FactoryConfigProcessor.java:303)
    ... 12 more
Caused by: java.lang.IllegalArgumentException: argument type mismatch
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at javax.faces.FactoryFinder.getImplGivenPreviousImpl(FactoryFinder.java:625)
    ... 17 more

Qual URL tu tá usando para acessar? Seu projeto está com alguém erro ou algum warning? Se estiver poste aí.

Esta usando as bibliotecas corretas?

Imagino que sim. Segui as orientaçãoes do vídeo da aula 1. Só adicionei o jar javax.faces-2.1.16.jar na pasta WEB-INF/Lib.

solução!

Após reinstalar o tomcat, excluir as pastas "workspace.metadata.plugins\org.eclipse.wst.server.core\tmp*" o problema foi solucionado. Imagino que possa ser alguma "sujeira" no arquivo web.xml do tomcat instalado. De qualquer forma, o problema tá resolvido e posso continuar os estudos.

Obrigado a todos pelas orientações.