OSGI expose An “ClassNotFoundException: org.w3c.dom.***” Error when release

烈酒焚心 提交于 2019-11-30 22:13:07

OSGi gives access to system packages but only java.* packages by default, this does not include other packages like: javax.net , javax.xml , com.sun

Thus it is necessary to specify any of such packages for OSGi framework to export them through the system bundle making them accessible to other bundles that import them.

To do that you need to set a configuration property with the additional packages required by your bundles, try setting it as a system property before starting the OSGi framework such that it picks up this property when it first starts.

Assuming you are on OSGi 4.2, that property would be configured like:

org.osgi.framework.system.packages.extra=org.w3c.dom

You may want to check the Apache Felix Framework Configuration Properties for more details, though this property is part of the OSGi spec and thus should be available in other implementations as well

Please update your question to include the bundle's MANIFEST.MF

It looks like org.w3c.dom is not implicitly provided in your production. Check the Import-Package header, may be you don't have Import-Package: org.w3c.dom

If you are using Equinox, you can edit the config.ini and add "org.w3c.dom" to org.osgi.framework.system.packages key and import the same packages in your MANIFEST.MF

in my case adding

org.osgi.framework.bootdelegation=xx...xxx,org.w3c.dom

solved my problem.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!