You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

RCP应用添加JNA遇Bundle-NativeCode匹配异常求助

Fixing org.osgi.framework.BundleException: No Bundle-NativeCode match for JNA 4.5.1 in RCP Apps

Hey there! I’ve wrestled with this exact JNA + RCP OSGi issue before, so let’s break down how to get past that frustrating No Bundle-NativeCode match error:

1. Double-Check Your Bundle-NativeCode Manifest Entries

OSGi is extremely picky about native code path and attribute matching. For JNA 4.5.1, your MANIFEST.MF entries should mirror the exact structure inside the JNA JARs. For Windows, it should look something like this:

Bundle-NativeCode: lib/native/win32-x86/jnidispatch.dll; osname=Win32; processor=x86,
lib/native/win32-x86-64/jnidispatch.dll; osname=Win32; processor=x86-64

  • Verify the path matches exactly what’s in your jna-4.5.1.jar (case-sensitive, even on Windows!)
  • Don’t miss the commas at the end of each line except the last one
  • Ensure osname and processor values align with your target system (e.g., Win32 for all Windows versions, x86-64 for 64-bit)

2. Confirm OSGi System Properties Are Correct

Your OSGi runtime needs to report the right OS and architecture to match the native code entries. In your RCP run configuration, add these VM arguments (adjust for 32-bit if needed):

-Dosgi.os=win32 -Dosgi.arch=x86_64

If you’re setting these via a config file, make sure there are no typos—even a missing underscore will break the match.

3. Use OSGi-Ready JNA Bundles (Don’t Roll Your Own)

Manual JAR-to-bundle conversions often botch the native code configuration. Instead, pull the official OSGi-compatible JNA artifacts:

  • net.java.dev.jna:jna:4.5.1
  • net.java.dev.jna:jna-platform:4.5.1
    These come pre-configured with the correct Bundle-NativeCode entries, so you won’t have to tweak the manifest manually.

4. Ensure JNA Bundles Are Properly Started

In your Eclipse Run Configurations > Bundles tab:

  • Locate jna and jna-platform bundles
  • Check their boxes to ensure they’re included in the runtime
  • Set their start level to a value that loads them before your application code (e.g., level 4, same as most third-party bundles)

5. Clean and Rebuild Your Workspace

Old cached build files or manifest data can cause false matching errors. Do a full clean:

  1. Go to Project > Clean in Eclipse
  2. Select your RCP project and click OK
  3. Rebuild the project and re-run your RCP application

6. Enable OSGi Debug Logging for Native Code

If you’re still stuck, enable debug logging to see exactly why the match is failing. Add this VM argument:

-Dosgi.debug=debug.options

Then create a debug.options file with this line:

org.osgi.framework/nativecode = debug

The logs will show you which OS/architecture values the runtime is using, and which native code entries it’s checking—this will point straight to the mismatch.

内容的提问来源于stack exchange,提问作者nahzor

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 08:05:53