• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Null pointer exception in chain.doFilter in file upload

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Before file upload I have created a filter to verify javascript pdf. But in filter I am not able to forward the request using dofilter method and I am getting null pointer exception. To get parts I used




once I get success, I want to forward it using from my filter java file. But I am getting below exceptions.



I don't face null exception in normal scenario. I am facing issue while forward servlet request in dofilter, even though I pass the proper value.

If I manipulate multiparts and tries to forward, getting null exception and if I remove multiparts manipulation and directly forward the request and I am getting any exception and it forward to other action. It looks like while manipulating muliparts and forward request getting exceptions.

Can you please help me to resolve it. Thanks in advance. Any details needed please let me know.
 
Saloon Keeper
Posts: 7582
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which line is # 44? Which objects or references used in it or before it are null?
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just to elaborate on Tim's reply, your error is in the line of code mentioned here:

at com.raistudies.forms.UploadForm.validate(UploadForm.java:44)



The code you posted doesn't include that line of code, so for now there's no point in looking there. Look in your UploadForm.validate() method, at line 44.
 
Mans Rad
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Moores wrote:Which line is # 44? Which objects or references used in it or before it are null?



Yes. That's the issue I am facing. In Filter config, if I cast serveltrequest to httprequest to get multiparts I am not able to forward the request and getting exceptions. Suppose if I don't cast and forward the request, I am not getting any null exceptions in UploadForm.java. As per my understanding it looks like after casting to multiparts and forward the request, I get null exceptions in UploadForm.java

UploadForm.java

L 44
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So either uploadedFile or errors is null. Can you show the code that sets these two variables?
 
Mans Rad
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote:So either uploadedFile or errors is null. Can you show the code that sets these two variables?



Please find my UploadForm.java


In Filter java file

 
Paul Clapham
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So yeah, the uploadedFile variable must be null. And looking at your code, there's only one place which can set it, and that's the setUploadedFile() method. So either that method isn't being called, or it's being passed a null value.

That's what you have to look into, then. Perhaps the redacted code from your filter doesn't ever call setUploadedFile, in some circumstances?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic