Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

current thread not owner

 
prakash p
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
could some body help me ??
I have a servlet to upload a file from the browser to the server but I get amessage "java.lang.IllegalMonitorStateException: current thread not owner"

I have tried to use notify()but issue was not resolved !
This code works fine in Tomcat but in Oracles 9iAS it gives said error

My servlet code is as follows

import java.io.*;
import java.util.*;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import javax.servlet.http.HttpServlet;
import org.apache.commons.fileupload.*;


public class UploadFile extends HttpServlet
{
public void doPost(HttpServletRequest req,HttpServletResponse res)
{
PrintWriter out=null;
try{
out=res.getWriter();

FileUpload fup=new FileUpload();
boolean isMultipart = FileUpload.isMultipartContent(req);
out.println(isMultipart);
DiskFileUpload upload = new DiskFileUpload();

List items = upload.parseRequest(req);

Iterator iter = items.iterator();
while (iter.hasNext())
{
FileItem item = (FileItem) iter.next();
if (item.isFormField())
{
out.println("its a field");
}
else
{
out.println("its a file");
out.println(item.getName());
File cfile=new File(item.getName());
File tosave=new File(getServletContext().getRealPath("/"),cfile.getName());
out.println(tosave);
item.write(tosave);
}
}

}catch(Exception e){out.println(e);}
}
}
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15633
46
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look closely at the stack trace of the exception. It will tell you exactly in which line of source code the exception happened. Go to your source code and find out what could go wrong there.

The error message means that you were doing something that you can only do while the current thread has a lock on the object you're using - which usually means you must be in a synchronized block. You are probably trying to call a method like wait() or notify() outside a synchronized block.
 
prakash p
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Jesper I'll certainly try for it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic