java.util.NoSuchElementException while starting an OSGi framework programatically

一世执手 提交于 2019-11-28 14:17:53

Service Loader searches the classpath for the interface you have asked for -- in this case FrameworkFactory. To fix it you need to put an OSGi Framework implementation on the classpath.

For example if you choose Felix, make sure that org.apache.felix.framework-<version>.jar is present on the classpath when you launch your application.

Make sure that your import for FrameworkFactory.class is on org.osgi.framework.launch.FrameworkFactory (not org.apache.felix.framework.FrameworkFactory). I ran into this same error (NoSuchElementException), when I broke up the statements the ServiceLoader.load() call was throwing a ClassNotFoundexception. Not sure why the load exception was eclipsed by the next call - but I reverted and confirmed this was happening. Good Luck!

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