Equinox:通过包正确导出和导入类,但仍然出现 ClassNotFoundException

发布于 2024-11-04 05:50:34 字数 508 浏览 1 评论 0原文

我在 OSGi 中开发时遇到了以下障碍。一组捆绑包负责持久性,使用另一个(Springsource EBR 提供的)捆绑包提供的 com.mysql.jdbc.Driver 类。在另一个包中,我将 Quartz 调度程序库配置为使用数据库作为作业存储。这也是使用 MySQL 驱动程序完成的。然而,在运行时,我得到了一个ClassNotFoundException。这很奇怪,因为持久性仍然可以正常工作。更奇怪的是,当我尝试使用 Class.forName("com.mysql.jdbc.Driver") 手动加载该类时,它已正确加载,这意味着该类确实可用于加载。

不管是否巧合,Drools 似乎也发生了同样的情况...我将一些最新的 Drools jar 重新打包为 OSGi 包,部署它们,再次运行时,会弹出 ClassNotFoundException 。在这两种情况下,所有供应商捆绑包都会添加到清单中的所需捆绑包中。

这个奇怪的问题是否引起了人们的注意?我很高兴听到这个消息......

I came upon the following obstacle whilst developing in OSGi. One set of bundles, responsible for persistence, uses the com.mysql.jdbc.Driver class, offered by another (Springsource EBR provisioned) bundle. In another bundle I'm configuring the Quartz scheduler library to use a database as a jobstore. This is also done using the MySQL driver. Upon running however, I get a ClassNotFoundException. This is strange, since the persistence still functions correctly. Even more strange, when I try to manually load the class, using Class.forName("com.mysql.jdbc.Driver") it is loaded correctly, implying that the class is indeed available for loading.

Coincidence or not, the same seems to be happening with Drools... I repackaged some of the latest Drools jars as OSGi bundles, deployed them and when running again the ClassNotFoundException pops up. In both cases all supplier bundles are added to the required bundles in the manifest.

Does this weird issue ring any bells? I'd be happy to hear about it...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情丝乱 2024-11-11 05:50:34

这似乎是 Equinox 中类加载的问题。我尝试使用 DynamicImport-Package 和 Eclipse-BuddyPolicy 标头修复此问题,但没有取得太大成功。最终,我自己将最新版本的 Quartz 重新打包为捆绑包,并在捆绑包中添加了 MySql jar,从而解决了这个问题。这不是最漂亮或最优雅的解决方案,但目前必须这样做。如果有人可以告诉我更多有关类加载的信息,请随时回复!

This seems to have been a problem concerning the classloading within Equinox. I tried fixing this using the DynamicImport-Package and Eclipse-BuddyPolicy headers, but without much success. Eventually I fixed this by repackaging the latest version of Quartz as a bundle myself, adding the MySql jar in the bundle. It's not the prettiest or most elegant solution, but it will have to do for now. In case anybody could tell me more about the classloading, feel free to reply!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文