Situation: Open source OSGI framework SMILA (http://www.eclipse.org/smila/) started as Windows Service with the aid of Apache commons-daemon (http://commons.apache.org/daemon/). Trying to load a DLL via System.loadLibrary() from OSGI bundle while Manifest.mf includes Bundle-NativeCode: path/to/dll.
Environment: Windows Server 2003, Java 1.6
Error: During the invocation of System.loadLibrary() the complete Java process hangs. When the service is stopped System.loadLibrary() finish and code execution goes on until the OSGI framework shut down.
The error doesn’t occur on Windows Server 2008 or if the OSGI framework isn’t started as service.
The DLL itself is stripped down to no functionality for testing. All imports are static and the only depended library is kernel32.ddl.
Could anyone imagine why this is happening and how to fix it?
Manifest containing 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 containing code:
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 Code snipped with System.loadLibrary() invocation:
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; }