objectbox / objectbox/objectbox-java
LinkageError when two programs use ObjectBox and share the same .dll.
还没有人认领这个 Issue。
- 主要语言
- Java
- 星标
- 4.6k
- 派生
- 311
- PR 合并指标
- 30 天内没有已合并 PR
描述
Describe the bug
A Java program will not work if another Java program uses ObjectBox.
Basic info:
- ObjectBox version: 3.2.1
- Reproducibility: always
- Device: Desktop Java
- OS: Windows 10, Windows 11 & Linux
To Reproduce
See the Is there anything special about your app?.
Probable way to reproduce the behaviour without using Spigot plugins:
- Create two projects that use ObjectBox and place them in the same folder.
- Execute each application
- See error
Way to reproduce the behaviour USING Spigot plugins:
- Create two Spigot plugins that use ObjectBox.
- Place the plugins under the
\pluginsfolder. - Start the server & see the error for one plugin.
Expected behavior
ObjectBox should be able to use different .dll files in order for this error not to happen. This could be worked around by providing a method to specify the location of the .dll file, https://github.com/objectbox/objectbox-java/issues/973
Logs, stack traces
[15:34:38 WARN]: Caused by: java.lang.LinkageError: [ObjectBox] Loading native library failed, please report this to us: vendor=Oracle Corporation,os=linux,os.arch=amd64,model=64,linux=true,machine=x86_64
[21:23:30 WARN]: java.io.FileNotFoundException: objectbox-jni-windows-x64.dll (El proceso no tiene acceso al archivo porque está siendo utilizado por otro proceso)
[21:23:30 WARN]: at java.base/java.io.FileOutputStream.open0(Native Method)
[21:23:30 WARN]: at java.base/java.io.FileOutputStream.open(FileOutputStream.java:293)
[21:23:30 WARN]: at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:235)
[21:23:30 WARN]: at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:184)
[21:23:30 WARN]: at Plugin-1.0-SNAPSHOT.jar//io.objectbox.internal.NativeLibraryLoader.checkUnpackLib(NativeLibraryLoader.java:227)
[21:23:30 WARN]: at Plugin-1.0-SNAPSHOT.jar//io.objectbox.internal.NativeLibraryLoader.<clinit>(NativeLibraryLoader.java:75)
[21:23:30 WARN]: at Plugin-1.0-SNAPSHOT.jar//io.objectbox.BoxStore.<init>(BoxStore.java:262)
[21:23:30 WARN]: at Plugin-1.0-SNAPSHOT.jar//io.objectbox.BoxStoreBuilder.build(BoxStoreBuilder.java:516)
[21:23:30 WARN]: at Plugin-1.0-SNAPSHOT.jar//dev.ckblck.referrals.logic.reward.storage.pending.PendingRewardDatabase.loadDatabase(PendingRewardDatabase.java:79)
[21:23:30 WARN]: at Plugin-1.0-SNAPSHOT.jar//dev.ckblck.referrals.logic.reward.storage.pending.PendingRewardDatabase.<init>(PendingRewardDatabase.java:30)
[21:23:30 WARN]: at Plugin-1.0-SNAPSHOT.jar//dev.ckblck.referrals.Plugin.lambda$onEnable$0(Plugin.java:82)
[21:23:30 WARN]: at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804)
[21:23:30 WARN]: at java.base/java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1796)
[21:23:30 WARN]: at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
[21:23:30 WARN]: at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
[21:23:30 WARN]: at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
[21:23:30 WARN]: at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
[21:23:30 WARN]: at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
[21:23:30 WARN]: java.util.concurrent.CompletionException: java.lang.LinkageError: [ObjectBox] Loading native library failed, please report this to us: vendor=Amazon.com Inc.,os=windows 10,os.arch=amd64,model=64,linux=false,machine=null
[21:23:30 WARN]: at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315)
[21:23:30 WARN]: at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:320)
[21:23:30 WARN]: at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1807)
[21:23:30 WARN]: at java.base/java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1796)
[21:23:30 WARN]: at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
[21:23:30 WARN]: at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
[21:23:30 WARN]: at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
[21:23:30 WARN]: at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
[21:23:30 WARN]: at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
[21:23:30 WARN]: Caused by: java.lang.LinkageError: [ObjectBox] Loading native library failed, please report this to us: vendor=Amazon.com Inc.,os=windows 10,os.arch=amd64,model=64,linux=false,machine=null
Additional context
- Is there anything special about your app?
I'm using ObjectBox for Spigot Java plugins. In this context, theobjectbox-jni-windows-x64is being shared for all the plugins that use ObjectBox, and as far as I'm aware, there is no viable way to modify the location of theobjectbox-jni-windows-x64file for each instance. Possibly related with https://github.com/objectbox/objectbox-java/issues/973
The Spigot standalone loads each plugin and when two plugins are using ObjectBox, the error occurrs.
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从第 227 行的 io.objectbox.internal.NativeLibraryLoader.checkUnpackLib 和相关 issue #973 开始,然后在 Windows 和 Linux 上复现两个共享原生库的 ObjectBox 应用或 Spigot 插件。完成标准是:在它们的原生库并发加载时,两个用户都能初始化 ObjectBox,且不会出现 LinkageError 或 FileNotFoundException。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- java
- 领域
- databases
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 42/100