This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 141069 - "The application is already running with the test user directory"
Summary: "The application is already running with the test user directory"
Status: RESOLVED FIXED
Alias: None
Product: apisupport
Classification: Unclassified
Component: Project (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Jesse Glick
URL:
Keywords:
: 145397 (view as bug list)
Depends on: 145324 207530
Blocks: 63652
  Show dependency tree
 
Reported: 2008-07-21 21:11 UTC by Torbjorn Norbye
Modified: 2018-01-18 13:57 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Torbjorn Norbye 2008-07-21 21:11:05 UTC
Recently, I'm getting this exception a lot - I'd say 50% of the time when I'm trying to run my IDE project:

  "The application is already running with the test user directory.
   You must shut it down before trying to run it again."

I've looked and there's still a lock file left in the user directory, even though I cleanly exited the IDE last time.

I'm not sure where the bug is here - if during debugging it's not properly shutting down the IDE, or if there's a race
condition in the code which is cleaning up the lock or what. I hope this is the right category for this.
Comment 1 Jesse Glick 2008-07-21 21:45:40 UTC
$userdir/lock ought to be deleted whenever the platform is shut down (except by kill -9 or similar).
Comment 2 Jaroslav Tulach 2008-07-22 08:38:13 UTC
Jesse, it should, but it sometimes is not. For example if you kill debugee, it is not cleaned.

I've run into this problem as well. Imho the "exception" is in fact a dialog shown somewhere from apisupport module. 
It is really annoying and it would benefit from few fixes: 
1. it could have a button "Run Anyway"
2. it could detect that the lock file is "dead" and there is no server behind it by calling into CLIHandler

Anyway I see this as a bug in apisupport not core.
Comment 3 Jesse Glick 2008-07-22 21:22:23 UTC
Tor says the IDE was exited cleanly - if the lock is left in the userdir anyway, that is definitely a core bug. That
said, both your suggestions #1 and #2 make sense. The former would be easy to implement, the latter a little more work
(especially as we do not want to block the UI waiting for the target platform to respond).
Comment 4 Jesse Glick 2008-07-29 23:12:08 UTC
Would suggest doing at least #1 for 6.5; should be simple.
Comment 5 rmichalsky 2008-08-05 17:10:29 UTC
Wouldn't be for #1 enough just not to check the lock in testuserdir and let NB application display usual warning (which
already has an option to continue regardless of the lock)? The wording is not so clear, it doesn't specifically say that
the lock is in testuserdir, but IMO suffices.
Comment 6 Jesse Glick 2008-08-06 03:13:25 UTC
If the tested app already shows a dialog which lets you either continue (blowing away the lock) or cancel, then I guess
that should suffice. I guess you mean to just delete

                if (project.getTestUserDirLockFile().isFile()) {
                    notifyCannotReRun();
                    return;
                }

and the associated method and bundle keys from ModuleActions.invokeAction?
Comment 7 rmichalsky 2008-08-06 11:49:28 UTC
Exactly. The warning reads: 

"An instance of the program seems to be already running with your user directory. Either a previous session of the
program did not exit correctly, or another instance of the program is running on a different computer and using the same
user directory.
If another session of the program is running with the same user director, please click Cancel to prevent the corruption
of the user directory. If you are sure that no other instances of the program are running with your user directory,
click OK to continue. - OK / Cancel"

which seems ok to me.
Comment 8 Jesse Glick 2008-08-06 14:07:29 UTC
The proposed reversion of a89f924f468e would regress issue #63652 - if the platform is running _and responding to
requests_ then trying to run it again will silently do nothing. The check for the lock file really needs to happen in
apisupport, with the option of deleting a stale lock.

As Yarda said, it would be best to check if the platform is live, but this gets more complicated. I really don't want
apisupport duplicating the complex code in CLIHandler. Ideally there would be some CLI option --ping which would exit 0
if the platform was live and exit 1 if not, but this would not work on older platforms. The best I can come up with
right now: if $userdir/lock exists, then run the app as you normally would, but append "--bogus" to the command line. If
the app is not really running (or frozen and unable to respond), after a delay the lock will be overwritten and a new
instance of the app will start up normally. If the app is responding, the command will quickly return with exit status
170 (invalid CLI option), which the harness (run.xml) can detect, and halt the build with an error message in the Output
Window asking you to shut down the old platform instance before trying to start it anew.
Comment 9 rmichalsky 2008-08-06 14:22:14 UTC
Mhmmm, just observed similar behavior as you describe for #63652, but somehow more random - even when platform is not
running, it sometimes rewrites the lock and continues and sometimes ends silently. Cannot find reproducible steps so far.
I'll try your approach.
Comment 10 rmichalsky 2008-08-27 16:21:51 UTC
The approach with --bogus option works, thanks for the tip. There is last glitch on Windows, NB launchers silently
swallow the exit code. Filing separate issue, once it is resolved, I can finish this one.
Comment 11 rmichalsky 2008-08-29 11:28:57 UTC
*** Issue 145397 has been marked as a duplicate of this issue. ***
Comment 12 aldobrucale 2008-09-15 18:08:39 UTC
In the current 6.5 dev builds (I am using 200809141401) the lock file is _never_ deleted when the session is terminated
via the "Finish debugger session".
Comment 13 Jesse Glick 2008-09-16 02:35:01 UTC
Right, "Finish Debugger Session" kills the VM immediately and does not give it a chance to clean up the lock.

Issue #145324 is fixed so this could be resolved for NB 6.5, no?
Comment 14 rmichalsky 2008-09-16 13:44:29 UTC
fixed in core-main #f4b694e61658
Comment 15 Quality Engineering 2008-09-17 05:59:48 UTC
Integrated into 'main-golden', will be available in build *200809170201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/f4b694e61658
User: Richard Michalsky <rmichalsky@netbeans.org>
Log: #141069: Checks for running platform when userdir lock is present. When platform is running, run or debug
targets fail instructing the user to shut the running instance down. Otherwise rewrites the lock silently.
Comment 16 Quality Engineering 2008-09-20 05:36:18 UTC
Integrated into 'main-golden', will be available in build *200809200201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/875cdbd31cfb
User: Richard Michalsky <rmichalsky@netbeans.org>
Log: #141069: fixing mishandled merge (change os -> osfamily was lost)
Comment 17 Quality Engineering 2009-02-22 07:56:04 UTC
Integrated into 'main-golden', will be available in build *200902220201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/86fdaf5bf991
User: Richard Michalsky <rmichalsky@netbeans.org>
Log: #141069: fixed also for platform apps
Comment 18 westrick85 2009-10-02 16:05:37 UTC
The fix should append "--test-userdir-lock-with-invalid-arg" to run.args.extra rather than replacing the current value
of run.args.extra.

I have set several options in run.args.extra like increasing the maximum heap size. If my application terminates
abnormally from a crash or by using the Finish Debugging Session, these settings aren't applied in the next run or debug
session because of this fix. They get overwritten with "--test-userdir-lock-with-invalid-arg" and my program behaves
badly because the heap size can't grow large enough. 
Comment 19 Jesse Glick 2010-03-11 15:36:54 UTC
westrick85: see bug #168126.
Comment 20 levimatheri 2018-01-18 13:57:53 UTC
Just open task manager and look for runnning netbeans and hit end task