FileUpload: Current thread not ownet?

Hi, I use the common Apache FileUpload lib.
When i use it on my local server i work!
But on my NetWare Tomcat server, i got this message:
Error Message:current thread not owner
java.lang.IllegalMonitorStateException: current thread
not owner
at
org.apache.commons.fileupload.DefaultFileItem.getUniqueId(DefaultFileItem.java,
Compiled Code)
at
org.apache.commons.fileupload.DefaultFileItem.getTempFile(DefaultFileItem.java:623)
at
org.apache.commons.fileupload.DefaultFileItem.getOutputStream(DefaultFileItem.java:563)
at
org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java,
Compiled Code)
at UploadFile.doPost(UploadFile.java:54)
Someone got an id�a???
thx a lot

Are you using java 1.4 ? And so is your netware server ?
http://developer.java.sun.com/developer/bugParade/bugs/4776385.html

Similar Messages

  • 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

  • Javaws 1.4.2 "current thread not owner"

    Hello everyone,
    I have an application that I have been launching with javaws since the javaws 1.0.x days that won't work with javaws 1.4.2. Does anyone have any clue as to what could be wrong?
    Java Web Start 1.4.2 Console, started Thu Aug 21 09:15:25 EDT 2003
    Java 2 Runtime Environment: Version 1.2.2 by Sun Microsystems Inc.
    --------- EXCEPTION ---------
    java.lang.IllegalMonitorStateException: current thread not owner
         at com.sun.javaws.security.JNLPClassPath.findNamedResourceInLoaders(Unknown Source)
         at java.lang.ClassLoader.loadClass(ClassLoader.java, Compiled Code)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java, Compiled Code)
         at com.sun.javaws.security.JNLPClassPath.findNamedResource(Unknown Source)
         at com.sun.javaws.security.JNLPClassPath.getResource(Unknown Source)
         at com.sun.jnlp.JNLPClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sun.jnlp.JNLPClassLoader.findClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(ClassLoader.java, Compiled Code)
         at java.lang.ClassLoader.loadClass(ClassLoader.java, Compiled Code)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java, Compiled Code)
         at org.apache.xerces.framework.XMLParser.<init>(XMLParser.java)
         at org.apache.xerces.framework.XMLParser.<init>(XMLParser.java)
         at org.apache.xerces.parsers.DOMParser.<init>(DOMParser.java)
         at com.fpl.ima.deployit.options.DeployItOptions.loadOptions(DeployItOptions.java, Compiled Code)
         at com.fpl.ima.deployit.options.DeployItOptions.getInstance(DeployItOptions.java)
         at com.fpl.ima.deployit.DeployIt.initialize(DeployIt.java)
         at com.fpl.ima.deployit.DeployIt.<init>(DeployIt.java)
         at com.fpl.ima.deployit.DeployIt.main(DeployIt.java)
         at java.lang.reflect.Method.invoke(Native Method)
         at com.sun.javaws.Launcher.executeApplication(Unknown Source)
         at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
         at com.sun.javaws.Launcher.continueLaunch(Unknown Source)
         at com.sun.javaws.Launcher.handleApplicationDesc(Unknown Source)
         at com.sun.javaws.Launcher.handleLaunchFile(Unknown Source)
         at com.sun.javaws.Launcher.run(Unknown Source)
         at java.lang.Thread.run(Thread.java:479)
    Exception occurred in main() of DeployIt
    java.lang.IllegalMonitorStateException: current thread not owner
         at com.sun.javaws.security.JNLPClassPath.findNamedResourceInLoaders(Unknown Source)
         at java.lang.ClassLoader.loadClass(ClassLoader.java, Compiled Code)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java, Compiled Code)
         at com.sun.javaws.security.JNLPClassPath.findNamedResource(Unknown Source)
         at com.sun.javaws.security.JNLPClassPath.getResource(Unknown Source)
         at com.sun.jnlp.JNLPClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sun.jnlp.JNLPClassLoader.findClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(ClassLoader.java, Compiled Code)
         at java.lang.ClassLoader.loadClass(ClassLoader.java, Compiled Code)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java, Compiled Code)
         at com.fpl.ima.deployit.DeployIt.main(DeployIt.java)
         at java.lang.reflect.Method.invoke(Native Method)
         at com.sun.javaws.Launcher.executeApplication(Unknown Source)
         at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
         at com.sun.javaws.Launcher.continueLaunch(Unknown Source)
         at com.sun.javaws.Launcher.handleApplicationDesc(Unknown Source)
         at com.sun.javaws.Launcher.handleLaunchFile(Unknown Source)
         at com.sun.javaws.Launcher.run(Unknown Source)
         at java.lang.Thread.run(Thread.java:479)

    I can only guess at the likely cause. Previously (jws 1.2 and earlier) every web start process would kick off a jvm for the web start client to process the jnlp, this would in turn then kick off a second jvm to run the actual application.
    1.4.2 has changed this slightly to improve startup time etc.. the second jvm process doesn't happen, and now the web start app runs from the same jvm that the web start client has started for itself. This is why the integration dialog is such a problem with modal apps in 1.4.2 -- they're sharing (and conflicting with) the same event thread.
    At least this is what I think is happening ~ I'm very sure but cant be 100% certain ..because much like the autodownloads Sun haven't published any of the source for 1.4.2 web start (shouldn't this be part of the shipped sdk source these days?).
    I guess this change breaks your previous class-loading assumptions.
    - Richard

  • 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

  • Current thread not owner

    Exception in thread "AWT-EventQueue-0" java.lang.IllegalMonitorStateException: current thread not owner
         at java.lang.Object.wait(Native Method)
         at java.lang.Object.wait(Unknown Source)
         at OneTab.OneForm.OneForm.stop_watch(OneForm.java:104)
         at DraMain_Sub.actionPerformed(DraMain.java:129)
         at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
         at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
         at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
         at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
         at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
         at java.awt.Component.processMouseEvent(Unknown Source)
         at javax.swing.JComponent.processMouseEvent(Unknown Source)
         at java.awt.Component.processEvent(Unknown Source)
         at java.awt.Container.processEvent(Unknown Source)
         at java.awt.Component.dispatchEventImpl(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Window.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)I just want to know this message.
    "java.lang.IllegalMonitorStateException: current thread not owner".
    What is it?
    try{
    this.wait();
    }catch(InterruptedException e){}I just want to do it.

    my initial guess would be that the OP needs a refresher on wait and
    notify. There are plenty of tutorials available and spending 15 20
    min on one of them would not be a waste of time, trust me!!!!!But this reply did not come from Jos, so it will apparantly be ignored.Hm, if that were true I wouldn't like it one bit. Lots of people give valuable
    advice here and the last thing I would want is a 'status aparte'.
    kind regards,
    Jos

  • Object.wait(): IllegalMonitorStateException: current thread not owner

    How can I identify the owner? I searched the Thread*-Classes but didn't see any method which identifies the owner.

    Or, from the documentation for Object.wait():
         * The current thread must own this object's monitor.and
         * This method should only be called by a thread that is the owner
         * of this object's monitor. See the <code>notify</code> method for a
         * description of the ways in which a thread can become the owner of
         * a monitor. and
         * @exception  IllegalMonitorStateException  if the current thread is not
         *               the owner of the object's monitor.Seems like a lot of people are getting broken downloads nowadays that don't include the documentation :-(

  • Why:current thread not owner?

    Here is my class:
    public class TestThread extends Thread {
        /* (non-Javadoc)
         * @see java.lang.Thread#run()
        @Override
        public void run() {
            System.out.println("begin");
            Test.check();
            System.out.println("end");
    public class Test {
        private static Integer s_count = 0;
        public static void check() {
            synchronized (s_count) {
                while (s_count > 0) {
                    try {
                        s_count.wait();
                        System.out.println("notify");
                    } catch (InterruptedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
         * @param args
         * @throws InterruptedException
        public static void main(String[] args) throws InterruptedException{
            for (int i = 0; i < 5; i++) {
                s_count++;
                TestThread tt = new TestThread();
                tt.start();
            for (int i = 0; i < 5; i++) {
                Thread.sleep(3000);
                System.out.println(i);
                synchronized (s_count) {
                    s_count--;
                    System.out.println("s_count is:"+s_count);
                    if (s_count == 0) {
                        try {
                            s_count.notifyAll();
                        } catch (Exception e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                    System.out.println("ssss");
    }

    you are incrementing an Integer member var, which means you are creating a new object each time, hence as each thread runs, it is using a variety of different object references. try separating the lock from the counter:
        private static final Object s_lock = new Object();
        private static int s_count = 0;
        synchronized(s_lock) {
          // do your work on s_count
        }

  • Player's position slider (Thread not owner)

    Hi every1,
    I've a thread that sets a slider value with the player's time in secods,but in case the slider Knob is dragged by the user the thread should wait and player's time should be set as per the value dragged by the user.
    But the wait() method is not executing instead it generates IllegalMonitorStateException: current thread not owner exception. Would you help me please?
    My code is:
    //the thread which sets the slider value as the time in second increases
    public void run() {
         while (true) {
                        if (player != null) {
               nano = player.getMediaTime().getSeconds();
              if (dura >nano) {
                  timex = (int)nano;
                        jSlider.setValue(timex);
                     try {
              Thread.currentThread().sleep(1000);
             } catch (InterruptedException ie) {
        }//the method which sets the slider as a user moves the knob of the slider
    jSlider.addChangeListener(new javax.swing.event.ChangeListener() {
                public void stateChanged(javax.swing.event.ChangeEvent evt) {
                   try{
                      if(jSlider.getValueIsAdjusting()){
    player.setMediaTime(new javax.media.Time((double)  
    jSlider.getValue())); 
                    thr.wait();                  }
                   }catch(Exception e){e.printStackTrace();
                      System.out.println("Exception @ jSlider stateChanged : " + e.getMessage() );
            });Thanks!

    The exception is happening because the ChangeListener thread does not own the monitor on "thr" (see the api documentation for Object.wait). That can be fixed by putting it in a synchronized (this) { ... } block.
    However, I see bigger problems. First, recognize that Java is going to call your ChangeEvent code on the event handling thread, so you definitely don't want it to wait. The screen will stop repainting and the user's mouse release event won't be processed, because you will have suspended the thread that handles those things. Second, you should not modify the position of the slider from any thread other than the event handling thread, for reasons documented at [http://java.sun.com/developer/technicalArticles/Threads/swing/]. That article also shows techniques that are safe.
    I don't mean to be discouraging, just wanted to point out a couple more things so you didn't get strange behavior without knowing why! What you are attempting actually requires some multi-threading skill, so study up!
    Cheers,
    Eric

  • Threads not working together well  !

    Dear People,
    The following line of code gives an error message:
    while(inTray.size() != 0)
    The error message says:
    current thread not owner, Exception in thread "main"
    Thank you for your advice
    Stan

    Dear Dubwai,
    Here is the entire output. (Except for entire list
    t of credits and debits posted by the bank. )
    Start debit of A//C No. 2 : $971 amount: 45
    Start credit of A//C No. 1 : $624 amount: 71
    End credit of A//C No. 1 : $695 amount: 71
    java.lang.IllegalMonitorStateException: current thread
    not owner
         at java.lang.Object.wait(Native Method)
         at java.lang.Object.wait(Object.java:426)
         at stan_ch15p638.Clerk.isBusy(Clerk.java:80)
    at
    stan_ch15p638.TryBankOperation.main(TryBankOperation.j
    va:75)
    End debit of A//C No. 2 : $926 amount: 45
    Start debit of A//C No. 2 : $926 amount: 48
    Exception in thread "main"
    I would post the entire program but the last time I
    did that
    I received a negative response. The error message
    speaks of
    line 75 which is the line posted previously.No it isn't.
    This is what you posted.
    while(inTray.size() != 0)
    In the above stack trace the following appears...
    Clerk.isBusy...
    That is where the problem occurs in your code.

  • Is there a way to figure out what the current thread is?

    I've got the following snippet of code:
    // create a new thread. If the current thread is not this new thread, return
    Thread CountDownThread = new Thread("CountDownThread");
    CountDownThread.start();
    if (/*CURRENT THREAD*/.getName() != CountDownThread.getName()) {
         System.out.println ("I'm not CountDownThread. I'm leaving.");
         return;
    // current thread should be new thread. Therefore start the countdown
    CurrTime = InitTime;
    while(CurrTime.charAt(0) != '-') {      // go until current time is negative
         CurrTime = C.countDown();       // returns the current time based on the difference between the initial and elapsed time
         setText(CurrTime);                   // display current time in JLabel
    C.reset();
    setText(C.getCurrTime());What I'm trying to do is get a clock (C) to count down and display the time remaining in a JLabel (this snippet is taken from a method within that very JLabel which I'm extending from javax.swing.JLabel). While it's counting down, I'd like for the program to go off and do other things. Therefore, I'm trying to create a new thread that carries out the task of counting down while the original/main thread moves on to do other things.
    Please have a look at the above code and tell me if I'm on the right track. The one thing I don't know how to do is figure out how to tell which thread the current thread is. I'm assuming that both the new thread and original/main one will execute the if statement, the new one after it returns from start() (which I haven't defined). The original/main one will detect that it is not the new thread and return, whereas the new thread will and go on to the while loop. In the while loop, it will count down the clock until it reaches 0, after which point it will reset it and die.
    If I'm on the right track, all I need to know is how to detect which thread is currently executing. If I'm not on the right track, what would be the best way to do this?

    What? No! No Thread terminates on the return of start(). Those two events are unrelated!Uh... I think you misunderstood what I said.
    I didn't say that CountDownThread terminates upon returning from start() (which is what it sounds like you interpreted from me); I said that the thread that CountDownThread creates terminates once CountDownThread returns from start() (i.e. like any other local variable/object). This, of course, assumes that CountDownThread has a Runnable object on which to call its run() method (am I right?), in which case my code above doesn't create a new thread at all (i.e. CountDownThread.start() is executed within the main/original thread) - am I right?
    No, run() doesn't call start()! That would be stupid.Again, you misunderstood. I shouldn't need to explain this one. A simple reference to an ordinary dictionary on the words 'former' and 'latter' should suffice :)
    Anyway, all joking aside, I have now improved my code and it works! Here's what it looks like:
    ClockJLabel.java
    package MazeMania.clock;
    public class ClockJLabel extends javax.swing.JLabel {
    private Clock C;
    private ClockJLabelsRunnable CJLR;
    public ClockJLabel() {
      C = new Clock();
      CJLR = new ClockJLabelsRunnable();
      setText(C.getCurrTime()); // should be 00:00:00:00
      setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
      // need to figure out how to set the size so that it sticks
      setForeground(new java.awt.Color(255, 0, 0));
      setBackground(new java.awt.Color(0, 0, 0));
      setOpaque(true);
    // starts the clock counting up indefinitely from 0
    public void start() {
      (new Thread(new Runnable() {
        public void run() {
         while(true) setText(C.getElapsedTime());
       })).start();
      //System.out.println("Started clock...");
    // starts the clock counting down from an initial time and runs this count down in a separate thread
    public void countDown(String InitTime) {
      // initialize the clock
      try {C.initClock(InitTime);}
      catch(java.text.ParseException PE) {
       System.out.println(PE.getMessage());
      // initialize JLabel's display
      setText(C.getCurrTime());
      // prepare Runnable and give it to new Thread. New Thread starts count down.
      CJLR.task = CJLR.COUNTDOWN;
      CJLR.CJL = this;
      Thread CountDownThread = new Thread(CJLR);
      CountDownThread.start();
    public Clock getClock() {
      return C;
    }ClockJLabelsRunnable
    package MazeMania.clock;
    import java.lang.Runnable;
    class ClockJLabelsRunnable implements Runnable {
    public static int COUNTDOWN = 1;
    public static int COUNTUP = 2;
    // NOTE: this Runnable doesn't test for the proper setting of these variables
    public int task = 0;
    public ClockJLabel CJL = null;
    public void run() {
      Clock C = CJL.getClock();
      while(C.countDown().charAt(0) != '-') {CJL.setText(C.getCurrTime());}
      C.reset();
      CJL.setText(C.getCurrTime());

  • Can I execute C code in current Thread(process)?

    Hi all,
    I want to execute a Linux command within current Thread, but Runtime.exec() will start a new process to execute the command specified.
    Does JNI can execute any system command or any C program in current Thread?
    BTW, I tried JNA, following code will start new process too:
    public interface CLibrary extends Library {
    CLibrary INSTANCE = (CLibrary)Native.loadLibrary((Platform.isWindows() ? "msvcrt" : "c"),CLibrary.class);
    void printf(String format, Object... args);
    void system(String cmd);
    public static void main(String[] args) {
         CLibrary.INSTANCE.system("sleep 5s");
    Can I execute the Linux command within current Thread with JNA?
    Any anwser will be appreciated!! Thanks!!
    Raymond Zeng
    Edited by: raymond.zeng on Dec 2, 2009 8:19 AM

    Hi sabre150,
    Thank you very much!
    In fact, the reason I want native code run in current process is that native code will lock some system resource(such as COM port), I want to manipulate that resource in Java code after calling native code. (native code may run in a new thread for a long time, in the same time, Java code may need to manipulate the resource in other thread)
    It is not import about whether start a new thread or not, but I really want the native code will be executed in a same process, so OS will not prevent me to manipulate that resource.
    Is there any smart solution to do this?
    Thanks!
    Raymond Zeng

  • Error starting thread: Not enough storage is available to process...

    Hi all,
    We are seeing server going down frequently with below exception:
    [ERROR][thread ] Failed to start new thread
    [2010-04-08 14:36:54,046][ERROR][com.astrazeneca.portal.rss.ContentTransformer] - Error processing item:null
    ; SystemID: http://beaa.astrazeneca.net:10002/NewsBroker/resources/newsToRss.xsl; Line#: 21; Column#: 128
    javax.xml.transform.TransformerException: java.lang.Error: Error starting thread: Not enough storage is available to process this command.
         at org.apache.xalan.extensions.ExtensionHandlerJavaPackage.callFunction(ExtensionHandlerJavaPackage.java:403)
         at org.apache.xalan.extensions.ExtensionHandlerJavaPackage.callFunction(ExtensionHandlerJavaPackage.java:426)
         at org.apache.xalan.extensions.ExtensionsTable.extFunction(ExtensionsTable.java:220)
         at org.apache.xalan.transformer.TransformerImpl.extFunction(TransformerImpl.java:437)
         at org.apache.xpath.functions.FuncExtFunction.execute(FuncExtFunction.java:199)
         at org.apache.xpath.XPath.execute(XPath.java:268)
         at org.apache.xalan.templates.ElemVariable.getValue(ElemVariable.java:279)
         at org.apache.xalan.templates.ElemVariable.execute(ElemVariable.java:247)
    I have a weblogic support SR open and they suggested to add -XXtlaSize and -XXlargeObjectLimit to our JVM parameter. With these parameters, we are getting below error in Windows frequently:
    Reporting queued error: faulting application java.exe, version 1.5.0.11, faulting module jvm.dll, version 27.3.1.1, fault address 0x0014b442.
    I have seen few threads on Sun forum, but answer was not posted there. Details of our environment are as below:-
    JVM : JROCKIT 1.5.0.11
    OS : Windows 2003
    Application Server : Weblogic 10
    Any inputs or pointers will be highly appreciated as this is a bit urgent for me...
    Thanks & Regards,
    Sanjeev

    Hi Henrik,
    I am running Weblogic with below parameters now:
    -Xnohup -Xms:1536m -Xmx:1536m -XXtlaSize:min=32k,preferred=768k -XXlargeObjectLimit:32K
    Weblogic crashed again with below dump:
    ===== BEGIN DUMP =============================================================
    JRockit dump produced after 0 days, 07:17:18 on Fri May 07 15:26:16 2010
    Additional information is available in:
    E:\PortalLIVDomaina\jrockit.5772.dump
    E:\PortalLIVDomaina\jrockit.5772.mdmp
    If you see this dump, please open a support case with BEA and
    supply as much information as you can on your system setup and
    the program you were running. You can also search for solutions
    to your problem at http://forums.bea.com in
    the forum jrockit.developer.interest.general.
    Error Message: Illegal memory access. [54]
    Exception Rec: EXCEPTION_ACCESS_VIOLATION (c0000005) at 0x005148AF - memory at 0x00000000 could not be written.
    Minidump : Wrote mdmp. Size is 1406MB
    SafeDllMode : -1
    Version : BEA JRockit(R) R27.3.1-1_CR344434-89345-1.5.0_11-20070925-1628-windows-ia32
    GC Strategy : Mode: throughput. Currently using strategy: genparpar
    GC Status : OC currently running, in phase: sweeping. This is OC#3000.
    : YC is not running. Last finished YC was YC#9937.
    OC History : Strategy genparpar was used for OC#1.
    : Strategy singleparpar was used for OC#2.
    : Strategy genparpar was used for OC#3 to OC#3000.
    YC History : Ran 11 YCs before OC#2996.
    : Ran 18 YCs before OC#2997.
    : Ran 11 YCs before OC#2998.
    : Ran 8 YCs before OC#2999.
    : Ran 1 YCs before OC#3000.
    Heap : 0x00900000 - 0x60900000
    Compaction : 0x06900000 - 0x0C900000
    Could you please provide some input on this?
    Thanks,
    Sanjeev

  • Getting error BEA-382051:No transaction found on current thread

    Hi,
    I am getting "BEA-382051:No transaction found on current thread" error while routing proxy service to business service.
    I also tried adding Routing Options in routing action with quality of service as "exactly once" but still got the same issue.
    I am using OSB 11.1.1.5.
    Thanks in advance.

    Hi,
    Plz read following
    BEA-382051 Error: No transaction found on the current thread
    Description: There was an internal error in OSB pipeline runtime while processing the inbound request by a proxy service. The state of OSB pipeline was not expected
    Action:Contact technical support
    ref: http://docs.oracle.com/cd/E23549_01/apirefs.1111/e15034/Router.html
    Thanks,
    S

  • Obtaining initialcontext from t3 client leaks current thread

    Summary: creating an initial context from a t3 client leaks the current
    thread.
    NB: I posted about this problem recently, except that the initialcontext was
    obtained from
    within the Weblogic server. I was told that user threads should not be
    spawned from within
    the server. I've since discovered that the problem also exists from a T3
    client as well.
    Any solutions/workarounds?
    Our temporary workaround is to maintain our own thread pool, and never
    expire threads
    out of the pool. That appears to mitigate the problem, but I'm a little
    leery of reusing
    threads when it appears as though parts of Weblogic key off the thread
    object (this is
    what seems to be causing the leak in the first place.) Is this a correct
    workaround?
    Regards,
    -kb-
    Sample output:
    java -mx64m -ms64m com.snapfish.test.SimpleTestJVMSockHTTPClient: connect() success to host: localhost port: 7001 sockID: 4
    Avail mem is 66325400
    Avail mem is 66240784
    Avail mem is 66139744
    Avail mem is 66038672
    Avail mem is 65937600
    Avail mem is 65836528
    Avail mem is 65735456
    Avail mem is 65634392
    Avail mem is 65533240
    Avail mem is 65432208
    -- SimpleTest.java --
    package com.snapfish.test;
    import java.util.Properties;
    import javax.naming.InitialContext;
    import javax.naming.Context;
    public class SimpleTest
    public static void main(String arg[])
    for (int i=0; i<1000; i++) {
    Thread t = new Thread () {
    public void run() {
    try {
    Properties p = new Properties();
    p.put(Context.INITIAL_CONTEXT_FACTORY,
    "weblogic.jndi.WLInitialContextFactory");
    p.put(Context.PROVIDER_URL,
    "http://localhost:7001");
    InitialContext ctx = new InitialContext(p);
    ctx.close();
    ctx = null;
    catch (Exception ex) {
    ex.printStackTrace();
    return;
    private byte buf[] = new byte[100000];
    t.start();
    try {  t.join(); }
    catch (InterruptedException ex) {
    ex.printStackTrace();
    return;
    t = null;
    System.gc();
    System.out.println("Avail mem is
    "+Runtime.getRuntime().freeMemory());

    You will need the generated stubs packaged on the client side.

  • Stop current thread

    I have got a Thread (made from swing thread).
    In the run() method i create a frame with a button that has an "actionperformed" and I show this frame and I put a loop like "
    while(true){
    Thread.currentTread.sleep(1000);
    System.out.println("bip");
    But in the button action I try to kill this Thread.
    But, no one of the methods from Thread class "yield", "destroy", "interrupt" seems to work.
    QUESTION :
    ==> How can I do to kill a Thread when I have his name or when it is the current Thread.

    Right - your best option is to either make the thread null (thus removing the object and stopping the thread from running), which is a bit heavy handed. Be careful of this, especially if you'll be creating new instances all the time - creating and scheduling threads can be quite processor and time intensive.
    The other option is to have the while loop use a boolean variable, such that you can do something like
    // instnace variable:
    private boolean running = true;
    // now a method to modify it:
    public void setRunning(boolean run)
      running = run;
    //some more code in your class...
    // now the body of the run method:
    while(running)
      Thread.currentTread.sleep(1000);
      System.out.println("bip");
    }Thus, when someone calls yourObjectName.setRunning(false), the run() method will quit.
    All you have to do now is call yourObjectName.start() to make it run again.
    I can't think of any cleaner ways to do this, so if they're any Java Gurus out there, help me out here.
    So, do this if you want to stop a thread running; but if you really want to kill it, and not use it again, make the object null.
    Let me know if this works for you,
    Rich

Maybe you are looking for