• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

current thread not owner

 
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);}
}
}
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • 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.
 
It's fun to be me, and still legal in 9 states! Wanna see my tiny ad?
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!