Rachel Rachel - 4 months ago 40
Java Question

JSF Exception : javax.faces.event.AbortProcessingException

I am getting

javax.faces.event.AbortProcessingException
, not sure why as I have data in my list of string
fileData
, I have attached my XHTML file, Java file and
Exception
for reference.

xhtml code

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:icecore="http://www.icefaces.org/icefaces/core"
xmlns:ace="http://www.icefaces.org/icefaces/components"
xmlns:ice="http://www.icesoft.com/icefaces/component">
<h:head>
<title>ICEfaces 3</title>
<link rel="stylesheet" type="text/css"
href="./xmlhttp/css/rime/rime.css" />
</h:head>
<h:body>
<h:form id="form">
<h:outputText value="Welcome to ICEfaces 3, select current date: " />
<ace:dateTimeEntry renderAsPopup="true">
<f:convertDateTime pattern="MM/dd/yyyy" timeZone="Canada/Mountain" />
</ace:dateTimeEntry>
<ace:fileEntry id="fileUpload" label="File Entry"
relativePath="uploaded" fileEntryListener="#{fileUpload.uploadFile}" />
<h:commandButton value="Upload File" />
</h:form>
<ice:panelSeries var="color" value="#{fileUpload.fileData}">
<ice:outputText value="#{color}" />
</ice:panelSeries>
</h:body>
<h:outputStylesheet library="org.icefaces.component.skins"
name="sam.css" />
</html>


Java code:

private List<String> fileData;

public void uploadFile(FileEntryEvent event) {
System.out.println("Event: " + event.getSource());
System.out.println("Test");
FileEntry fileEntry = (FileEntry) event.getSource();
FileEntryResults results = fileEntry.getResults();
for (FileEntryResults.FileInfo fileInfo : results.getFiles()) {
if (fileInfo.isSaved()) {
System.out.println("File is saved sucessfully");
fileData.add("FileName: " + fileInfo.getFileName());
fileData.add("FileSize: " + fileInfo.getSize());
fileData.add("FileStatus: " + fileInfo.getStatus());
}
}
}

public List<String> getFileData() {
System.out.println("inside getFileData");
List<String> data = fileData;
return fileData;
}

public void setFileData(List<String> fileData) {
this.fileData = fileData;
}


Exception:

10:05:29 AM org.icefaces.impl.application.ExtendedExceptionHandler handle
WARNING: queued exception
javax.faces.event.AbortProcessingException: /ICEfacesPage1.xhtml @22,75 fileEntryListener="#{fileUpload.uploadFile}": java.lang.NullPointerException
at org.icefaces.ace.component.fileentry.FileEntry.broadcast(FileEntry.java:308)
at org.icefaces.ace.component.fileentry.FileEntryPhaseListener$1.visit(FileEntryPhaseListener.java:97)
at com.sun.faces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:183)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1590)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1601)
at javax.faces.component.UIForm.visitTree(UIForm.java:344)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1601)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1601)
at org.icefaces.ace.component.fileentry.FileEntryPhaseListener.beforePhase(FileEntryPhaseListener.java:102)
at com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:228)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:99)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1812)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NullPointerException
at FileUploadBean.uploadFile(FileUploadBean.java:54)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.el.parser.AstValue.invoke(AstValue.java:264)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at org.icefaces.ace.component.fileentry.FileEntry.broadcast(FileEntry.java:306)
... 28 more

Answer

fileData is null, since you did not create it yet. Add the follwing to your uploadFile method:

fileData = new ArrayList<String>();

PS: The setFileData method you might not need.