wood burning stoves 2.0*
The moose likes Threads and Synchronization and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark ""Current thread not owner" on upload.parseRequest(request);" Watch ""Current thread not owner" on upload.parseRequest(request);" New topic
Author

"Current thread not owner" on upload.parseRequest(request);

Tha�s Manfrim Firmino
Ranch Hand

Joined: Apr 12, 2004
Posts: 48
I created a class to upload files and in my local machine. It's working perfectly. But when I upload to the server, I'm getting the error message: java.lang.IllegalMonitorStateException: current thread not owner
This occurs on the call
items = upload.parseRequest(request);
//upload is an instance of org.apache.commons.fileupload.DiskFileUpload
Could someone please assist me?

Below is some code in case of need
I tried to put the code inside a synchronization block but didn't work.

vvvvvvvvvvvvvvvvvvvvvvvvvvv
//class sumarized with only what I need to know
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.fileupload.DiskFileUpload;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUpload;

//public class UploadFileHandler extends ActionHandlerAbstract {

/**
* This class handles user's requests to upload files that will be used by the job to generate reports
*/


public class UploadFileHandler extends HttpServlet {

private static final long serialVersionUID = 1L;


protected void doPost (HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try {


List items = null;
System.out.println("will upload & parse...");
synchronized(this){//tried to solve issue by syncronization but didn't help
DiskFileUpload upload = new DiskFileUpload();
items = upload.parseRequest(request);

}
//... the rest of code is unecessary
dispatch (request, response, "/HTMLReport/uploadedSuccessfully.html");

}catch(Exception e){

e.printStackTrace();
dispatch (request, response,"/HTMLReport/uploadFailed.html");
}
}

/**
* Dispatches the request and response to the resource
* @param request - HttpServletRequest in use
* @param response - HttpServletResponse in use
* @param resource - String containing resource path relative to request
* @throws ServletException
* @throws IOException
*/

private void dispatch (HttpServletRequest request, HttpServletResponse response, String resource)
throws ServletException, IOException {
RequestDispatcher dispatcher = request.getRequestDispatcher(resource);
if (dispatcher != null) {
response.setContentType("text/html");
dispatcher.forward(request, response);
}
}
}


Tha�s M. K. M. Firmino
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4164
    
  21

Are you sure that is the line that causes the error? Could you provide more of the error message to be sure?

The java.lang.IllegalMonitorStateException: current thread not owner message usually occurs when you try to wait or notify on an object that you did not synchronize on. Are you using a wait() or notify() anywhere in your code?


Steve
Tha�s Manfrim Firmino
Ranch Hand

Joined: Apr 12, 2004
Posts: 48
Hi Steve,

first, thank you for your help.

Yes, I'm sure that is the line. In fact I already verified on the internet that the error usually happens for wait() or notify(). I don't know why that is happening. :-(
See below some log file lines. Thank you in advance!

A nonfatal internal JIT (3.10.107(x)) error 'chgTarg: Conditional' has occurred in :
'com/packaging/reportgenerator/ReportGenerator.init ()V': Interpreting method.
Please report this error in detail to http://java.sun.com/cgi-bin/bugreport.cgi

java.lang.NullPointerException
at allaire.jrun.servlet.ForwardRequest.getRequestDispatcher(ForwardRequest.java, Compiled Code)
at com.packaging.reportgenerator.ReportGenerator.processAction(ReportGenerator.java, Compiled Code)
at com.packaging.reportgenerator.ReportGenerator.processRequest(ReportGenerator.java, Compiled Code)
at com.packaging.reportgenerator.ReportGenerator.doPost(ReportGenerator.java:115)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:772)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
at allaire.jrun.servlet.JRunSE.service(JRunSE.java, Compiled Code)
at allaire.jrun.servlet.JRunSE.runServlet(JRunSE.java, Compiled Code)
at allaire.jrun.servlet.JRunRequestDispatcher.forward(JRunRequestDispatcher.java, Compiled Code)
at allaire.jrun.servlet.JRunSE.service(JRunSE.java, Compiled Code)
at allaire.jrun.servlet.JRunSE.service(JRunSE.java, Compiled Code)
at allaire.jrun.servlet.JvmContext.dispatch(JvmContext.java, Compiled Code)
at allaire.jrun.jrpp.ProxyEndpoint.run(ProxyEndpoint.java, Compiled Code)
at allaire.jrun.ThreadPool.run(ThreadPool.java, Compiled Code)
at allaire.jrun.WorkerThread.run(WorkerThread.java, Compiled Code)
java.lang.IllegalMonitorStateException: current thread not owner
at org.apache.commons.fileupload.DefaultFileItem.getUniqueId(DefaultFileItem.java, Compiled Code)
at com.packaging.reportgenerator.job.UploadFileHandler.doPost(UploadFileHandler.java, Compiled Code)
at org.apache.commons.fileupload.DefaultFileItem.getTempFile(DefaultFileItem.java:617)
at org.apache.commons.fileupload.DefaultFileItem.getOutputStream(DefaultFileItem.java:557)
at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java, Compiled Code)
at com.packaging.reportgenerator.job.UploadFileHandler.doPost(UploadFileHandler.java, Compiled Code)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:772)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
at allaire.jrun.servlet.JRunSE.service(JRunSE.java, Compiled Code)
at allaire.jrun.servlet.JRunSE.runServlet(JRunSE.java, Compiled Code)
at allaire.jrun.servlet.JRunRequestDispatcher.forward(JRunRequestDispatcher.java, Compiled Code)
at allaire.jrun.servlet.JRunSE.service(JRunSE.java, Compiled Code)
at allaire.jrun.servlet.JRunSE.service(JRunSE.java, Compiled Code)
at allaire.jrun.servlet.JvmContext.dispatch(JvmContext.java, Compiled Code)
at allaire.jrun.jrpp.ProxyEndpoint.run(ProxyEndpoint.java, Compiled Code)
at allaire.jrun.ThreadPool.run(ThreadPool.java, Compiled Code)
at allaire.jrun.WorkerThread.run(WorkerThread.java, Compiled Code)
java.lang.NullPointerException
at allaire.jrun.servlet.ForwardRequest.getRequestDispatcher(ForwardRequest.java, Compiled Code)
at com.packaging.reportgenerator.ReportGenerator.processAction(ReportGenerator.java, Compiled Code)
at com.packaging.reportgenerator.ReportGenerator.processRequest(ReportGenerator.java, Compiled Code)
at com.packaging.reportgenerator.ReportGenerator.doPost(ReportGenerator.java:115)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:772)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
at allaire.jrun.servlet.JRunSE.service(JRunSE.java, Compiled Code)
at allaire.jrun.servlet.JRunSE.runServlet(JRunSE.java, Compiled Code)
at allaire.jrun.servlet.JRunRequestDispatcher.forward(JRunRequestDispatcher.java, Compiled Code)
at allaire.jrun.servlet.JRunSE.service(JRunSE.java, Compiled Code)
at allaire.jrun.servlet.JRunSE.service(JRunSE.java, Compiled Code)
at allaire.jrun.servlet.JvmContext.dispatch(JvmContext.java, Compiled Code)
at allaire.jrun.jrpp.ProxyEndpoint.run(ProxyEndpoint.java, Compiled Code)
at allaire.jrun.ThreadPool.run(ThreadPool.java, Compiled Code)
at allaire.jrun.WorkerThread.run(WorkerThread.java, Compiled Code)
java.lang.IllegalMonitorStateException: current thread not owner
at org.apache.commons.fileupload.DefaultFileItem.getUniqueId(DefaultFileItem.java, Compiled Code)
at com.packaging.reportgenerator.job.UploadFileHandler.doPost(UploadFileHandler.java, Compiled Code)
at org.apache.commons.fileupload.DefaultFileItem.getTempFile(DefaultFileItem.java:617)
at org.apache.commons.fileupload.DefaultFileItem.getOutputStream(DefaultFileItem.java:557)
at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java, Compiled Code)
at com.packaging.reportgenerator.job.UploadFileHandler.doPost(UploadFileHandler.java, Compiled Code)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:772)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
at allaire.jrun.servlet.JRunSE.service(JRunSE.java, Compiled Code)
at allaire.jrun.servlet.JRunSE.runServlet(JRunSE.java, Compiled Code)
at allaire.jrun.servlet.JRunRequestDispatcher.forward(JRunRequestDispatcher.java, Compiled Code)
at allaire.jrun.servlet.JRunSE.service(JRunSE.java, Compiled Code)
at allaire.jrun.servlet.JRunSE.service(JRunSE.java, Compiled Code)
at allaire.jrun.servlet.JvmContext.dispatch(JvmContext.java, Compiled Code)
at allaire.jrun.jrpp.ProxyEndpoint.run(ProxyEndpoint.java, Compiled Code)
at allaire.jrun.ThreadPool.run(ThreadPool.java, Compiled Code)
at allaire.jrun.WorkerThread.run(WorkerThread.java, Compiled Code)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: "Current thread not owner" on upload.parseRequest(request);
 
Similar Threads
file uploading using apache
Using commons-fileupload-1.2.1.jar to upload file to MySQL
I got http-500 error in servlet and jsp.how to find error?
Servlet : upload and converter a ppt to pdf
How to redirect from servlet to JSP/Servlet with out executing the below code