在Windows 2008上从JNI加载DLL时出错

时间:2012-06-27 08:54:02

标签: java c++ java-native-interface

我们有一个java程序,它依赖于通过JNI的C ++代码。我们有.so和.dll用于放置在java程序的类路径中的solaris和C ++代码的窗口。 同样在Windows上我们生成了java.exe.manifest,以强制windows使用MSVC RTL。这在solaris,windows 2003中运行良好,但在Windows 2008上,我收到错误消息 '并排组装配置是错误的'

这是java.exe.manifest

<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type='win32' name='Microsoft.VC80.CRT' version='8.0.50727.762' processorArchitecture='amd64' publicKeyToken='1fc8b3b9a1e18e3b' />
    </dependentAssembly>
  </dependency>
</assembly>

此外,我尝试通过sxstrace调试问题,这是它的日志

=================
Begin Activation Context Generation.
Input Parameter:
    Flags = 0
    ProcessorArchitecture = AMD64
    CultureFallBacks = en-US;en
    ManifestPath = D:\JDA\TRO\bin\OptCoreBodies.dll
    AssemblyDirectory = D:\JDA\TRO\bin\
    Application Config File = 
-----------------
INFO: Parsing Manifest File D:\JDA\TRO\bin\OptCoreBodies.dll.
    INFO: Manifest Definition Identity is (null).
    INFO: Reference: Microsoft.VC80.CRT,processorArchitecture="amd64",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50608.0"
    INFO: Reference: Microsoft.VC80.CRT,processorArchitecture="amd64",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.4053"
INFO: Resolving reference Microsoft.VC80.CRT,processorArchitecture="amd64",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50608.0".
    INFO: Resolving reference for ProcessorArchitecture amd64.
        INFO: Resolving reference for culture Neutral.
            INFO: Applying Binding Policy.
                INFO: Find publisher policy at C:\Windows\WinSxS\manifests\amd64_policy.8.0.microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.3053_none_09c0f5a3facc9779.manifest
                INFO: Publisher Policy redirected assembly version.
                INFO: Post policy assembly identity is Microsoft.VC80.CRT,processorArchitecture="amd64",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.3053".
            INFO: Begin assembly probing.
                INFO: Attempt to probe manifest at C:\Windows\WinSxS\manifests\amd64_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.3053_none_88e044e32fae7230.manifest.
                INFO: Manifest found at C:\Windows\WinSxS\manifests\amd64_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.3053_none_88e044e32fae7230.manifest.
            INFO: End assembly probing.
INFO: Resolving reference Microsoft.VC80.CRT.mui,language="&#x2a;",processorArchitecture="amd64",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.3053".
    INFO: Resolving reference for ProcessorArchitecture amd64.
        INFO: Resolving reference for culture en-US.
            INFO: Applying Binding Policy.
                INFO: No publisher policy found.
                INFO: No binding policy redirect found.
            INFO: Begin assembly probing.
                INFO: Did not find the assembly in WinSxS.
                INFO: Attempt to probe manifest at C:\Windows\assembly\GAC_64\Microsoft.VC80.CRT.mui\8.0.50727.3053_en-US_1fc8b3b9a1e18e3b\Microsoft.VC80.CRT.mui.DLL.
                INFO: Did not find manifest for culture en-US.
            INFO: End assembly probing.
        INFO: Resolving reference for culture en.
            INFO: Applying Binding Policy.
                INFO: No publisher policy found.
                INFO: No binding policy redirect found.
            INFO: Begin assembly probing.
                INFO: Did not find the assembly in WinSxS.
                INFO: Attempt to probe manifest at C:\Windows\assembly\GAC_64\Microsoft.VC80.CRT.mui\8.0.50727.3053_en_1fc8b3b9a1e18e3b\Microsoft.VC80.CRT.mui.DLL.
                INFO: Did not find manifest for culture en.
            INFO: End assembly probing.
INFO: Resolving reference Microsoft.VC80.CRT,processorArchitecture="amd64",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.4053".
    INFO: Resolving reference for ProcessorArchitecture amd64.
        INFO: Resolving reference for culture Neutral.
            INFO: Applying Binding Policy.
                INFO: No binding policy redirect found.
            INFO: Begin assembly probing.
                INFO: Did not find the assembly in WinSxS.
                INFO: Attempt to probe manifest at C:\Windows\assembly\GAC_64\Microsoft.VC80.CRT\8.0.50727.4053__1fc8b3b9a1e18e3b\Microsoft.VC80.CRT.DLL.
                INFO: Attempt to probe manifest at D:\JDA\TRO\bin\Microsoft.VC80.CRT.DLL.
                INFO: Attempt to probe manifest at D:\JDA\TRO\bin\Microsoft.VC80.CRT.MANIFEST.
                INFO: Attempt to probe manifest at D:\JDA\TRO\bin\Microsoft.VC80.CRT\Microsoft.VC80.CRT.DLL.
                INFO: Attempt to probe manifest at D:\JDA\TRO\bin\Microsoft.VC80.CRT\Microsoft.VC80.CRT.MANIFEST.
                INFO: Did not find manifest for culture Neutral.
            INFO: End assembly probing.
    ERROR: Cannot resolve reference Microsoft.VC80.CRT,processorArchitecture="amd64",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.4053".
ERROR: Activation Context generation failed.
End Activation Context Generation.

任何人都可以帮我解决这个问题。我尝试安装MS VS 2005 Redistributable但没有用。

先谢谢 Niraj Rathi

3 个答案:

答案 0 :(得分:1)

使用version ='8.0.50727.762'编译的CRT版本以及您正在执行的系统没有此CRT版本。所以@panickal提到安装MS VS 2005 Redistributable Package应解决问题。

答案 1 :(得分:1)

我终于解决了这个问题。我重新安装了操作系统,然后安装了Visual C ++ 2005 Redistributables(x64)SP1。然后安装Java 64位。然后添加HKEY_LOCAL_MACHINE \ COMPONENTS \ PreferExternalManifest注册表并将其设置为1.

该问题得到解决后。

由于 Niraj Rathi

答案 2 :(得分:0)