0 Replies Latest reply on May 26, 2008 9:15 AM by IVAN BATISTA MORENO

    Error with fileUpload

    IVAN BATISTA MORENO Newbie

      It is with this error when I upload, which may be suspect because I have a PhaseListener implementation for authentication, in other application works.

      implementation of the code PhaseListener

      package br.gov.mt.seguranca.simp.application;
      
      import javax.faces.application.NavigationHandler;
      import javax.faces.context.FacesContext;
      import javax.faces.event.PhaseEvent;
      import javax.faces.event.PhaseId;
      import javax.faces.event.PhaseListener;
      import javax.servlet.ServletContext;
      import javax.servlet.http.HttpServletRequest;
      
      import org.springframework.context.ApplicationContext;
      import org.springframework.web.context.support.WebApplicationContextUtils;
      
      import br.gov.mt.seguranca.simp.action.Constants;
      import br.gov.mt.seguranca.simp.service.AuthenticationBean;
      import br.gov.mt.seguranca.simp.service.AuthenticationStatus;
      import br.gov.mt.seguranca.simp.service.LoginService;
      
      public class SimpPhaseListener implements PhaseListener {
      
       private static final long serialVersionUID = 6399816010554236845L;
      
       private LoginService loginService;
      
       public void afterPhase(PhaseEvent event) {
      
       FacesContext facesContext = event.getFacesContext();
      
       // recupera o AuthenticationBean da sessao
       AuthenticationBean authenticationBean = (AuthenticationBean) facesContext
       .getExternalContext().getSessionMap().get(
       Constants.AUTHENTICATION_BEAN);
      
       if (authenticationBean == null) {
      
       // caso de nao existir cria
      
       if (loginService == null) {
      
       ApplicationContext applicationContext = WebApplicationContextUtils
       .getRequiredWebApplicationContext((ServletContext) FacesContext
       .getCurrentInstance().getExternalContext()
       .getContext());
      
       loginService = (LoginService) applicationContext
       .getBean("loginService");
      
       }
      
       authenticationBean = loginService.getAuthenticationBean();
      
       // seta o AuthenticationBean na sessao
       facesContext.getExternalContext().getSessionMap().put(
       Constants.AUTHENTICATION_BEAN, authenticationBean);
      
       }
      
       if (authenticationBean.getIp() == null) {
      
       // seta o endereco IP client no AuthenticationBean
       HttpServletRequest httpServletRequest = (HttpServletRequest) facesContext
       .getExternalContext().getRequest();
       authenticationBean.setIp(httpServletRequest.getRemoteAddr());
      
       }
      
       // verifica se está na pagina de login
       boolean pageLogin = (facesContext.getViewRoot().getViewId()
       .lastIndexOf("login") > -1);
      
       if (!pageLogin
       && !authenticationBean.getAuthenticationStatus().equals(
       AuthenticationStatus.AUTENTICADO)) {
      
       NavigationHandler navigationHandler = facesContext.getApplication()
       .getNavigationHandler();
      
       // verifica o status do AuthenticationBean
       switch (authenticationBean.getAuthenticationStatus()) {
       case AGUARDANDO_LOGIN:
       navigationHandler.handleNavigation(facesContext, null,
       Constants.ACTION_LOGIN);
       break;
      
       case AGUARDANDO_AUTENTICACAO:
       navigationHandler.handleNavigation(facesContext, null,
       Constants.ACTION_LOGIN_TOKEN);
       break;
      
       case AGUARDANDO_ALTERACAO_SENHA:
       navigationHandler.handleNavigation(facesContext, null,
       Constants.ACTION_ALTERAR_SENHA);
       break;
      
       case AGUARDANDO_AUTENTICACAO_SENHA:
       navigationHandler.handleNavigation(facesContext, null,
       Constants.ACTION_AUTENTICAR_SENHA);
       break;
       }
      
       }
      
       }
      
       public PhaseId getPhaseId() {
       return PhaseId.RESTORE_VIEW;
       }
      
       public void beforePhase(PhaseEvent event) {
       // TODO Auto-generated method stub
       }
      
      }
      
      
      



      I am using:

      RichFaces 3.2.1 SNAPSHOT
      Toncat 6.0.14
      JavaServer Faces 1.2.04
      Java 5.0.13

      the error message:

      WARNING: executePhase(APPLY_REQUEST_VALUES 2,com.sun.faces.context.FacesContextImpl@149a2c8) threw exception
      javax.faces.FacesException
      at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:109)
      at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:266)
      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:132)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:147)
      at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:256)
      at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:358)
      at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:488)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
      at java.lang.Thread.run(Unknown Source)
      Caused by: java.lang.NullPointerException
      at org.richfaces.renderkit.FileUploadRendererBase.doDecode(FileUploadRendererBase.java:112)
      at org.ajax4jsf.renderkit.RendererBase.decode(RendererBase.java:76)
      at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:791)
      at javax.faces.component.UIInput.decode(UIInput.java:722)
      at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1012)
      at javax.faces.component.UIInput.processDecodes(UIInput.java:638)
      at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1007)
      at javax.faces.component.UIForm.processDecodes(UIForm.java:203)
      at org.ajax4jsf.component.AjaxViewRoot$1.invokeContextCallback(AjaxViewRoot.java:388)
      at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:235)
      at org.ajax4jsf.component.AjaxViewRoot.processDecodes(AjaxViewRoot.java:405)
      at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:101)
      ... 24 more
      26/05/2008 08:35:58 org.apache.catalina.core.StandardWrapperValve invoke
      SEVERE: Servlet.service() for servlet Faces Servlet threw exception
      java.lang.NullPointerException
      at org.richfaces.renderkit.FileUploadRendererBase.doDecode(FileUploadRendererBase.java:112)
      at org.ajax4jsf.renderkit.RendererBase.decode(RendererBase.java:76)
      at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:791)
      at javax.faces.component.UIInput.decode(UIInput.java:722)
      at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1012)
      at javax.faces.component.UIInput.processDecodes(UIInput.java:638)
      at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1007)
      at javax.faces.component.UIForm.processDecodes(UIForm.java:203)
      at org.ajax4jsf.component.AjaxViewRoot$1.invokeContextCallback(AjaxViewRoot.java:388)
      at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:235)
      at org.ajax4jsf.component.AjaxViewRoot.processDecodes(AjaxViewRoot.java:405)
      at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:101)
      at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:266)
      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:132)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:147)
      at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:256)
      at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:358)
      at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:488)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
      at java.lang.Thread.run(Unknown Source)