IllegalMonitorStateException in 3.7.1.2

We are seeing the following exception in our logs, this comes out of several members around the same time;
3-Feb-2012 06:03:36 ERROR ( Log4j.CDB:3) - 2012-02-03 06:03:36.251 Oracle Coherence GE 3.7.1.2 <Error>
                         (thread=DataCacheServiceWorker:4, member=16): Terminating PartitionedCache due to unhandled exception: java.lang.IllegalMonitorStateException
03-Feb-2012 06:03:36 ERROR ( Log4j.CDB:3) - 2012-02-03 06:03:36.251 Oracle Coherence GE 3.7.1.2 <Error>
                         (thread=DataCacheServiceWorker:4, member=16):
java.lang.IllegalMonitorStateException
     at java.lang.Object.notifyAll(Native Method)
     at com.tangosol.net.internal.StorageVersion.commit(StorageVersion.java:176)
     at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$ResourceCoordinator.processEvent(PartitionedCache.CDB:94)
     at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$ResourceCoordinator.finalizeInvokeSingleThreaded(PartitionedCache.CDB:56)
     at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$ResourceCoordinator.finalizeInvoke(PartitionedCache.CDB:9)
     at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache.processChanges(PartitionedCache.CDB:3)
     at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache.onInvokeFilterRequest(PartitionedCache.CDB:128)
     at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$InvokeFilterRequest.run(PartitionedCache.CDB:1)
     at com.tangosol.coherence.component.util.DaemonPool$WrapperTask.run(DaemonPool.CDB:1)
     at com.tangosol.coherence.component.util.DaemonPool$WrapperTask.run(DaemonPool.CDB:32)
     at com.tangosol.coherence.component.util.DaemonPool$Daemon.onNotify(DaemonPool.CDB:63)
     at com.tangosol.coherence.component.util.Daemon.run(Daemon.CDB:42)
     at java.lang.Thread.run(Thread.java:619)
03-Feb-2012 06:03:37 WARN ( Log4j.CDB:3) - 2012-02-03 06:03:37.265 Oracle Coherence GE 3.7.1.2 <Warning>
                         (thread=DistributedCache:DataCacheService, member=16): failed to stop 1 worker threads; abandoning
03-Feb-2012 06:04:30 INFO ( Log4j.CDB:3) - 2012-02-03 06:04:30.836 Oracle Coherence GE 3.7.1.2 <Info>
                         (thread=Invocation:InvocationService, member=16): Restarting Service: DataCacheService
03-Feb-2012 06:04:30 INFO ( Log4j.CDB:3) - 2012-02-03 06:04:30.882 Oracle Coherence GE 3.7.1.2 <Info>
This is a sporadic issue so difficult to repeat. Interestingly I can see the following in the 3.7.1 release notes;
"Fixed an issue causing an IllegalMonitorStateException to be thrown by deadlock detection under heavy load."
Is this still a known issue?

Hi,
We’re seeing the same thing!
When we have coherence commands that run filtered and direct entry processors, aggregators, etc... we are using POF objects that exeneds AbstractEvolvable.
12:06:17:362- [Logger@9215220 3.7.1.2] - ERROR - com.tangosol.coherence.component.util.logOutput.Log4j - 2012-02-02 12:06:17.362/14803.069 Oracle Coherence GE 3.7.1.2 <Error> (thread=DistributedCache-service:3, member=2): Terminating PartitionedCache due to unhandled exception: java.lang.IllegalMonitorStateException
12:06:17:366- [Logger@9215220 3.7.1.2] - ERROR - com.tangosol.coherence.component.util.logOutput.Log4j - 2012-02-02 12:06:17.362/14803.069 Oracle Coherence GE 3.7.1.2 <Error> (thread=DistributedCache-service:3, member=2):
java.lang.IllegalMonitorStateException
     at java.lang.Object.notifyAll(Native Method)
     at com.tangosol.net.internal.StorageVersion.commit(StorageVersion.java:176)
     at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$ResourceCoordinator.processEvent(PartitionedCache.CDB:94)
     at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$ResourceCoordinator.finalizeInvokeSingleThreaded(PartitionedCache.CDB:56)
     at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$ResourceCoordinator.finalizeInvoke(PartitionedCache.CDB:9)
     at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache.processChanges(PartitionedCache.CDB:3)
     at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache.onInvokeFilterRequest(PartitionedCache.CDB:128)
     at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$InvokeFilterRequest.run(PartitionedCache.CDB:1)
     at com.tangosol.coherence.component.util.DaemonPool$WrapperTask.run(DaemonPool.CDB:1)
     at com.tangosol.coherence.component.util.DaemonPool$WrapperTask.run(DaemonPool.CDB:32)
     at com.tangosol.coherence.component.util.DaemonPool$Daemon.onNotify(DaemonPool.CDB:63)
     at com.tangosol.coherence.component.util.Daemon.run(Daemon.CDB:42)
     at java.lang.Thread.run(Thread.java:619)
12:06:17:369- [Logger@9215220 3.7.1.2] - ERROR - com.tangosol.coherence.component.util.logOutput.Log4j - 2012-02-02 12:06:17.369/14803.076 Oracle Coherence GE 3.7.1.2 <Error> (thread=DistributedCache-service:0, member=2): This thread was interrupted while waiting for the results of a request:
Poll
  PollId=377106, active
  InitTimeMillis=1328184377367
  Service=DistributedCacheForCommandPattern (5)
  RespondedMemberSet=[]
  LeftMemberSet=[]
  RemainingMemberSet=[8]
12:06:17:374- [Logger@9215220 3.7.1.2] - ERROR - com.tangosol.coherence.component.util.logOutput.Log4j - 2012-02-02 12:06:17.373/14803.080 Oracle Coherence GE 3.7.1.2 <Error> (thread=DistributedCache-service:1, member=2): This thread was interrupted while waiting for the results of a request:
Poll
  PollId=377107, active
  InitTimeMillis=1328184377373
  Service=DistributedCacheForCommandPattern (5)
  RespondedMemberSet=[]
  LeftMemberSet=[]
  RemainingMemberSet=[8]
  },

Similar Messages

  • IllegalMonitorStateException on close brace

    (package names shortened to make post prettier)
    java.lang.IllegalMonitorStateException
    at com...ThreadPool.finishedWork(ThreadPool.java:553)
    at com...ThreadPool.access$1000(ThreadPool.java:27)
    at com...ThreadPool$PoolThread.run(ThreadPool.java:752)
    at java.lang.Thread.run(Unknown Source)
    We get these type of errors in our product.. but we don't know why..:(
    workingThreads is declared like this:
    private TreeMap workingThreads = new TreeMap();
    And is never assigned to a new object anywhere in the code.
    private void finishedWork(Date timeToKill) {
    synchronized(workingThreads) {
    workingThreads.remove(timeToKill); // remove a thread
    } <-------Exception thrown here
    at com...ThreadPool.access$1000(ThreadPool.java:27)
    This part of the stack trace isn't always present... but the exception occuring at the end of the synchronizes close brace always is. It doesn't always happen in this method... sometimes it happens in other classes that synchronize on member variables.
    Ideas? questions? comments? help!!!?!?!

    Maybe you could post all the code in a synchronized
    block that gives you trouble and the full stack trace?
    synchronized(  tpLock  ) {
                    if( (objId != null) && (!objId.equals("")) ) {
                        SnmpContainer old = (SnmpContainer)goodOnes.put( m_ip, sc );
                        if( old == null  || !old.equals(sc) ) {
                            m_changedIps.add(m_ip);
                    else {  // it's a bad ip
                        goodOnes.remove( m_ip );
                    if (m_changedIps.contains(m_ip)) {
                        postEvent( sc );
                        m_changedIps.remove(m_ip);
                } <--- Exception hereDoing a search for tpLock shows that other then the declaration..it only appears as "synchronized (tpLock)"
    postEvent isn't in the stackTrace... and has no .waits/.notifys
    So this case... plus the first posting.. are very similar.. an exception being thrown on the close brace..:(
    Any trees I should be barking up?

  • Java.lang.IllegalMonitorStateException: current thread not owner

    Hello,
    my program runs an exe that doesn't return a zero when it's finished, therefore, I can't use a waitFor().
    To solve this problem i look at the length of the file which has to be manipulated by this exe every 200ms and see whether it's length stopped changing. This should mean it's job is done...
    But using this code:
    public void run(String filename)
              System.out.println("start runtime");
              Runtime rt = Runtime.getRuntime();
              String[] callAndArgs = { "lssvmFILE.exe", filename };
              try
                   Process child = rt.exec(callAndArgs);
                   child.wait(200);
                   filesize = 0;
                   while(filesize != file.length())                            {
                        filesize = file.length();
                        child.wait(200);
                   //child.waitFor();
                   System.out.println("Process exit code is:   " + child.exitValue());
              catch(IOException e)
              {     System.err.println( "IOException starting process!");}
              catch(InterruptedException e)
              {     System.err.println( "Interrupted waiting for process!");}
              System.out.println("end run");
         }i get this on my System.out:
    Exception occurred during event dispatching:
    java.lang.IllegalMonitorStateException: current thread not owner
            at java.lang.Object.wait(Native Method)
            at LssvmFile.run(LssvmFile.java:292)
            at LssvmFile.start(LssvmFile.java:189)
            at GUI.actionPerformed(GUI.java:137)
            at java.awt.Button.processActionEvent(Button.java:329)
            at java.awt.Button.processEvent(Button.java:302)
            at java.awt.Component.dispatchEventImpl(Component.java:2593)
            at java.awt.Component.dispatchEvent(Component.java:2497)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:339)
            at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:131)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:98)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:85)

    Here's the code:
    I already found out that the sleep function indeed caused this exe to run so slow. It seems that everything stops when sleep is used. By setting the delay to 2ms the duration is satisfactory (some seconds).
    I also tried skipping the sleep and just using a while, but that ended in an endless loop. Setting the delay to 1ms lead to a stop when the filelength was 0 (i guess that was on the moment that the exe cleared the file and prepared to write) so it seems to me that 2ms is quite a good trade off.
    this part of the code is preceeded by writing the data to the file and afterwards the new data will be read in again...
         //Close the stream
              outFileStream.close();
         //Run lssvmFILE.exe to compute alpha & b
              long originalfilesize = file.length();
              run(filename);
              //wait untill job done
              Thread thread = new Thread();
              long filesize = file.length();
              try{thread.sleep(2);}
              catch(InterruptedException e){};
              while(filesize != file.length() || originalfilesize ==file.length())
                   filesize = file.length();
                   try{thread.sleep(2);}
                   catch(InterruptedException e){};
         //Set up Instream (read from file)
         //----------------------Bedankt!
    Bart

  • IllegalMonitorStateException when closing streams

    Hi all,
    The following code throws an illegalMonitorStateException. Anyone know what I need to do?
    The documentatin says about an illegalMonitorStateException:
    Thrown to indicate that a thread has attempted to wait on an object's monitor or to notify other threads waiting on an object's monitor without owning the specified monitor.
    Do I need to notifyAll before closing?
         public void closeConnection () {
              try {
                   ins.close();    // InputStream
                   dins.close();   // DataInputStream
                   outs.close();   // OutputStream
                   douts.close();  // DataOutputStream
                   connection.close();
              catch (IOException ioException) {
                   displayMessage("IO Error", "Unable to close " +
                             "the connection (IOException: " +
                             ioException.getMessage() + ")");
              finally {
                   isGameCompleted = true;
                   notifyAll ();
                   bpMIDlet.destroyApp(true);
         }Thanks in advance.
    Maik

    What you need is:
    synchronized(this) {
          isGameCompleted = true;
          notifyAll ();
    }You should always surrond either a set and notify or a test and wait with synchronization on the object you are notifying/waiting on.

  • IllegalMonitorStateException on some queries

    Hi,
    Some SELECT statements in my java code consistently cause exceptions and Oracle core dumps.
    Here is one example:
    SELECT COUNT(H.harvest_id) FROM nm_harvest H , nm_messages M WHERE H.msg_uid=M.msg_uid AND M.user_id=1 AND H.harvest_type='foo' AND M.receive_date BETWEEN (TRUNC(SYSDATE, 'IW') -7) AND TRUNC(SYSDATE, 'IW')
    Can anyone see anything wrong with the statement above?
    This is what it throws:
    java.lang.IllegalMonitorStateException: current thread not owner
    at oracle.jdbc.oci8.OCIDBAccess.parseExecuteDescribe(OCIDBAccess.java)
    at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java)
    at oracle.jdbc.driver.OracleStatement.doExecute(OracleStatement.java)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java)
    at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java)
    at com.neomeo.DBL.DBCore.executeNonModQuery(DBCore.java:140)
    at com.neomeo.DBL.DBCore.getCount(DBCore.java:262)
    at com.neomeo.DBL.DBHarvest.getHarvestCount(DBHarvest.java:144)
    at com.neomeo.BL.HarvestService.getHarvestCount(HarvestService.java:119)
    at NMHarvest.getHarvest(NMHarvest.java:276)
    at NMHarvest.harvestView(NMHarvest.java:208)
    at NMHarvest.handle(NMHarvest.java:107)
    at org.webmacro.servlet.WMServlet.doRequest(WMServlet.java:251)
    at org.webmacro.servlet.WMServlet.doGet(WMServlet.java:212)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:499)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
    at org.apache.jserv.JServConnection.processRequest(JServConnection.java:314)
    at org.apache.jserv.JServConnection.run(JServConnection.java:188)
    at java.lang.Thread.run(Thread.java)
    This is Oracle 8.1.5.0.2 on Linux and the oci8 JDBC driver that came with it....
    Any help would be much appreciated!
    Thanks,
    Otis

    Thanks for the reply Sri!
    The restriction on Infocube wouldn't work either because I have a combination of queries I want to allow and prevent on the same InfoProvider.
    That option got me thinking though... I think another solution would be to create a MultiProvider, copy the queries I need to restrict to that new MultiProvider and then use a role based restriction. The only problem would be that my naming convention for Queries uses the InfoProvider as part of the technical name so I would have to change the names of queries too. (Not to mention the process of creating several MPs and copying the Qs)
    The other option you provide sounds feasible. Is it possible to change the owner of a query after creation? is it something you could easily do everytime you want to allow the editing of the Query?
    Let me put this example:
    a. User X creates a query that we want to control so noone can edit it before authorization.
    assuming the option to restrict by query owner:
    b. We change the owner of the query.
    c. The Query needs to be modified. I change the owner again to user X.
    d. After the modification is done, change the owner of the query again.
    Using this scenario I think I could have a pretty decent solution to my need. Do you think it could work? It heavily depends on being able to modify the owner of the query every time I need to edit or restrict its modification.
    Thanks for the time to help me out,
    JD

  • IllegalMonitorStateException on notify()

    I have a ready thread that runs a timer from up to down:
    public void run(){
                        int counter = timeInSeconds;
                        try {
                             if (countDown){
                                  while (counter > 0 && !stop){
                                  if(GestureGuide.isPause()){
                                       try {
                                                 wait();
                                            } catch (InterruptedException e) {
                                                 // TODO Auto-generated catch block
                                                 e.printStackTrace();
                                       text.text = textToPrint + counter;
                                       canvas.repaintCanvas();
                                       Thread.sleep(1000);
                                       counter--;
                                       setTimeLeftInSeconds(counter);
                             text.text = "Done";
                        } catch (InterruptedException e) {
                             if (!stop){
                                  GestureGuideLogger.getApplicationLog().logException(e);
                             text.text = "Stopped";
                        }finally{
                                  canvas.repaintCanvas();
                                  if (listener != null){
                                       if (!PrepareToTest){
                                            listener.timeThreadStopped();
                                       else {
                                            timeForPrepareEnded = true;
    I added "Pause" button to GUI.
    When "Pause" button pressed - I want to stop the timer thread.
    When "Pause" button released - I want to continue the timer thread.
    So I added the following things:
    I changed the TimerThread to:
    public void run(){
                   synchronized (this){
                        int counter = timeInSeconds;
                        try {
                             if (countDown){
                                  while (counter > 0 && !stop){
                                  if(GestureGuide.isPause()){
                                       try {
                                                 wait();
                                            } catch (InterruptedException e) {
                                                 // TODO Auto-generated catch block
                                                 e.printStackTrace();
                                       text.text = textToPrint + counter;
                                       canvas.repaintCanvas();
                                       Thread.sleep(1000);
                                       counter--;
                                       setTimeLeftInSeconds(counter);
                             text.text = "Done";
                        } catch (InterruptedException e) {
                             if (!stop){
                                  GestureGuideLogger.getApplicationLog().logException(e);
                             text.text = "Stopped";
                        }finally{
                             if(!GestureGuide.isPause()){
                                  canvas.repaintCanvas();
                                  if (listener != null){
                                       if (!PrepareToTest){
                                            listener.timeThreadStopped();
                                       else {
                                            timeForPrepareEnded = true;
    And I added another Thread that starts when"Pause" button state is changed to "pressed":
    public abstract class GestureGuideBaseTest......{
    protected TimerThread sleepThread;
         class StopPauseThread extends Thread {
         public void run() {
              synchronized (sleepThread) {
                   if(!GestureGuide.isPause()){
                        notify();
    The problem is, I get IllegalMonitorStateException on notify();
    How can I solve this?

    Well you synchronize on 'sleepThread' but you call notify() on 'this'. I'd expect you to call sleepThread.notify(), but that is without trying to understand what you are trying to do. The javadoc of the notify() method may provide some hints:
    http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html#notify%28%29

  • IllegalMonitorStateException Thrown From Synchronized Block

    Greetings,
    We recently had a case where a java.lang.IllegalMonitorStateException was thrown from section of code (in activemq) that I'm 99.9% sure was properly synchronized. Has anyone ever seen this exception thrown when the object whose wait method is being called is currently owened (via. a synchronized block)?
    The code that this exception occurred was in the backport-util-concurrent library. A get method (which is synchronized) call was made to a FutureTask instance which (eventually) calls Object.wait(). This call threw the exception. Below is the FutureTask code.
    public synchronized Object get() throws InterruptedException, ExecutionException
      waitFor();
      return getResult();
    private void waitFor() throws InterruptedException
      while (!isDone())
        wait();
    }And the stack trace on the exception was:
    ERROR - 21/2 08:56:41 - Failed to checkpoint a message store: java.lang.IllegalMonitorStateException - org.apache.activemq.store.journal.JournalPersistenceAdapter 395
    java.lang.IllegalMonitorStateException
    at java.lang.Object.wait(Native Method)
    at java.lang.Object.wait(Object.java:485)
    at edu.emory.mathcs.backport.java.util.concurrent.FutureTask.waitFor(FutureTask.java:267)
    at edu.emory.mathcs.backport.java.util.concurrent.FutureTask.get(FutureTask.java:117)
    at org.apache.activemq.store.journal.JournalPersistenceAdapter.doCheckpoint(JournalPersistenceAdapter.java:386)
    at org.apache.activemq.store.journal.JournalPersistenceAdapter$2.iterate(JournalPersistenceAdapter.java:129)
    at org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:117)
    at org.apache.activemq.thread.PooledTaskRunner.access$100(PooledTaskRunner.java:26)
    at org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:44)
    at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
    at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
    at java.lang.Thread.run(Thread.java:619)We are running Java 1.6 on solaris (64-bit). If anybody has any feedback on what might have caused this problem it would be appreciated.
    Thanks,
    Corey

    There seem to be some difficult to reproduce bugs in JDK 6 relating to hotspot compilation (and maybe synchronization). A few threads worth checking out:
    http://forum.java.sun.com/thread.jspa?threadID=5251785&tstart=0
    http://forum.java.sun.com/thread.jspa?threadID=5262404&tstart=0
    My own bug report (this one is reproducible): http://www.blinkenbyte.org/jvm/hotspot_bug_reviewid_1085121.html
    Which reminds me, I need to get around to submitting an update to the report.. disabling HotSpot compilation on the problematic method made the problem go away in my case...
    If at all possible to turn this into a test case, please do so and submit a bug report to Sun. Somehow Sun needs to pay attention to this problem, but I haven't even got a bug id on my problem despite it being 100% reproducible.

  • Java.lang.IllegalMonitorStateException problem

    Hi all,
    I'm using Future objects but I'm getting java.lang.IllegalMonitorStateException.
    The stack trace is the following:
    java.util.concurrent.ExecutionException: java.lang.IllegalMonitorStateException: current thread not owner
    [java]      at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:215)
    [java]      at java.util.concurrent.FutureTask.get(FutureTask.java:85)
    [java]      at stock.GUI$1.mouseClicked(GUI.java:168)
    [java]      at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:212)
    [java]      at java.awt.Component.processMouseEvent(Component.java:5491)
    [java]      at javax.swing.JComponent.processMouseEvent(JComponent.java:3126)
    [java]      at java.awt.Component.processEvent(Component.java:5253)
    [java]      at java.awt.Container.processEvent(Container.java:1966)
    [java]      at java.awt.Component.dispatchEventImpl(Component.java:3955)
    [java]      at java.awt.Container.dispatchEventImpl(Container.java:2024)
    [java]      at java.awt.Component.dispatchEvent(Component.java:3803)
    [java]      at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
    [java]      at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3901)
    [java]      at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
    [java]      at java.awt.Container.dispatchEventImpl(Container.java:2010)
    [java]      at java.awt.Window.dispatchEventImpl(Window.java:1774)
    [java]      at java.awt.Component.dispatchEvent(Component.java:3803)
    [java]      at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
    [java]      at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
    [java]      at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
    [java]      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
    [java]      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
    [java]      at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
    [java] Caused by: java.lang.IllegalMonitorStateException: current thread not owner
    [java]      at java.lang.Object.wait(Native Method)
    [java]      at dsm.mrmw.ReadHandler.remoteRead(ReadHandler.java:145)
    [java]      at dsm.mrmw.ReadHandler.call(ReadHandler.java:107)
    [java]      at dsm.mrmw.ReadHandler.call(ReadHandler.java:28)
    [java]      at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:269)
    [java]      at java.util.concurrent.FutureTask.run(FutureTask.java:123)
    [java]      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
    [java]      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
    [java]      at java.lang.Thread.run(Thread.java:595)
    where:
    - the chunk of code in GUI.java is
    try {
       Future<ISharedObject> result = memory.read(address); // the "read" call creates a ReadHandler object to satisfy the request
       try {
         SharedObject value = result.get(3, TimeUnit.SECONDS);   // line 168
         Stock s = (Stock) value.getObject();
       } catch (InterruptedException e1) {
         e1.printStackTrace();
       } catch (ExecutionException e1) {
         e1.printStackTrace();
      } catch (TimeoutException e1) {
         e1.printStackTrace();
    } catch (BadAddressException e1) {
         e1.printStackTrace();
    }while the chunk of code responsible for the exception in ReadHandler, a Callable object, is:
    // the line 107 is the call of this method
    private final ISharedObject remoteRead() throws ReadException,
         DuplicateRequestException {
              try {
                    *  Creates a new destination and stores it into the
                    *  subscriptions hash table.
                   Subscription toSubscribe = subscribe();
                   // Sends "synchronization" request ONLY if this subscription is
                   // not already present.
                   if (subscriptions.putIfAbsent(
                             toSubscribe.destination, toSubscribe) == null) {
                        toSubscribe.sendRequestMsg();
                   if (memory.queueThread(address.toString(), this) == null) {
                        try {
                             wait(timeoutInMillisecs);   // line 145
                        } catch (InterruptedException e) {
                             Thread.currentThread().interrupt();
                        return memory.get(address);
                   // else the request has already been submitted but it's still pending
                   throw new DuplicateRequestException();
              } catch (NamingException e) {
                   if (logger.isEnabledFor(Level.INFO)) {
                        logger.info("Unable to satisfy the remote read request: " +
                                  e.getLocalizedMessage());
                   throw new ReadException();
              } catch (JMSException e) {
                   if (logger.isEnabledFor(Level.INFO)) {
                        logger.info("Unable to satisfy the remote read request: " +
                                  e.getLocalizedMessage());
                   throw new ReadException();
              } finally {
                   memory.removeWaitingThread(address.getDestination());
         }How can I solve this error?
    Best regards,
    Michele

    I'll reply by by own: the solution seems to be making the remoteRead() method synchronized (or to use a synchronized block)

  • Java.lang.IllegalMonitorStateException

    This is my code
    BatchFile b= new BatchFile();
    boolean isgenerated=b.runBatch(checkExistSub,folder);
    if(isgenerated)
    boolean runBatch(String checkExistSub, File folder)
         boolean isBatchExecuted=false;
         fold = new File(folder+"\\");
         path1= "cmd /c C:\\temp\\ps.bat \"" + checkExistSub +"\"";
         try
              Process procapplyxsl = Runtime.getRuntime().exec(path1,null,fold);
              wait(1000);
              isBatchExecuted= true;
         catch(InterruptedException inte)
         catch(IOException ioe)
         return isBatchExecuted;
    Why am I getting the following error
    Exception in thread "main" java.lang.IllegalMonitorStateException: current thread not owner
    at java.lang.Object.wait(Native Method)
    at BatchFile.runBatch(BatchFile.java:117)
    at Main.execute(Main.java:459)
    at Main.main(Main.java:488)
    Java Result: 1

    I got the solution. Thanks to everyone.
    Message was edited by:
    Simmy

  • Synchronizing unrelated threads - java.lang.IllegalMonitorStateException

    Hi,
    I'm trying to synchronize two unrelated threads using a third object, but getting java.lang.IllegalMonitorStateException: current thread not owner error. Does any one know what am I doing wrong and how to fix it. A simulated code is posted below.
    Thanks in advance.
    // ----------- beginning of code --------------------------
    // Code that throws java.lang.IllegalMonitorStateException: current thread not owner error.
    public class ThreadTest
    public static void log( String message )
         System.out.println( Thread.currentThread().getName() + ":" + message );
    public static void main( String args[] )
         Thread thread1 = new Thread1();
         Thread thread2 = new Thread2();
         thread1.start();
         thread2.start();
         try
         thread1.join();
         thread2.join();
         catch (InterruptedException e)
         e.printStackTrace();
         log( "All Done...");
    class Thread1 extends Thread
    public void run()
         synchronized( Common.done )
         while (!Common.done.booleanValue())
              ThreadTest.log("Waiting on Common.done");
              try
              Common.done.wait();
              catch (InterruptedException e)
              e.printStackTrace();
    class Thread2 extends Thread
    public void run()
         synchronized( Common.done )
         ThreadTest.log( "Sleeping for 10 seconds ");
         try
              Thread.sleep( 10 * 1000 );
         catch (InterruptedException e)
              e.printStackTrace();
         ThreadTest.log( "Calling notifyAll");
         Common.done = Boolean.TRUE;
         // ******* Why am I getting 'java.lang.IllegalMonitorStateException: current thread not owner' in the next line
         Common.done.notifyAll();
    class Common
    public static Boolean done = Boolean.FALSE;
    // ----------- end of code --------------------------

    // ******* Why am I getting'java.lang.IllegalMonitorStateException:
    current thread not owner' in the next line
    Common.done.notifyAll(); Because x.notifyAll() has to be inside a
    synchronized(x) block.
    The code you posted looks like it meets that
    criteria, so I would have to conclude the code you
    posted does not represent the actual code you are
    running.Hi.. It is inside synchronized( Common.done) block... Thats why I'm confused....

  • Threadproblem - java.lang.IllegalMonitorStateException

    does anybody know why i'm getting a IllegalMonitorStateException here:
    public class Test()
    private TestThread test = null;
    public Test()
    test = new TestThread()
    test.start();
    foo();
    private foo()
    test.notify();
    public class TestThread
    extends Thread
    private synchronized void doIt()
    try
    wait();
    catch (InterruptedException e)
    System.out.println("check");
    public void run()
    while (true)
    doIt();
    }

    test.notify();To call the notify method you must have the monitor of the object. You gain the monitor through e.g. the synchronized-statement:
    synchronized (test) {
    test.notify();
    See the API documentation of the Object.notify method and the threading tutorial for details:
    http://java.sun.com/j2se/1.4.2/docs/api/
    http://java.sun.com/docs/books/tutorial/essential/threads/multithreaded.html

  • IllegalMonitorStateException: current thread not owner

    Hello I'm a new french developper in JAVA.
    I have problems to launch a command from my main class.
    Here is the method :
    private static boolean ConvertToPDF(Vector HTMLPath, String PDFPath, boolean DeleteHTMLSourceFile) {
              boolean      ConvertOK           = false;
              String           HTMLDocCommand      = "";
              String           HTMLSourcePath     = "";
              String           command;                // Command string
              Process      process;                // Process for HTMLDOC
              Runtime      runtime;                // Local runtime object
              InputStream input;
              byte           buffer[];
              int           bytes;
              // R�cup�ration du chemin du r�pertoire tampon HTML dans le fichier general.properties
             try {
                  mailProperties = (PropertyResourceBundle) ResourceBundle.getBundle("General");
             catch (MissingResourceException e) {
                  System.out.println("ConvertToPDF - Impossible de localiser le fichier general.properties");
             HTMLDocCommand = mailProperties.getString("HTMLDocCommand");
             for (int i=0;i<HTMLPath.size();i++){
                  HTMLSourcePath += (String) HTMLPath.elementAt(i) + " ";
              command = HTMLDocCommand+" "+PDFPath+" "+HTMLSourcePath;
              // Lancement du processus et attente de fin ...
              runtime = Runtime.getRuntime();
              try
                   process = runtime.exec(command);
                   System.out.println("D�but attente du processus");
                   process.notifyAll();
                   bytes = process.waitFor();
                   process.notifyAll();
                   System.out.println("Fin attente du processus");
                   // V�rification de l'existence du fichier de sortie
                   File PDFFile = new File(PDFPath);
                   if (PDFFile.exists())
                        ConvertOK = true;
                   else
                        ConvertOK = false;
              catch (Exception e)
                   ConvertOK = false;
                   System.out.print(e.toString() + " caught while running:\n\n");
                   System.out.print(" " + command + "\n");
              return ConvertOK;
         }When I Executing my class (from a windows command prompt) i Have this error message :
    IllegalMonitorStateException: current thread not owner caught while running <mycommand>
    I have also tried to use the "synchronied method" :
    private static boolean ConvertToPDF(Vector HTMLPath, String PDFPath, boolean DeleteHTMLSourceFile) {
              boolean      ConvertOK           = false;
              String           HTMLDocCommand      = "";
              String           HTMLSourcePath     = "";
              String           command;                // Command string
              Process      process;                // Process for HTMLDOC
              Runtime      runtime;                // Local runtime object
              InputStream input;
              byte           buffer[];
              int           bytes;
              // R�cup�ration du chemin du r�pertoire tampon HTML dans le fichier general.properties
             try {
                  mailProperties = (PropertyResourceBundle) ResourceBundle.getBundle("General");
             catch (MissingResourceException e) {
                  System.out.println("ConvertToPDF - Impossible de localiser le fichier general.properties");
             HTMLDocCommand = mailProperties.getString("HTMLDocCommand");
             for (int i=0;i<HTMLPath.size();i++){
                  HTMLSourcePath += (String) HTMLPath.elementAt(i) + " ";
              command = HTMLDocCommand+" "+PDFPath+" "+HTMLSourcePath;
              // Lancement du processus et attente de fin ...
              runtime = Runtime.getRuntime();
              try
                   process = runtime.exec(command);
    synchronized(process){
                   System.out.println("D�but attente du processus");
                   process.notifyAll();
                   bytes = process.waitFor();
                   process.notifyAll();
                   System.out.println("Fin attente du processus");
                   // V�rification de l'existence du fichier de sortie
                   File PDFFile = new File(PDFPath);
                   if (PDFFile.exists())
                        ConvertOK = true;
                   else
                        ConvertOK = false;
              catch (Exception e)
                   ConvertOK = false;
                   System.out.print(e.toString() + " caught while running:\n\n");
                   System.out.print(" " + command + "\n");
              return ConvertOK;
         }But I have the same error message. Maybe the synchronised is not on the right object ?
    Could anyone help me ?
    Thanks for all.

    - The exception is thrown during process.notifyAll() calls; can u try commenting out those calls?
    - For questions on java, you may also want to try the forum at:
    http://forum.java.sun.com/category.jspa?categoryID=32

  • IllegalMonitorStateException problem

    er, i'm having a problem with thread in an applet
    i'm trying to make it so the thread runs only when the mousedrag() method returns an event, which is that i want the thread to run only while i'm dragging the mouse
    using the wait() and notify() methods. but i get a error message saying this:
    java.lang.IllegalMonitorStateException: current thread not owner
    why is this happening? can anyone teach me the "right" way of implementing a thread using the wait and notify methods completely? i'd appreciate it.
    thanx,
    kev

    You can only call notifyAll(), notify(), or wait()
    from within a synchronized block either by using a synchronized method
    like
    // tries to get the lock for the current object
    public synchronized void myMethod()
       while ( something)
         try
            wait();
         catch( InterruptedException ie)
    }or by something more strange
    public void strangeSynchronization()
       synchronized( synchronizedObject)
          synchronizedObject.doSomething();
          synchronizedObject.notifyAll();

  • Threads cause IllegalMonitorStateException

    The very simple multithreaded application program below is producing the following exceptions
    Exception in thread "main" java.lang.IllegalMonitorStateException: current thread not owner
    at java.lang.Object.wait(Native Method)
    at java.lang.Object.wait(Object.java:426)
    at BlockSync.run(BlockSync.java:19)
    at BlockSync.main(BlockSync.java:5)
    java.lang.IllegalMonitorStateException: current thread not owner
    at java.lang.Object.notifyAll(Native Method)
    at Thread_1.run(BlockSync.java:48)
    Help in understanding why would be much appreciated...
    Thanks in advance for any replies
    Application code:
    class BlockSync
    public static void main(String[] args)
    new BlockSync().run();
    public GoFlag gf;
    public void run()
    gf=new GoFlag();
    new Thread_1(gf).start();
    // wait until Thread_1 sets goFlag then continue;
    synchronized (gf)
    if(gf.goFlag==false)
    try { wait(); } catch (InterruptedException e) {}
    class GoFlag
    public boolean goFlag;
    GoFlag()
    goFlag=false;
    class Thread_1 extends Thread
    public GoFlag g;
    Thread_1(GoFlag gf)
    g=gf;
    // wait a second then set goFlag
    public void run()
    try { sleep(1000); } catch (InterruptedException e) {}
    synchronized (g)
    g.goFlag=true;
    notifyAll();

    class BlockSync
    public GoFlag gf;
    public void run()
    gf=new GoFlag();
    new Thread_1(gf).start();
    // wait until Thread_1 sets goFlag then continue;
    synchronized (gf)
    if(gf.goFlag==false)
    try { wait(); } catch (InterruptedException e) {}
    }You can only call wait if you are within a synchronized block ON THAT OBJECT.
    You are synchronizing on gf, but waiting on this
    You probably wanted to do gf.wait();

  • IllegalMonitorStateException from StringBuffer.append()

    Hi,
    I am having a not-easily reproducible problem about IllegalMonitorStateException.
    I have an event dispatching Thread that runs fine for roughly 10 hours. But after that "IllegalMonitorStateException" happens
    most of the time from JRE methods like StringBuffer.append() or Hashtable.clear().
    One observation that i had made is that the IllegalMonitorStateException is happening from synchronized methods.
    I have never received this IllegalMonitorStateException from any wait() ot notify() calls in my code.
    Could somebody please help me with this.
    I am using pbp 1.0
    Thanks in advance.

    Thanks "ChuckBing" for the reply
    ChuckBing wrote:
    Thrown to indicate that a thread has attempted to wait on an object's monitor or to notify other threads waiting on an object's monitor without owning the specified monitor.
    I understand that IllegalMonitorStateException is thrown normally when we try to do a wait(), notify() or notifyAll() while not holding lock on the same object.
    But here the scenario is different. See the stack trace log.
    java.lang.IllegalMonitorStateException: current thread not owner
         at java.lang.StringBuffer.append(I)Ljava/lang/StringBuffer;(Unknown Source)
         at java.lang.Thread.startup(Z)V(Unknown Source)
    The exception came from append() method of StringBuffer class. I went through the source code of the StringBuffer class and found the append() method's implementation as
    public synchronized StringBuffer append(String str) {
         if (str == null) {
         str = String.valueOf(str);
         int len = str.length();
         int newcount = count + len;
         if (newcount > value.length)
         expandCapacity(newcount);
         str.getChars(0, len, value, count);
         count = newcount;
         return this;
    So the situation is that an IllegalMonitorStateExceptiion is being thrown from a synchronized method where there are no wait(), notify() or notifyAll() being used.
    Other than wait(), notify() or notifyAll(), what other Java programming mistake can cause such an Exception to be thrown?

Maybe you are looking for

  • Does labview have drag and drop capability while a program is running

    Suppose I have a cluster with controls of various datatypes on the front panel of one vi. Is it possible to represent that cluster with an icon, and then drag that icon on to the front panel of a second vi? The information in the cluster would then b

  • How to unlock my iPhone once it is disabled, How to unlock my iPhone once it is disabled

    A little kid locked my phone to where it says hook up to iTunes, I did that and it asked me to unlock my phone. I obviously can't do that since that is not an option. I need help!!

  • FIOS REMOTES STOLEN IN ROBBERY

    Hi we were robbed last friday and they stole everything. Our Laptops, TV's etc.  We didn't notice until today when we replaced all of the TV's from the insurance that we were missing all of the remotes to our fios boxes.  How can we get replacement r

  • Temperature monitor lite

    temperature monitor lite has detected the SMART sensor on my 1.83 mbp... can anyone tell me what temperature range is "normal" for my machine? thanks in advance. MacBook Pro   Mac OS X (10.4.6)  

  • How to register for class while using ActiveX

    Hi I am trying to use ActiveX to send an email with Microsoft Outlook. I have found an example Vi. but i was getting an error with code "-2147221164" (Class not registered in Outlook_Mail-1.vi). How to register for that class and what are the files r