Erro JSF + TomCat...não consigo resolver.....(básico)

11 respostas
IMPERIO

Pessoal, estou tentando implementar um exemplo, simples com Maven + Jsf + TomCat, porém está dando um erro que não consigo descobrir. Já faz alguns dias que estou quebrando a cabeça porém não consigo resolver…procurei no Fórum problemas iguais mas não consegui resolver o meu será que alguem pode me ajudar ?

Acredito que o problema está no TomCat e o JSF, pois quando deixo meu index.jsp sem as tags do JSF funciona.

Segue o erro:

type Exception report

message 

description The server encountered an internal error () that prevented it from fulfilling this request.

exception 

org.apache.jasper.JasperException: An exception occurred processing JSP page /index.jsp at line 4

1:<%@taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
2: <%@taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
3: <html>                                                                                                               
4: 	<f:view>
5:         <head>
6:             <title>JSP Page</title>
7:         </head>


Stacktrace:
	org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


root cause 

java.lang.NullPointerException
	com.sun.faces.taglib.jsf_core.ViewTag.doStartTag(ViewTag.java:162)
	org.apache.jsp.index_jsp._jspx_meth_f_005fview_005f0(index_jsp.java:90)
	org.apache.jsp.index_jsp._jspService(index_jsp.java:64)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


note The full stack trace of the root cause is available in the Apache Tomcat/6.0.29 logs.

index.jsp (QUE DÁ O ERRO)

<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%@taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<html>
	<f:view>
        <head>
            <title>JSP Page</title>
        </head>
        <body>
            <h1><h:outputText value="Hello World!"/></h1>
        </body>
	</f:view>
</html>

index.jsp (NÃO DÁ O ERRO)

<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%@taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<html>
	
        <head>
            <title>JSP Page</title>
        </head>
        <body>
            <p>Hello World!</p>
        </body>
	
</html>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
	<!--
		Use this definition if using a Java EE 6 container This also stops
		Eclipse from complaining that 3.0 is not a valid version <web-app
		version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xsi:schemaLocation=" http://java.sun.com/xml/ns/javaee
		http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
	-->
<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_2_5.xsd"
	version="2.5">
	<welcome-file-list>
		<welcome-file>index.jsp</welcome-file>
	</welcome-file-list>
	<context-param>
		<param-name>facelets.DEVELOPMENT</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>
	</servlet-mapping>
	<listener>  
         <listener-class>com.sun.faces.config.ConfigureListener</listener-class>  
    </listener>  
	<resource-env-ref>
		<description>Object factory for the CDI Bean Manager</description>
		<resource-env-ref-name>BeanManager</resource-env-ref-name>
		<resource-env-ref-type>javax.enterprise.inject.spi.BeanManager</resource-env-ref-type>
	</resource-env-ref>
</web-app>

Já criei uma pasta lib no WEB-INF e coloquei os seguintes jars:
comons-beanutils.jar
commons-digester-2.1.jar
commons-logging-1.1.1.jar
jff-api-1.2.jar
jsf-impl-1.2-NIGHTLY_20060227.jar

Coloquei esses mesmos jars na pasta lib do eclipse.

Achando que pudesse ser isso criei ate um faces-config

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

<!-- =========== FULL CONFIGURATION FILE ================================== -->

<faces-config version="1.2" 
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
        
</faces-config>

Caso alguém puder me ajudar agradeço !

11 Respostas

R

nunca usei o maven, nao sei como ele funciona, talvez eu esteja falando uma bobagem aqui, mas ja tentou adicionar as libs do jsf ao buildpath manualmente ?

IMPERIO

Entaum RMarcel, não tentei até pq o Maven se encarrega de fazer isso.
Acredito que esse não seja o problema.

R

pois é, eu sabia que o maven cuidava dos jars automaticamente, mas tenta add os jars no braco mesmo, pode ser que funcione …

V

Qual a url vc está colocando no browser para acessar?
index.jsp?
Caso esteja desta forma troque por index.jsf.

ricardo13

E como ta o seu pom ??

Ricardo

V

No browser vc está chamando o jsp de que forma? index.jsp ou index.jsf? Se estiver index.jsp chame por index.jsf

IMPERIO

Pessoal, estou no trampo e chegando em casa vou realizar todos os testes…

Muito obrigado por enquanto… espero que consiga fazer funcionar, na verdade preciso que funcione…

Assim que conseguir dou o retorno.

henrriquetec

conseguiu alguma coisa? funcionou?

IMPERIO

Aew … cheguei agora e vim testar…

http://localhost:8080/hello/index.jsf - sucesso !!!

http://localhost:8080/hello/index.jsp - erro

http://localhost:8080/hello/ -erro

Caraca não acredito…mas agora alguem pode me explicar o que to fazendo de errado ?
Pois meu web.xml não tá mapeando tudo que for *.jsf (ele pega os meus JSPs transforma em jsf ?).

Pra mim qdo digitasse no browser http://localhost:8080/hello/ já deveria funcionar…

Se aguem puder esclarecer melhor…

Agradeço a todos pela atenção…

R

Tá faltando jar ai(o do facelets,por exemplo)

IMPERIO

jar não deve ser pois qdo coloco no browser :

http://localhost:8080/hello/index.jsf

Abre certinho !

De qualquer forma segue o meu pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.teste</groupId>
  <artifactId>hello</artifactId>
  <packaging>war</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>hello Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
	<!-- JSF Dependencies -->
	<dependency>
		<groupId>org.hibernate</groupId>
		<artifactId>hibernate-validator</artifactId>
		<version>4.0.0.GA</version>
		<scope>compile</scope>
	</dependency>
	<dependency>
		<groupId>org.hibernate</groupId>
		<artifactId>hibernate-entitymanager</artifactId>
		<version>3.5.0-Beta-2</version>
		<scope>compile</scope>
	</dependency>
	<dependency>
		<groupId>org.hibernate.javax.persistence</groupId>
		<artifactId>hibernate-jpa-2.0-api</artifactId>
		<version>1.0.0.Final</version>
		<scope>compile</scope>
	</dependency>
	<dependency>
		<groupId>commons-digester</groupId>
		<artifactId>commons-digester</artifactId>
		<version>2.1</version>
	</dependency>
	<dependency>
		<groupId>org.hibernate</groupId>
		<artifactId>hibernate-commons-annotations</artifactId>
		<version>3.3.0.ga</version>
	</dependency>
	<dependency>
		<groupId>commons-beanutils</groupId>
		<artifactId>commons-beanutils</artifactId>
		<version>20030211.134440</version>
	</dependency>
	<dependency>
		<groupId>commons-logging</groupId>
		<artifactId>commons-logging</artifactId>
		<version>1.1.1</version>
	</dependency>
	<dependency>
		<groupId>javax.faces</groupId>
		<artifactId>jsf-api</artifactId>
		<version>1.2_02</version>
	</dependency>
	<dependency>
		<groupId>javax.faces</groupId>
		<artifactId>jsf-impl</artifactId>
		<version>1.2</version>
		<classifier>NIGHTLY_20060227</classifier>
	</dependency>
	<dependency>
		<groupId>jstl</groupId>
		<artifactId>jstl</artifactId>
		<version>1.1.2</version>
	</dependency>
	<dependency>
		<groupId>taglibs</groupId>
		<artifactId>standard</artifactId>
		<version>1.1.2</version>
	</dependency>
	<!-- JPA Persistence Dependencies -->
  </dependencies>
  <build>
    <finalName>hello</finalName>
	<plugins>
		<!-- Facilitates downloading source and javadoc in Eclipse -->
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-eclipse-plugin</artifactId>
			<configuration>
				<wtpversion>2.0</wtpversion>
				<downloadSources>true</downloadSources>
				<downloadJavadocs>true</downloadJavadocs>
			</configuration>
		</plugin>

		<!-- Ensures we are compiling at 1.6 level -->
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-compiler-plugin</artifactId>
			<configuration>
				<source>1.6</source>
				<target>1.6</target>
			</configuration>
		</plugin>
			<!-- Tomcat plugin for embedded tomcat -->
		<plugin>
			<groupId>org.codehaus.mojo</groupId>
			<artifactId>tomcat-maven-plugin</artifactId>
			<configuration>
				<path>/${project.build.finalName}</path>
			</configuration>
		</plugin>
	</plugins>
  </build>
</project>
Criado 16 de novembro de 2010
Ultima resposta 17 de nov. de 2010
Respostas 11
Participantes 6