Java 无法启动 glassfish 服务器,因为无法锁定 /opt/glassfishv3/glassfish/domains/domain1/logs/server.log

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24447579/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 12:15:14  来源:igfitidea点击:

Failed to start glassfish server because Couldn't get lock for /opt/glassfishv3/glassfish/domains/domain1/logs/server.log

javaglassfish-3

提问by user3752888

admin@BRMSDEV:/opt/glassfishv3/glassfish/bin$ ./asadmin start-domain domain1
java.io.IOException: Couldn't get lock for /opt/glassfishv3/glassfish/domains/domain1/logs/server.log
at java.util.logging.FileHandler.openFiles(FileHandler.java:389)
at java.util.logging.FileHandler.<init>(FileHandler.java:287)
at com.sun.enterprise.admin.launcher.GFLauncherLogger.addLogFileHandler(GFLauncherLogger.java:85)
at com.sun.enterprise.admin.launcher.GFLauncher.setup(GFLauncher.java:148)
at com.sun.enterprise.admin.cli.StartDomainCommand.createLauncher(StartDomainCommand.java:239)
at com.sun.enterprise.admin.cli.StartDomainCommand.runCommandNotEmbedded(StartDomainCommand.java:122)
at com.sun.enterprise.admin.cli.StartDomainCommand.executeCommand(StartDomainCommand.java:117)
at com.sun.enterprise.admin.cli.CLICommand.execute(CLICommand.java:257)
at com.sun.enterprise.admin.cli.AsadminMain.executeCommand(AsadminMain.java:229)
at com.sun.enterprise.admin.cli.AsadminMain.main(AsadminMain.java:167)
Waiting for DAS to start .Error starting domain: domain1.
The server exited prematurely with exit code 0.

Before it died, it produced the following output:

在它死之前,它产生了以下输出:

   Warning:  Cannot open log file: /opt/glassfishv3/glassfish/domains/domain1/logs/jvm.log
admin@BRMSDEV:/opt/glassfishv3/glassfish/bin$ ./asadmin start-domain domain1
java.io.IOException: Couldn't get lock for /opt/glassfishv3/glassfish/domains/domain1/logs/server.log
at java.util.logging.FileHandler.openFiles(FileHandler.java:389)
at java.util.logging.FileHandler.<init>(FileHandler.java:287)
at com.sun.enterprise.admin.launcher.GFLauncherLogger.addLogFileHandler(GFLauncherLogger.java:85)
at com.sun.enterprise.admin.launcher.GFLauncher.setup(GFLauncher.java:148)
at com.sun.enterprise.admin.cli.StartDomainCommand.createLauncher(StartDomainCommand.java:239)
at com.sun.enterprise.admin.cli.StartDomainCommand.runCommandNotEmbedded(StartDomainCommand.java:122)
at com.sun.enterprise.admin.cli.StartDomainCommand.executeCommand(StartDomainCommand.java:117)
at com.sun.enterprise.admin.cli.CLICommand.execute(CLICommand.java:257)
at com.sun.enterprise.admin.cli.AsadminMain.executeCommand(AsadminMain.java:229)
at com.sun.enterprise.admin.cli.AsadminMain.main(AsadminMain.java:167)
Waiting for DAS to start .Error starting domain: domain1.
The server exited prematurely with exit code 0.

Before it died, it produced the following output:

在它死之前,它产生了以下输出:

Warning:  Cannot open log file: /opt/glassfishv3/glassfish/domains/domain1/logs/jvm.log
Warning:  Forcing option -XX:LogFile=/tmp/hs_pid2234.log
Jun 27, 2014 8:36:05 AM com.sun.enterprise.glassfish.bootstrap.ASMain main
INFO: Launching GlassFish on Felix platform
Jun 27, 2014 8:36:05 AM com.sun.enterprise.glassfish.bootstrap.ASMain main
SEVERE: the domain directory is not writable.
java.lang.RuntimeException: the domain directory is not writable.
at com.sun.enterprise.glassfish.bootstrap.ASMainHelper.verifyAndSetDomainRoot(ASMainHelper.java:233)
at com.sun.enterprise.glassfish.bootstrap.AbstractMain.run(AbstractMain.java:89)
at com.sun.enterprise.glassfish.bootstrap.ASMainOSGi.run(ASMainOSGi.java:71)
at com.sun.enterprise.glassfish.bootstrap.AbstractMain.start(AbstractMain.java:78)
at com.sun.enterprise.glassfish.bootstrap.ASMain.main(ASMain.java:82)
Command start-domain failed.

I just installed glassfish in my host machine and changed the domain.xml with my host ip and started the server through the following command

我刚刚在我的主机上安装了 glassfish 并用我的主机 ip 更改了 domain.xml 并通过以下命令启动了服务器

./asadmin start-domain domain1

./asadmin 起始域 domain1

I got the above exceptions ,I am new to glassfish please help me out how to over come this issue , Thanks in advance @dinesh

我遇到了上述例外情况,我是 glassfish 的新手,请帮助我解决这个问题,提前致谢 @dinesh

回答by Mario Werner

Looks like you don't have writing permissions to the folder /opt/glassfishv3/glassfish/domains/domain1/logs/ and / or file server.log ... and / or the folder / file doesn't exist.

看起来您没有对文件夹 /opt/glassfishv3/glassfish/domains/domain1/logs/ 和/或文件 server.log ... 和/或文件夹 / 文件不存在的写入权限。

Try sudoor change the folder's permission settings.

尝试sudo或更改文件夹的权限设置。

回答by Hakikat41

I had the same problem and changing the directory permissions solved that issue. Try this:

我遇到了同样的问题,更改目录权限解决了这个问题。尝试这个:

  1. sudo chmod -R 777 /opt/glassfishv3/glassfish/
  2. If you are using an ide like IntelliJ for example, you have to start the GlassFish Server inside the ide.
  1. sudo chmod -R 777 /opt/glassfishv3/glassfish/
  2. 例如,如果您使用像 IntelliJ 这样的 IDE,则必须在该 IDE 中启动 GlassFish Server。