Javax.faces.view.facelets.FaceletException: Error Parsing /produtos/form.xhtml: Error Traced[line: 10] Invalid byte 2 of 3-byte UTF-8 sequence

6 respostas
G

22:10:05,149 FATAL [javax.enterprise.resource.webcontainer.jsf.context] (default task-2) JSF1073: javax.faces.view.facelets.FaceletException obtido durante o processamento de RESTORE_VIEW 1: UIComponent-ClientId=, Message=Error Parsing /produtos/form.xhtml: Error Traced[line: 10] Invalid byte 2 of 3-byte UTF-8 sequence.

22:10:05,151 FATAL [javax.enterprise.resource.webcontainer.jsf.context] (default task-2) Error Parsing /produtos/form.xhtml: Error Traced[line: 10] Invalid byte 2 of 3-byte UTF-8 sequence.: javax.faces.view.facelets.FaceletException: Error Parsing /produtos/form.xhtml: Error Traced[line: 10] Invalid byte 2 of 3-byte UTF-8 sequence.

estou tendo esses erros ao usar JSF.

meu web.xml

<?xml version="1.0" encoding="UTF-8"?>
<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"
	id="WebApp_ID" version="2.5">

	<display-name>JavaServerFaces</display-name>

	<!-- Change to "Production" when you are ready to deploy -->
	<context-param>
		<param-name>javax.faces.PROJECT_STAGE</param-name>
		<param-value>Development</param-value>
	</context-param>

	<!-- JSF mapping -->
	<servlet>
		<servlet-name>Faces Servlet</servlet-name>
		<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
		<load-on-startup>1</load-on-startup>
	</servlet>

	<!-- Map these files with JSF -->
	<servlet-mapping>
		<servlet-name>Faces Servlet</servlet-name>
		<url-pattern>/faces/*</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
		<servlet-name>Faces Servlet</servlet-name>
		<url-pattern>*.jsf</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
		<servlet-name>Faces Servlet</servlet-name>
		<url-pattern>*.faces</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
		<servlet-name>Faces Servlet</servlet-name>
		<url-pattern>*.xhtml</url-pattern>
	</servlet-mapping>

</web-app>

meu faces.config.xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<faces-config xmlns="http://xmlns.jcp.org/xml/ns/javaee"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.2"
	xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd">
</faces-config>

e o formulario que da o erro

<html xmlns:h="http://java.sun.com/jsf/html"
	xmlns:jsf="http://xmlns.jcp.org/jsf">
<h:body>
	<h:form>
			<div>
				<h:outputLabel>Titulo</h:outputLabel>
				<h:inputText />
			</div>
			<div>
				<h:outputLabel>Descrição</h:outputLabel>
				<h:inputTextarea cols="20" rows="10" />
			</div>
			<div>
				<h:outputLabel>Número de Páginas</h:outputLabel>
				<h:inputText />
			</div>
			<div>
				<h:outputLabel>Preço</h:outputLabel>
				<h:inputText />
			</div>
			<h:commandButton value=" Gravar" action="#{adminBooksBean.save}" />

	</h:form>
</h:body>
</html>

Se alguem puder me ajudar, sinceramente nao sei quel o erro.
Obrigado.

6 Respostas

J

Oi @grinoliel,

O outputLabel do JSF recebe o valor que deve ser exibido dentro da propriedade value e não dentro da tag.

Troque de:

<h:outputLabel>Titulo</h:outputLabel>

Para:

<h:outputLabel value = "Descrição"/>

Abraço!

G

uhn, entendi, faz sentido…
mas o problema continua, rs.

Abraço

P

Deve estar relacionado com o encoding com que está gravado o ficheiro. Experimenta retirar os caracteres especiais para confirmar se é mesmo isso (muda Descrição para Descricao, páginas para paginas e Preço para Preco).
Se funcionar então tens de gravar o ficheiro com um encoding diferente (não deve estar neste momento com UTF-8).

G

é, já tinha tentado isso, não deu em nada…

J

@grinoliel, joga na primeira linha do seu xhtml:

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

Abraço!

L

Eu estava com o mesmo problema, resolvi colocando a tag:

<?xml version="1.0" encoding="ISO-8859-1"?>

Criado 21 de dezembro de 2015
Ultima resposta 20 de jan. de 2017
Respostas 6
Participantes 4