Search code examples
windowscmdstartuppromptglassfish-4

Starting Glassfish4 on Windows cmd Null Pointer Exp


I checked the site but could not find the solution. I tried "asadmin start-domain" asadmin start-domain domain1" and I edited asenv file in conf folder AS_JAVA as JAVA_HOME (I said this because some people may suggest this too) but I could not start the domain.

It was working when I just installed glassfish 4 and it started automatically. I stopped it with "asadmin stop-domain" and now it is not working.

my cmd commmand and result is following:

C:\Program Files\Java\glassfish4\glassfish\bin>asadmin start-domain domain1
java.nio.file.AccessDeniedException: C:\Program Files\Java\glassfish4\glassfish\
domains\domain1\logs\server.log.lck
        at sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
        at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
        at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
        at sun.nio.fs.WindowsFileSystemProvider.newFileChannel(Unknown Source)
        at java.nio.channels.FileChannel.open(Unknown Source)
        at java.nio.channels.FileChannel.open(Unknown Source)
        at java.util.logging.FileHandler.openFiles(Unknown Source)
        at java.util.logging.FileHandler.<init>(Unknown Source)
        at com.sun.enterprise.admin.launcher.GFLauncherLogger.addLogFileHandler(
GFLauncherLogger.java:98)
        at com.sun.enterprise.admin.launcher.GFLauncher.setup(GFLauncher.java:19
1)
        at com.sun.enterprise.admin.servermgmt.cli.StartDomainCommand.createLaun
cher(StartDomainCommand.java:220)
        at com.sun.enterprise.admin.servermgmt.cli.StartDomainCommand.executeCom
mand(StartDomainCommand.java:117)
        at com.sun.enterprise.admin.cli.CLICommand.execute(CLICommand.java:321)
        at com.sun.enterprise.admin.cli.AdminMain.executeCommand(AdminMain.java:
360)
        at com.sun.enterprise.admin.cli.AdminMain.doMain(AdminMain.java:298)
        at org.glassfish.admin.cli.AsadminMain.main(AsadminMain.java:56)
Waiting for domain1 to start .Error starting domain domain1.
The server exited prematurely with exit code 1.
Before it died, it produced the following output:

Launching GlassFish on Felix platform
ERROR: Error creating bundle cache. (java.lang.Exception: Unable to create bundl
e cache lock file: java.io.FileNotFoundException: C:\Program Files\Java\glassfis
h4\glassfish\domains\domain1\osgi-cache\felix\cache.lock (Erişim engellendi))
java.lang.Exception: Unable to create bundle cache lock file: java.io.FileNotFou
ndException: C:\Program Files\Java\glassfish4\glassfish\domains\domain1\osgi-cac
he\felix\cache.lock (Erişim engellendi)
        at org.apache.felix.framework.cache.BundleCache.<init>(BundleCache.java:
168)
        at org.apache.felix.framework.Felix.init(Felix.java:640)
        at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiFrameworkLauncher$1.r
un(OSGiFrameworkLauncher.java:88)
Exception in thread "Thread-1" java.lang.RuntimeException: org.osgi.framework.Bu
ndleException: Error creating bundle cache.
        at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiFrameworkLauncher$1.r
un(OSGiFrameworkLauncher.java:90)
Caused by: org.osgi.framework.BundleException: Error creating bundle cache.
        at org.apache.felix.framework.Felix.init(Felix.java:645)
        at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiFrameworkLauncher$1.r
un(OSGiFrameworkLauncher.java:88)
Caused by: java.lang.Exception: Unable to create bundle cache lock file: java.io
.FileNotFoundException: C:\Program Files\Java\glassfish4\glassfish\domains\domai
n1\osgi-cache\felix\cache.lock (Erişim engellendi)
        at org.apache.felix.framework.cache.BundleCache.<init>(BundleCache.java:
168)
        at org.apache.felix.framework.Felix.init(Felix.java:640)
        ... 1 more
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at com.sun.enterprise.glassfish.bootstrap.GlassFishMain.main(GlassFishMa
in.java:97)
        at com.sun.enterprise.glassfish.bootstrap.ASMain.main(ASMain.java:54)
Caused by: org.glassfish.embeddable.GlassFishException: java.lang.NullPointerExc
eption
        at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiGlassFishRuntimeBuild
er.build(OSGiGlassFishRuntimeBuilder.java:170)
        at org.glassfish.embeddable.GlassFishRuntime._bootstrap(GlassFishRuntime
.java:157)
        at org.glassfish.embeddable.GlassFishRuntime.bootstrap(GlassFishRuntime.
java:110)
        at com.sun.enterprise.glassfish.bootstrap.GlassFishMain$Launcher.launch(
GlassFishMain.java:112)
        ... 6 more
Caused by: java.lang.NullPointerException
        at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiGlassFishRuntimeBuild
er.newFramework(OSGiGlassFishRuntimeBuilder.java:241)
        at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiGlassFishRuntimeBuild
er.build(OSGiGlassFishRuntimeBuilder.java:135)
        ... 9 more
Error stopping framework: java.lang.NullPointerException
java.lang.NullPointerException
        at com.sun.enterprise.glassfish.bootstrap.GlassFishMain$Launcher$1.run(G
lassFishMain.java:203)

Command start-domain failed.

C:\Program Files\Java\glassfish4\glassfish\bin>

Solution

  • You have to open a command line as administrator to solve this problem. You should get the next:

    C:\Program Files\Java\java_ee_sdk-7u1\glassfish4\glassfish\bin>asadmin start-domain
    Waiting for domain1 to start .............
    Successfully started the domain : domain1
    domain  Location: C:\Program Files\Java\java_ee_sdk-7u1\glassfish4\glassfish\domains\domain1
    Log File: C:\Program Files\Java\java_ee_sdk-7u1\glassfish4\glassfish\domains\domain1\logs\server.log
    Admin Port: 4848
    Command start-domain executed successfully.
    

    C:\Program Files\Java\java_ee_sdk-7u1\glassfish4\glassfish\bin>

    Cheers