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 239962
Collapse All | Expand All

(-)a/derby/src/org/netbeans/modules/derby/RegisterDerby.java (-2 / +84 lines)
Lines 52-73 Link Here
52
import java.util.Properties;
52
import java.util.Properties;
53
import java.util.logging.Level;
53
import java.util.logging.Level;
54
import java.util.logging.Logger;
54
import java.util.logging.Logger;
55
import java.util.prefs.Preferences;
56
import java.util.regex.Matcher;
57
import java.util.regex.Pattern;
58
import javax.swing.Icon;
55
import org.netbeans.api.db.explorer.ConnectionManager;
59
import org.netbeans.api.db.explorer.ConnectionManager;
56
import org.netbeans.api.db.explorer.DatabaseConnection;
60
import org.netbeans.api.db.explorer.DatabaseConnection;
57
import org.netbeans.api.db.explorer.JDBCDriver;
61
import org.netbeans.api.db.explorer.JDBCDriver;
58
import org.netbeans.api.db.explorer.JDBCDriverManager;
62
import org.netbeans.api.db.explorer.JDBCDriverManager;
59
import org.netbeans.api.progress.ProgressHandle;
63
import org.netbeans.api.progress.ProgressHandle;
60
import org.netbeans.api.progress.ProgressHandleFactory;
64
import org.netbeans.api.progress.ProgressHandleFactory;
61
import org.netbeans.api.progress.ProgressUtils;
62
import org.netbeans.modules.derby.api.DerbyDatabases;
65
import org.netbeans.modules.derby.api.DerbyDatabases;
63
import org.netbeans.spi.db.explorer.DatabaseRuntime;
66
import org.netbeans.spi.db.explorer.DatabaseRuntime;
64
import org.openide.DialogDisplayer;
67
import org.openide.DialogDisplayer;
65
import org.openide.NotifyDescriptor;
68
import org.openide.NotifyDescriptor;
69
import org.openide.awt.NotificationDisplayer;
66
import org.openide.execution.NbProcessDescriptor;
70
import org.openide.execution.NbProcessDescriptor;
67
import org.openide.filesystems.FileObject;
71
import org.openide.filesystems.FileObject;
68
import org.openide.filesystems.FileUtil;
72
import org.openide.filesystems.FileUtil;
69
import org.openide.util.Cancellable;
73
import org.openide.util.Cancellable;
74
import org.openide.util.ImageUtilities;
70
import org.openide.util.NbBundle;
75
import org.openide.util.NbBundle;
76
import org.openide.util.NbPreferences;
71
import org.openide.util.RequestProcessor;
77
import org.openide.util.RequestProcessor;
72
import org.openide.util.Utilities;
78
import org.openide.util.Utilities;
73
import org.openide.windows.InputOutput;
79
import org.openide.windows.InputOutput;
Lines 86-91 Link Here
86
    
92
    
87
    private static final Logger LOGGER = Logger.getLogger(RegisterDerby.class.getName());
93
    private static final Logger LOGGER = Logger.getLogger(RegisterDerby.class.getName());
88
    private static final boolean LOG = LOGGER.isLoggable(Level.FINE);
94
    private static final boolean LOG = LOGGER.isLoggable(Level.FINE);
95
    private static final Pattern JAVA_VERSION_PATTERN = Pattern.compile(
96
            "(\\d+)\\.(\\d+)\\.\\d+(?:(?:-.*)|(?:_(\\d+)))?");          //NOI18N
97
    private static final String DISABLED_SECURITY_MNGR_NOTIFIED
98
            = "disabledSecurityManagerNotified";                        //NOI18N
89
    
99
    
90
    private static final int START_TIMEOUT = 0; // seconds
100
    private static final int START_TIMEOUT = 0; // seconds
91
    
101
    
Lines 299-305 Link Here
299
              java,
309
              java,
300
              "-Dderby.system.home=\"" + getDerbySystemHome() + "\" " +
310
              "-Dderby.system.home=\"" + getDerbySystemHome() + "\" " +
301
              "-classpath \"" + getNetworkServerClasspath() + "\"" + 
311
              "-classpath \"" + getNetworkServerClasspath() + "\"" + 
302
              " org.apache.derby.drda.NetworkServerControl start"
312
              " org.apache.derby.drda.NetworkServerControl start" + jdkParams()
303
            );
313
            );
304
            if (LOG) {
314
            if (LOG) {
305
                LOGGER.log(Level.FINE, "Running " + desc.getProcessName() + " " + desc.getArguments());
315
                LOGGER.log(Level.FINE, "Running " + desc.getProcessName() + " " + desc.getArguments());
Lines 332-337 Link Here
332
        }
342
        }
333
    }
343
    }
334
    
344
    
345
    /**
346
     * Check whether some non-standard arguments are needed to start JavaDB. If
347
     * so, a warning notification may be displayed to the user. Ugly workaround
348
     * for bug 239962.
349
     *
350
     * @return String containing non-standard JDK params. Prefixed by a space
351
     * character if not emtpy.
352
     */
353
    @NbBundle.Messages({
354
        "TTL_NoSecurity=JavaDB - Security Manager Disabled",
355
        "LBL_NoSecurity=JavaDB will be started with disabled security manager"
356
                + " (i.e. with argument -noSecurityManager). Please ensure"
357
                + " this cannot cause any security risks, and if so, start the"
358
                + " JavaDB manually."
359
    })
360
    private String jdkParams() {
361
362
        if (isDisablingOfSecurityManagerNeeded()) {
363
            Preferences prefs = NbPreferences.forModule(RegisterDerby.class);
364
            if (!prefs.getBoolean(DISABLED_SECURITY_MNGR_NOTIFIED, false)) {
365
                NotificationDisplayer.getDefault().notify(
366
                        Bundle.TTL_NoSecurity(),
367
                        getDbIcon(), Bundle.LBL_NoSecurity(), null,
368
                        NotificationDisplayer.Priority.HIGH);
369
                prefs.putBoolean(DISABLED_SECURITY_MNGR_NOTIFIED, true);
370
            }
371
            return " -noSecurityManager";                               //NOI18N
372
        } else {
373
            return "";                                                  //NOI18N
374
        }
375
    }
376
377
    private Icon getDbIcon() {
378
        return ImageUtilities.loadImageIcon(
379
                "org/netbeans/modules/derby/resources/database.gif", //NOI18N
380
                false);
381
    }
382
383
    /**
384
     * JavaDB needs to be started with parameter "-noSecurityManager" on jdk
385
     * 7u51 or newer or jdk8.
386
     */
387
    private boolean isDisablingOfSecurityManagerNeeded() {
388
        // 1.8.0-ea+
389
        // 1.7.0_51+
390
        String version = System.getProperty("java.version");            //NOI18N
391
        Matcher m = JAVA_VERSION_PATTERN.matcher(version);
392
        try {
393
            if (m.matches()) {
394
                int major = Integer.parseInt(m.group(1));
395
                int minor = Integer.parseInt(m.group(2));
396
                if (major == 1 && minor >= 8) {
397
                    return true;
398
                }
399
                String updateStr = m.group(3);
400
                if (updateStr != null && !updateStr.isEmpty()) {
401
                    int update = Integer.parseInt(updateStr);
402
                    if (major == 1 && minor == 7 && update >= 51) {
403
                        return true;
404
                    }
405
                }
406
            } else {
407
                LOGGER.log(Level.FINE, "Cannot parse java version {0}", //NOI18N
408
                        version);
409
            }
410
        } catch (NumberFormatException ex) {
411
            LOGGER.log(Level.FINE, null, ex);
412
            return false;
413
        }
414
        return false;
415
    }
416
335
    private boolean waitStart(final ExecSupport execSupport, int waitTime) {
417
    private boolean waitStart(final ExecSupport execSupport, int waitTime) {
336
        boolean started = false;
418
        boolean started = false;
337
        String waitMessage = NbBundle.getMessage(RegisterDerby.class, "MSG_StartingDerby");
419
        String waitMessage = NbBundle.getMessage(RegisterDerby.class, "MSG_StartingDerby");

Return to bug 239962