commons fileupload null pointer exception

Hi,

I've developing a beta site which allows its user to submit resumes and I'm trying to use the fileupload component for the resume upload part. I've followed some sample code I can find but keep getting a null pointer exception. Anyone have any ideas?

The following is the error trace:

23:16:38,468 ERROR [STDERR] java.lang.NullPointerException

23:16:38,468 ERROR [STDERR]at org.swg.rs.job.ResumeUpload.upload(Unknown So

urce)

23:16:38,468 ERROR [STDERR]at sun.reflect.NativeMethodAccessorImpl.invoke0(

Native Method)

23:16:38,468 ERROR [STDERR]at sun.reflect.NativeMethodAccessorImpl.invoke(N

ativeMethodAccessorImpl.java:39)

23:16:38,468 ERROR [STDERR]at sun.reflect.DelegatingMethodAccessorImpl.invo

ke(DelegatingMethodAccessorImpl.java:25)

23:16:38,468 ERROR [STDERR]at java.lang.reflect.Method.invoke(Method.java:5

85)

23:16:38,468 ERROR [STDERR]at org.apache.myfaces.el.MethodBindingImpl.invok

e(MethodBindingImpl.java:129)

23:16:38,468 ERROR [STDERR]at org.apache.myfaces.application.ActionListener

Impl.processAction(ActionListenerImpl.java:63)

23:16:38,468 ERROR [STDERR]at javax.faces.component.UICommand.broadcast(UIC

ommand.java:106)

23:16:38,468 ERROR [STDERR]at javax.faces.component.UIViewRoot._broadcastFo

rPhase(UIViewRoot.java:94)

23:16:38,468 ERROR [STDERR]at javax.faces.component.UIViewRoot.processAppli

cation(UIViewRoot.java:168)

23:16:38,468 ERROR [STDERR]at org.apache.myfaces.lifecycle.LifecycleImpl.in

vokeApplication(LifecycleImpl.java:343)

23:16:38,468 ERROR [STDERR]at org.apache.myfaces.lifecycle.LifecycleImpl.ex

ecute(LifecycleImpl.java:86)

23:16:38,468 ERROR [STDERR]at javax.faces.webapp.FacesServlet.service(Faces

Servlet.java:137)

23:16:38,468 ERROR [STDERR]at org.apache.catalina.core.ApplicationFilterCha

in.internalDoFilter(ApplicationFilterChain.java:252)

23:16:38,468 ERROR [STDERR]at org.apache.catalina.core.ApplicationFilterCha

in.doFilter(ApplicationFilterChain.java:173)

23:16:38,468 ERROR [STDERR]at org.apache.myfaces.webapp.filter.ExtensionsFi

lter.doFilter(ExtensionsFilter.java:144)

23:16:38,468 ERROR [STDERR]at org.apache.catalina.core.ApplicationFilterCha

in.internalDoFilter(ApplicationFilterChain.java:202)

23:16:38,468 ERROR [STDERR]at org.apache.catalina.core.ApplicationFilterCha

in.doFilter(ApplicationFilterChain.java:173)

23:16:38,468 ERROR [STDERR]at org.jboss.web.tomcat.filters.ReplyHeaderFilte

r.doFilter(ReplyHeaderFilter.java:96)

23:16:38,468 ERROR [STDERR]at org.apache.catalina.core.ApplicationFilterCha

in.internalDoFilter(ApplicationFilterChain.java:202)

23:16:38,468 ERROR [STDERR]at org.apache.catalina.core.ApplicationFilterCha

in.doFilter(ApplicationFilterChain.java:173)

23:16:38,468 ERROR [STDERR]at org.apache.catalina.core.StandardWrapperValve

.invoke(StandardWrapperValve.java:213)

23:16:38,468 ERROR [STDERR]at org.apache.catalina.core.StandardContextValve

.invoke(StandardContextValve.java:178)

23:16:38,468 ERROR [STDERR]at org.jboss.web.tomcat.security.SecurityAssocia

tionValve.invoke(SecurityAssociationValve.java:175)

23:16:38,468 ERROR [STDERR]at org.jboss.web.tomcat.security.JaccContextValv

e.invoke(JaccContextValve.java:74)

23:16:38,468 ERROR [STDERR]at org.apache.catalina.core.StandardHostValve.in

voke(StandardHostValve.java:126)

23:16:38,468 ERROR [STDERR]at org.apache.catalina.valves.ErrorReportValve.i

nvoke(ErrorReportValve.java:105)

23:16:38,468 ERROR [STDERR]at org.apache.catalina.core.StandardEngineValve.

invoke(StandardEngineValve.java:107)

23:16:38,468 ERROR [STDERR]at org.apache.catalina.connector.CoyoteAdapter.s

ervice(CoyoteAdapter.java:148)

23:16:38,468 ERROR [STDERR]at org.apache.coyote.http11.Http11Processor.proc

ess(Http11Processor.java:869)

23:16:38,468 ERROR [STDERR]at org.apache.coyote.http11.Http11BaseProtocol$H

ttp11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)

23:16:38,468 ERROR [STDERR]at org.apache.tomcat.util.net.PoolTcpEndpoint.pr

ocessSocket(PoolTcpEndpoint.java:527)

23:16:38,468 ERROR [STDERR]at org.apache.tomcat.util.net.MasterSlaveWorkerT

hread.run(MasterSlaveWorkerThread.java:112)

23:16:38,468 ERROR [STDERR]at java.lang.Thread.run(Thread.java:595)

--

This is how I defined the component in the jsp file:

<t:inputFileUpload id="fileupload"

value="#{resumeUpload.resume}" storage="file"

styleClass="fileUploadInput" required="true" />

<h:commandButton value="Upload" action="#{resumeUpload.upload}"/>

--

This is what I put in web.xml:

<filter>

<filter-name>extensionsFilter</filter-name>

<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>

<init-param>

<param-name>uploadMaxFileSize</param-name>

<param-value>100m</param-value>

<description>Set the size limit for uploaded files.

Format: 10 - 10 bytes

10k - 10 KB

10m - 10 MB

1g - 1 GB

</description>

</init-param>

<init-param>

<param-name>uploadThresholdSize</param-name>

<param-value>100k</param-value>

<description>Set the threshold size - files

below this limit are stored in memory, files above

this limit are stored on disk.

Format: 10 - 10 bytes

10k - 10 KB

10m - 10 MB

1g - 1 GB

</description>

</init-param>

<init-param>

<param-name>uploadRepositoryPath</param-name>

<param-value>/temp</param-value>

<description>Set the path where the intermediary files will be stored.

</description>

</init-param>

</filter>

<filter-mapping>

<filter-name>extensionsFilter</filter-name>

<url-pattern>*.jsf</url-pattern>

</filter-mapping>

<filter-mapping>

<filter-name>extensionsFilter</filter-name>

<url-pattern>/faces/*</url-pattern>

</filter-mapping>

Thanks a lot.

[6486 byte] By [gtguia] at [2007-10-3 0:16:21]
# 1
Found the problem, left out the enctype tag.
gtguia at 2007-7-14 17:07:08 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...