I have the following problem:
One swing application is executed in the following way:
- C++ code is executed via windows service
- this C++ code runs a batch file.
- the batch file executes swing application
When this swing application starts, another swing application is
executed from another place and is "stuck" on one of the
first swing functions (pack() of Window class). It remains in task
manager, doesn't throw any exception, resembles waiting in
turn for some resource.
The problem doesn't happen when the C++ code is executed from
command line and not from the Windows service.
It happens only on one computer.
The set of environment variables is same on working and non-working
computers.
There are 2 swing functions in the 1st applications that cause the
2nd appl-n to be stuck - UIManager.setLookAndFeel(...),
JFrame() - these I found to be a problem, but there are certainly
others.
OS is Windows 2000, java - 1.4.2_03
What resources are likely to be locked in this way?..
Michael Post - 13 Sep 2004 16:24 GMT
Hello Shenia,
why you don't use Threads?
> I have the following problem:
> One swing application is executed in the following way:
[quoted text clipped - 24 lines]
>
> What resources are likely to be locked in this way?..
Faithfully
Michael
xarax - 13 Sep 2004 19:04 GMT
Re-read the original post and you'll see it
has nothing to do with threads. Two separate
Java applications (JVM's) are running as
separate processes.
> Hello Shenia,
>
[quoted text clipped - 32 lines]
>
> Michael
dar7yl - 13 Sep 2004 19:45 GMT
>I have the following problem:
> One swing application is executed in the following way:
[quoted text clipped - 5 lines]
> executed from another place and is "stuck" on one of the
> first swing functions (pack() of Window class).
How is the swing application launched? If you are launching from MS
Exploder, it will share the VM with all windows launched from that browser
instance. Thus, only one VM is actually used. The applications share the
same event-processing-loop.
(That's one of my beefs with AWT/Swing, the single event loop)
> It remains in task
> manager, doesn't throw any exception, resembles waiting in
[quoted text clipped - 14 lines]
>
> What resources are likely to be locked in this way?..
Probably the registry, or the windows OS structures themselves. I don't
know how intensively Sun et al have investigated the possibility of race
conditions when multiple VM's operate at the same time.
regards,
Dar7yl
shenia_nim - 14 Sep 2004 14:01 GMT
The application is inside "Administrative tools" -> "services". If I
start service, it will run the batch file, which executes C++ exe.
This C++ code inside runs another batch file, which executes javaw
MyClass.class (GUI application).
The problem resides in Windows service - something's wrong inside
OS, because it happens only on one computer. It doesn't happen if I
run initially the 1st batch file from command line.
I'm sure formatting the computer will resolve the problem, but I
wanted to understand what it could be.
Yaniv D. - 14 Sep 2004 16:19 GMT
> I have the following problem:
> One swing application is executed in the following way:
[quoted text clipped - 24 lines]
>
> What resources are likely to be locked in this way?..
I experienced a similar problem. I have a java server application,
which I installed as a windows service using "java service wrapper".
The server is launched with no GUI, and in order to display its window
we execute a main class, "ShowServer", which resides in a different
jar file (and not a service). When I execute "showServer", nothing is
displayed. Debugging with eclipse shows that the freeze happens when
executing the function pack() of a JWindow object. Further
investigation shows that any java application that involves swing will
suffer the same phenomena as long as the server service is running. As
soon as I stop the service, the problem is resolved. I have to mention
that this phenomena only happens to me on win2k machines, and not on
winXP pro. I will also add that the service is installed as
"interactive". If anyone has a clue, please help. I am desperate...
Dieter Mach - 16 Sep 2004 07:27 GMT
Hi,
did you try to call pack() from a separate Thread? This could solve
the problem if it is related to the event dispatching thread. I
normally do something like this:
...
JFrame someFrame;
...
SwingUtilities.invokeLater(new Runnable() {
public void run() {
someFrame.pack();
someFrame.show();
}
});
...
The SwingUtilities class can be found somewhere at http://java.sun.com
Hope this helps
Dieter
shenia_nim - 19 Sep 2004 06:52 GMT
This is impossible, since the whole application is very big - more
than 700 classes. I can't wrap every problematic swing function like
you suggest...
Dieter Mach - 20 Sep 2004 08:40 GMT
> This is impossible, since the whole application is very big - more
> than 700 classes. I can't wrap every problematic swing function like
> you suggest...
I didn't suggest you to wrap every problematic swing function. Just the
creation of the GUI should be wrapped. A more detailed explanation can
be found here:
http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html
Yaniv D. - 26 Sep 2004 16:28 GMT
> > This is impossible, since the whole application is very big - more
> > than 700 classes. I can't wrap every problematic swing function like
[quoted text clipped - 5 lines]
>
> http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html
This issue has nothing to do with threads. The Windows service runs in
its own process, so does the java app it runs (I run the service with
"/detach" switch), and of course, so does every new java app I try to
use swing in. So we are talking about seperate processes here, not
threads.
Therefore, the solution has to come from a different approach. Any
thoughts?
shenia_nim - 29 Sep 2004 20:31 GMT
Yaniv, does it happen with your application on every computer?.. I
have a problem only on one of them, but there's always chance that it
happens somewhere else.
OH HAS NOONE HEARD OF SOME SOLUTION??? PLEASE!!!!!!!!