aspose file tools*
The moose likes JSF and the fly likes Two MyFaces problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Two MyFaces problems" Watch "Two MyFaces problems" New topic
Author

Two MyFaces problems

Urs Wagner
Greenhorn

Joined: Sep 01, 2005
Posts: 9
I try build my own MyFaces applications. I always get one of this errors.

First problem:

2005-09-03 00:23:18,112 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/faces-einfach].[jsp]] Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
at javax.faces.webapp.UIComponentTag.setupResponseWriter(UIComponentTag.java:646)
at javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:254)
at org.apache.myfaces.taglib.core.ViewTag.doStartTag(ViewTag.java:90)


Second problem:

Caused by: javax.faces.el.PropertyNotFoundException: Base is null: helloWorldBacking
at org.apache.myfaces.el.ValueBindingImpl.resolveToBaseAndProperty(ValueBindingImpl.java:523)
Kevin Galligan
Ranch Hand

Joined: Aug 10, 2005
Posts: 70
Code please.
Heberton B. Alves dos Santos
Greenhorn

Joined: Feb 18, 2006
Posts: 9
I had the same problem. So, my code in faces-config:


<?xml version="1.0"?>
<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
"http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
<faces-config>
<lifecycle>
<phase-listener>br.gov.iphan.rh.autenticacao.AutentPhaseListener</phase-listener>
</lifecycle>

<!-- Inicio login -->
<navigation-rule>
<from-view-id>/login.jsp</from-view-id>
<navigation-case>
<from-outcome>principal</from-outcome>
<to-view-id>/principal.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>loginFail</from-outcome>
<to-view-id>/loginFail.jsp</to-view-id>
</navigation-case>
</navigation-rule>

<navigation-rule>
<from-view-id>/principal.jsp</from-view-id>
<navigation-case>
<from-outcome>principal</from-outcome>
<to-view-id>/principal.jsp</to-view-id>
</navigation-case>
</navigation-rule>

<managed-bean>
<managed-bean-name>autenticacao</managed-bean-name>
<managed-bean-class>br.gov.iphan.rh.autenticacao.Autenticacao</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>

</faces-config>


My login.jsp:

<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<html>
<f:view>
<head>
<link rel="stylesheet" href="css/novas_definicoes.css" type="text/css">
<title>Sistema de RH vers.20060808</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<center>
<body style="margin:0px">
<div align="left"></div>
<td colspan="2" align="right"> <TABLE align="center"cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD height="38" align="center" vAlign=top><img src="Imagens/Titulo2.png"></td>
</tr>
<tr>
<td height="30" colspan="2" align="center"> </td>
</tr>
<tr>
<td height="30" colspan="2" align="center">
<h:form>
<table align="center" width="56%" border="0" cellspacing="0" cellpadding="4" style="border-bottom: 1px solid #663300;border-left:1px solid #663300;border-right: 1px solid #663300;border-top: 1px solid #663300;">
<tr>
<td width="19%" height="32" align="right"><font color="#663300" size="3" face="Verdana, Arial, Helvetica, sans-serif">Matricula</font><font color="#663300" size="3">:</font></td>
<td width="19%">

<h:inputText id="matriculaInput" value="#{autenticacao.matricula}"/>
</td>
<td width="38%" rowspan="2" >

<h:commandButton action="#{autenticacao.getAutenticar}" type="submit" image="Imagens/btn_branco_entra.gif"/>
</td>
</tr>
<tr>
<td height="46" align="right"><font color="#663300" size="3" face="Verdana, Arial, Helvetica, sans-serif">Senha:</font></td>
<td>

<h:inputSecret id="passwordInput" value="#{autenticacao.senha}"/>
</td>
</tr>
</table>
</h:form>
</td>
</tr>
<tr>
<td height="180" colspan="2" align="center" background="Imagens/imagem_log.png" style="background-position: center;;background-repeat:no-repeat;"> </td>
</tr>
<tr>
<td height="30" colspan="2" align="center"> </td>
</tr>
<tr>
<td>  </td>
<td> </td>
</tr>
</table>
</body>
</center>
</f:view>
</html>

My AutentPhaseListener:

package br.gov.iphan.rh.autenticacao;

import java.util.GregorianCalendar;

import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.event.PhaseEvent;
import javax.faces.event.PhaseId;
import javax.faces.event.PhaseListener;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.myfaces.context.servlet.RequestMap;

import br.gov.iphan.rh.util.DataUtil;

public class AutentPhaseListener implements PhaseListener {

public void afterPhase(PhaseEvent event) {
}

public void beforePhase(PhaseEvent event) {
boolean autorizado = false;
String paginaRequisitada = null;
ExternalContext ce;
FacesContext context = null;


//vou recuperar o contexto externo atual
context = FacesContext.getCurrentInstance();
ce = context.getExternalContext();


//vou verificar se o usuario ja esta logado ou nao

try{

HttpSession session = (HttpSession) context.getExternalContext().getSession(true);


if (session.getAttribute("operador") != null){
autorizado = true;
}

}catch (Exception e) {
System.out.println("falha na fase de autentica��o rh");
e.printStackTrace();
}


//vou recuperar a pagina requisitada
paginaRequisitada = ce.getRequestServletPath();



/*se o usuario requisitar uma pagina diferente da pagina de login vou verificar se ele ja esta logado. Se ele ainda nao estiver logado, o redireciono para a pagina de login*/
if (!"/login.jsf".equals(paginaRequisitada)){
if (!autorizado)
try {
ce.redirect("/projSRH/login.jsf");
}
catch(Exception e){
System.out.print(DataUtil.getDataHora(new GregorianCalendar()) + ": ");
System.out.println("Usu�rio n�o autenticado!");
System.out.println(e.toString());
}

}


}

public PhaseId getPhaseId() {
return PhaseId.RENDER_RESPONSE;
}

}


And my Autenticacao:

package br.gov.iphan.rh.autenticacao;



import java.util.GregorianCalendar;
import java.util.List;

import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;

import br.gov.iphan.rh.operador.Operador;
import br.gov.iphan.rh.operador.OperadorDAO;
import br.gov.iphan.rh.servidor.Servidor;
import br.gov.iphan.rh.servidor.ServidorDAO;
import br.gov.iphan.rh.usuarioExterno.UsuarioExternoDAO;
import br.gov.iphan.rh.util.CriptoUtil;
import br.gov.iphan.rh.util.DataUtil;


public class Autenticacao {


private String matricula;
private String senha;
private String autenticar;
public static String nomeServidor = "";
public String nomeUsuarioLogado;
private List usuarios;
private String mensagem;
private boolean usuarioLogado;

public Autenticacao(){

}

public String getMatricula() {
return matricula;
}
public void setMatricula(String matricula) {
this.matricula = matricula;
}
public String getSenha() {
return senha;
}
public void setSenha(String senha) {
this.senha = senha;
}


public String getAutenticar() {

Operador o = null;
try{
//passa a matricula do usuario para o admcorp
o = new OperadorDAO().getOperador(matricula);
HttpSession session = (HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(true);
session.setAttribute("operador", o);
}catch(Exception e){

}

if(o != null){
//Criptografa a senha do usuario
String senhaCriptografada = CriptoUtil.getCriptografia(senha);
if(senhaCriptografada.equals(o.getSenha())){
if(o.verificarExistenciaPerfisSistema(22)){
if(o.isAdministrador()){
Servidor servidor = new ServidorDAO().getServidorMatricula(o.getMatricula());
if(servidor != null){
//FacesContext context = FacesContext.getCurrentInstance();
//HttpSession session = (HttpSession) context.getExternalContext().getSession(false);
//session.setAttribute("nomeLogado", servidor.getNome());

this.setNomeUsuarioLogado(servidor.getNome());
this.setUsuarioLogado(true);
}
}

try{
List users = new UsuarioExternoDAO().getUsuariosExternosPorCpf(o.getMatricula().toString());
this.setUsuarios(users);

}catch(Exception e){
System.out.print(DataUtil.getDataHora(new GregorianCalendar()) + ": ");
System.out.println("N�o foi poss�vel recuperar os usu�rio do operador");
System.out.println(e.toString());
}

try{
//Retorna a string para redirecionar para a p�gina principal
return "principal";
}catch(Exception ioe){
System.out.print(DataUtil.getDataHora(new GregorianCalendar()) + ": ");
System.out.println("N�o foi poss�vel redirecionar o usu�rio para a p�gina principal");
System.out.println(ioe.toString());
}

}else{
this.setMensagem("Usu�rio n�o autorizado a acessar o sistema");
try{
//Retorna string para redirecionar para a p�gina de falha login
((HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(false)).removeAttribute("operador");
return "loginFail";
}catch(Exception e){
System.out.print(DataUtil.getDataHora(new GregorianCalendar()) + ": ");
System.out.println("N�o foi poss�vel redirecionar o usu�rio para a p�gina de login!");
System.out.println(e.toString());
}

}

}else{
this.setMensagem("Senha n�o confere");
try{
FacesContext.getCurrentInstance().getExternalContext().getSessionMap().remove("operador");
return "loginFail";
}catch(Exception ioe){
System.out.print(DataUtil.getDataHora(new GregorianCalendar()) + ": ");
System.out.println("N�o foi poss�vel redirecionar o usu�rio para a p�gina de login!");
System.out.println(ioe.toString());
}
}
}else{

String msg = "N�o h� operador cadastrado com a matr�cula " + matricula;
this.setMensagem(msg);
try{
FacesContext.getCurrentInstance().getExternalContext().getSessionMap().remove("operador");
return "loginFail";
}catch(Exception ioe){
System.out.print(DataUtil.getDataHora(new GregorianCalendar()) + ": ");
System.out.println("N�o foi poss�vel redirecionar o usu�rio para a p�gina de login!");
System.out.println(ioe.toString());
}

}

return "login";
}


public void setAutenticar(String autenticar) {
this.autenticar = autenticar;
}

public List getUsuarios() {
return usuarios;
}
public void setUsuarios(List usuarios) {
this.usuarios = usuarios;
}
public String getMensagem() {
return mensagem;
}
public void setMensagem(String mensagem) {
this.mensagem = mensagem;
}

public boolean isUsuarioLogado() {
return usuarioLogado;
}
public void setUsuarioLogado(boolean usuarioLogado) {
this.usuarioLogado = usuarioLogado;
}

public String getNomeUsuarioLogado() {
return nomeUsuarioLogado;
}

public void setNomeUsuarioLogado(String nomeUsuarioLogado) {
this.nomeUsuarioLogado = nomeUsuarioLogado;
}


}


I tested in others computers and worked well. And in my PC, nothing! Just:
19:44:28,062 ERROR [Faces Servlet]:253 - Servlet.service() for servlet Faces Servlet threw exception
javax.faces.el.PropertyNotFoundException: Base is null: autenticacao
at org.apache.myfaces.el.ValueBindingImpl.resolveToBaseAndProperty(ValueBindingImpl.java:460)
at org.apache.myfaces.el.ValueBindingImpl.getType(ValueBindingImpl.java:172)
at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:111)
at javax.faces.component.UIInput.getConvertedValue(UIInput.java:395)
at javax.faces.component.UIInput.validate(UIInput.java:349)
at javax.faces.component.UIInput.processValidators(UIInput.java:183)
at javax.faces.component.UIForm.processValidators(UIForm.java:70)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:624)
at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:146)
at org.apache.myfaces.lifecycle.LifecycleImpl.processValidations(LifecycleImpl.java:262)
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:76)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:137)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)


Sun Certified Programmer for Java 2 Plataform
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Its better to just post the relevent code snippet. Its unlikely that anybody would read that bulk of code.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Originally posted by Adeel Ansari:
Its better to just post the relevent code snippet. Its unlikely that anybody would read that bulk of code.


At the very least use UBB Code Tags


GenRocket - Experts at Building Test Data
 
Consider Paul's rocket mass heater.
 
subject: Two MyFaces problems