0

我已经建立了一个 glassfish 服务器来学习它。根据快速入门指南进行设置和配置后,我能够毫无问题地运行服务器和 domain1。一段时间后,它开始记录以下行:

[#|2013-01-11T15:43:45.246+0800|WARNING|glassfish3.1.2|java.util.prefs|_ThreadID=105;_ThreadName=Thread-2;|Could not lock User prefs.  Unix error code 5.|#]

[#|2013-01-11T15:43:45.246+0800|WARNING|glassfish3.1.2|java.util.prefs|_ThreadID=105;_ThreadName=Thread-2;|Couldn't flush user prefs: java.util.prefs.BackingStoreException: Couldn't get file lock.|#]

我对此做了一些谷歌搜索,找到了这个链接并应用了那里推荐的选项。重新启动 glassfish 后,虽然服务器日志显示它已启动,但我在命令行中看到了这一点:

./asadmin start-domain domain1
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 lock bundle cache: java.io.IOException: Input/output error)
java.lang.Exception: Unable to lock bundle cache: java.io.IOException: Input/output error
at org.apache.felix.framework.cache.BundleCache.<init>(BundleCache.java:176)
at org.apache.felix.framework.Felix.init(Felix.java:629)
at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiFrameworkLauncher$1.run(OSGiFrameworkLauncher.java:88)
Exception in thread "Thread-1" java.lang.RuntimeException: org.osgi.framework.BundleException: Error creating bundle cache.
at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiFrameworkLauncher$1.run(OSGiFrameworkLauncher.java:90)
Caused by: org.osgi.framework.BundleException: Error creating bundle cache.
at org.apache.felix.framework.Felix.init(Felix.java:634)
at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiFrameworkLauncher$1.run(OSGiFrameworkLauncher.java:88)
Caused by: java.lang.Exception: Unable to lock bundle cache: java.io.IOException: Input/output error
at org.apache.felix.framework.cache.BundleCache.<init>(BundleCache.java:176)
at org.apache.felix.framework.Felix.init(Felix.java:629)
... 1 more
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.enterprise.glassfish.bootstrap.GlassFishMain.main(GlassFishMain.java:97)
at com.sun.enterprise.glassfish.bootstrap.ASMain.main(ASMain.java:55)
Caused by: org.glassfish.embeddable.GlassFishException: java.lang.NullPointerException
at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiGlassFishRuntimeBuilder.build(OSGiGlassFishRuntimeBuilder.java:164)
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.OSGiGlassFishRuntimeBuilder.newFramework(OSGiGlassFishRuntimeBuilder.java:230)
at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiGlassFishRuntimeBuilder.build(OSGiGlassFishRuntimeBuilder.java:133)
... 9 more
 Error stopping framework: java.lang.NullPointerException
 java.lang.NullPointerException
at com.sun.enterprise.glassfish.bootstrap.GlassFishMain$Launcher$1.run(GlassFishMain.java:203)

Command start-domain failed.

我试图找到解决方案,删除域目录中的缓存文件夹或更改访问权限,但问题不断出现,我无法启动我的域。

任何想法如何解决这个问题?

4

1 回答 1

0

安装 Glassfish 后,我遇到了与该堆栈中相同的 IO 错误,并发现以下内容:

Glassfish 3.1.2 使用 felix 库来处理 OSGI 的东西,而这个库想要使用核心 Java 方法 java.nio.channels.FileChannel.tryLock() 来锁定文件。当要锁定的文件位于某些类型的 NAS 上的文件系统上时,这似乎不起作用,并在长时间超时后导致 IO 错误。确保在本地磁盘上安装关键部分或全部 Glassfish,此错误将消失。

运行以下 Java 类可以很容易地重现该错误:

import java.io.File;
import java.io.FileOutputStream;
import java.nio.channels.FileChannel;

public class TryLock {

/**
 * @param args
 */
public static void main(String[] args) {
    // name of a file is the only parameter
    File lockFile = new File(args[0]);
    FileChannel fc = null;
    FileOutputStream fos = null;
    try {
        fos = new FileOutputStream(lockFile);
        fc = fos.getChannel();
        // This is the code that fails on some NAS (low-level operation?):
        fc.tryLock();
    } catch( Throwable th) {
        th.printStackTrace();
    }
    System.out.println("Success");
}
}
于 2013-04-17T13:08:12.060 回答