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.

View | Details | Raw Unified | Return to bug 199655
Collapse All | Expand All

(-)a/glassfish.javaee/src/org/netbeans/modules/glassfish/javaee/Hk2StartServer.java (-24 / +15 lines)
Lines 445-482 Link Here
445
445
446
                @Override
446
                @Override
447
                public void operationStateChanged(OperationState newState, String message) {
447
                public void operationStateChanged(OperationState newState, String message) {
448
                    if (OperationState.COMPLETED.equals(newState)) {
448
                    if (newState == OperationState.RUNNING) {
449
                        // Make sure the server really is ready before we
449
                        // wait for the profiler agent to initialize
450
                        // advertise that it is ready
450
                        int t = 0;
451
                        Logger.getLogger("glassfish-javaee").log(Level.FINE,"t == {0}", t); // NOI18N
452
453
                        // Leave as soon as the profiler reaches state STATE_BLOCKING - 
454
                        //   we need the ant execution thread to for the profiler client;
455
                        // Note: It does not make sense to wait for STATE_RUNNING or STATE_PROFILING
456
                        //       as the profiler won't reach them unless the client is connected
451
                        try {
457
                        try {
452
                            int t = 0;
458
                            while (!(ProfilerSupport.getState() == ProfilerSupport.STATE_BLOCKING)
453
                            Logger.getLogger("glassfish-javaee").log(Level.FINE,"t == {0}", t); // NOI18N
459
                                    && t < 30000) {
454
455
                            // Wait for the profiler to start completely...
456
                            while (!(ProfilerSupport.getState() == ProfilerSupport.STATE_PROFILING) &&
457
                                    t < 30000) {
458
                                Thread.sleep(1000);
460
                                Thread.sleep(1000);
459
                                t += 1000;
461
                                t += 1000;
460
                                Logger.getLogger("glassfish-javaee").log(Level.FINE,"t.1 == {0}", t);  // NOI18N
462
                                Logger.getLogger("glassfish-javaee").log(Level.FINE, "t.1 == {0}", t);  // NOI18N
461
                            }
463
                            }
462
463
                            int port = Integer.parseInt(ip.getProperty(GlassfishModule.ADMINPORT_ATTR));
464
                            // Wait for the admin port to be 'running'
465
                            while (//!Hk2PluginProperties.isRunning(ip.getProperty(GlassfishModule.HOSTNAME_ATTR),
466
                                   // ip.getProperty(GlassfishModule.ADMINPORT_ATTR)) &&
467
                                    !org.netbeans.modules.glassfish.spi.Utils.isLocalPortOccupied(port) &&
468
                                    t < 60000) {
469
                                Thread.sleep(1000);
470
                                t += 1000;
471
                                Logger.getLogger("glassfish-javaee").log(Level.FINE,"t.2 == {0}", t);  // NOI18N
472
                            }
473
                            Logger.getLogger("glassfish-javaee").log(Level.FINE, "t.3 == {0}", t);  // NOI18N
474
                        } catch (InterruptedException ex) {
464
                        } catch (InterruptedException ex) {
465
                            Thread.currentThread().interrupt();
475
                        }
466
                        }
476
                    }
467
                    }
477
                    fireHandleProgressEvent(null, new Hk2DeploymentStatus(
468
                    fireHandleProgressEvent(null, new Hk2DeploymentStatus(
478
                            CommandType.START, translateState(newState), ActionType.EXECUTE,
469
                        CommandType.START, translateState(newState), ActionType.EXECUTE,
479
                            message));
470
                        message));
480
                }
471
                }
481
            }, jdkRoot, settings.getJvmArgs());
472
            }, jdkRoot, settings.getJvmArgs());
482
        }
473
        }
(-)a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/TargetServer.java (+26 lines)
Lines 514-520 Link Here
514
                }
514
                }
515
                case PROFILE: {
515
                case PROFILE: {
516
                    ProfilerServerSettings settings = Lookup.getDefault().lookup(Profiler.class).getSettings(instance.getUrl(), false);
516
                    ProfilerServerSettings settings = Lookup.getDefault().lookup(Profiler.class).getSettings(instance.getUrl(), false);
517
                    
518
                    final Object monitor = new Object();
519
                    ServerInstance.StateListener sl = new ServerInstance.StateListener() {
520
                        @Override
521
                        public void stateChanged(int oldState, int newState) {
522
                            switch (newState) {
523
                                case ServerInstance.STATE_STOPPED: 
524
                                case ServerInstance.STATE_PROFILING: {
525
                                    synchronized(monitor) {
526
                                        monitor.notifyAll();
527
                                    }
528
                                    break;
529
                                }
530
                            }
531
                        }
532
                    };
533
                    instance.addStateListener(sl);
517
                    instance.startProfile(settings, false, ui);
534
                    instance.startProfile(settings, false, ui);
535
                    // need to wait for profiler to load the agent etc.
536
                    synchronized(monitor) {
537
                        try {
538
                            monitor.wait(60000); // 60 seconds timeout; instrumentation may slow down the startup significantly
539
                        } catch (InterruptedException e) {
540
                            Thread.currentThread().interrupt();
541
                        }
542
                    }
543
                    instance.removeStateListener(sl);
518
                    break;
544
                    break;
519
                }
545
                }
520
                case RUN: {
546
                case RUN: {

Return to bug 199655