【发布时间】:2012-03-02 12:50:24
【问题描述】:
情况:开源 OSGI 框架 SMILA (http://www.eclipse.org/smila/) 在 Apache commons-daemon (http://commons.apache.org/daemon/) 的帮助下作为 Windows 服务启动.尝试从 OSGI 包中通过 System.loadLibrary() 加载 DLL,而 Manifest.mf 包括 Bundle-NativeCode: path/to/dll。
环境:Windows Server 2003、Java 1.6
错误:在调用System.loadLibrary() 期间,整个Java 进程挂起。当服务停止时System.loadLibrary() 完成并继续执行代码,直到 OSGI 框架关闭。
在 Windows Server 2008 上或 OSGI 框架未作为服务启动时不会发生该错误。
DLL 本身被剥离为没有用于测试的功能。所有导入都是静态的,唯一依赖的库是kernel32.ddl。
谁能想象为什么会发生这种情况以及如何解决它?
包含 DLL 的清单:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: NTFS Utils Acl Win32 Library
Bundle-SymbolicName: com.eccenca.utils.ntfs.acl.win32
Bundle-Version: 2.2.0
Bundle-Vendor: brox IT-Solutions GmbH
Fragment-Host: com.eccenca.utils.ntfs
Eclipse-PlatformFilter: (& (osgi.os=win32) (osgi.arch=x86))
Bundle-NativeCode: ntfsacl/Release/NtfsAcl.dll
Bundle-RequiredExecutionEnvironment: JavaSE-1.6+
清单包含代码:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: NTFS Utils Acl
Bundle-SymbolicName: com.eccenca.utils.ntfs
Bundle-Version: 2.2.0
Bundle-Vendor: brox IT-Solutions GmbH
Export-Package: com.eccenca.processing.acl,
com.eccenca.utils.ntfs
Import-Package: org.apache.commons.io;version="1.4.0",
org.apache.commons.lang,
org.apache.commons.logging;version="1.1.1",
org.eclipse.smila.blackboard;version="0.8.0",
org.eclipse.smila.datamodel,
org.eclipse.smila.processing;version="0.8.0",
org.eclipse.smila.processing.pipelets;version="0.8.0",
org.eclipse.smila.utils.config;version="0.8.0",
org.eclipse.smila.utils.service;version="0.8.0",
org.osgi.framework;version="1.4.0"
SMILA-Pipelets: com.eccenca.processing.acl.AccessListConverterPipelet
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
使用System.loadLibrary() 调用截断的代码:
public class ACLList {
private static final org.apache.commons.logging.Log LOG =
org.apache.commons.logging.LogFactory.getLog(ACLList.class);
static {
try {
LOG.debug("Start loading library");
System.loadLibrary("NtfsAcl");
if (LOG.isInfoEnabled()) {
LOG.info("NTFS ACL library was succesfully loaded");
}
} catch (Throwable e) {
LOG.error(e);
}
}
private ACLList() {
}
public static native ArrayList<ACLEntry> getAccessFor(String path,
String serverName) throws IOException;
}
【问题讨论】:
-
能否包含一些代码,以及更完整的捆绑清单?
-
当然。我只是编辑我的问题。谢谢。
-
也许
jstack可以展示一些有用的东西。
标签: java windows dll service osgi