简体   繁体   中英

Equinox can´t resolve org.eclipse.osgi.services and org.eclipse.equinox.cm

I am new to OSGI and I am currently stuck with following problem:

I am trying to write an OSGI module with a managed service which should return hello world strings in different languages based on configuration. I have downloaded Equinox and added it under Preferences/Plug-in Development/Target platform/Content in my Eclipse IDE. When I then try to import the packages I require in the MANIFEST.ML

Import-Package: org.osgi.framework;version="1.3.0", org.eclipse.equinox.cm, org.eclipse.osgi.services

Eclipse warns me that no available bundle exports these packages (I have ticked them under Preferences/Plug-in Development/Target platform/) even though Eclipse then recognizes classes like ManagedService. When I try to run the project anyways I get following output:

WARNING: Using incubator modules: jdk.incubator.httpclient
Hello World
!SESSION 2018-11-11 17:34:31.981 -----------------------------------------------
eclipse.buildId=unknown
java.version=9.0.4
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=de_AT
Command-line arguments:  -dev file:C:/Users/SpaceLama/eclipse-workspace/.metadata/.plugins/org.eclipse.pde.core/New_configuration/dev.properties -os win32 -ws win32 -arch x86_64 -consoleLog -console

!ENTRY HelloWorld 4 0 2018-11-11 17:34:32.505
!MESSAGE FrameworkEvent ERROR
!STACK 0
org.osgi.framework.BundleException: Could not resolve module: HelloWorld [33]
  Unresolved requirement: Import-Package: translator
    -> Export-Package: translator; bundle-symbolic-name="Translator"; bundle-version="1.0.0.qualifier"; version="0.0.0"
       Translator [69]
         Unresolved requirement: Import-Package: org.eclipse.equinox.cm

    at org.eclipse.osgi.container.Module.start(Module.java:447)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1685)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1665)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1627)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1558)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:233)
    at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:343)

!ENTRY org.eclipse.osgi.services 4 0 2018-11-11 17:34:32.552
!MESSAGE FrameworkEvent ERROR
!STACK 0
org.osgi.framework.BundleException: Could not resolve module: org.eclipse.osgi.services [61]
  Unresolved requirement: Import-Package: javax.servlet; resolution:="optional"
  Unresolved requirement: Import-Package: javax.servlet.http; resolution:="optional"
  Unresolved requirement: Import-Package: org.osgi.util.function; version="[1.0.0,2.0.0)"

    at org.eclipse.osgi.container.Module.start(Module.java:447)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1685)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1665)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1627)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1558)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:233)
    at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:343)

!ENTRY Translator 4 0 2018-11-11 17:34:32.552
!MESSAGE FrameworkEvent ERROR
!STACK 0
org.osgi.framework.BundleException: Could not resolve module: Translator [69]
  Unresolved requirement: Import-Package: org.eclipse.equinox.cm

    at org.eclipse.osgi.container.Module.start(Module.java:447)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1685)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1665)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1627)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1558)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:233)
    at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:343)

!ENTRY org.eclipse.osgi 4 0 2018-11-11 17:34:32.552
!MESSAGE Bundle initial@reference:file:../../eclipse-workspace/HelloWorld/ was not resolved.

!ENTRY org.eclipse.osgi 4 0 2018-11-11 17:34:32.552
!MESSAGE Bundle initial@reference:file:../../eclipse-workspace/Translator/ was not resolved.

!ENTRY org.eclipse.osgi 4 0 2018-11-11 17:34:32.552
!MESSAGE Bundle initial@reference:file:plugins/org.eclipse.osgi.services_3.7.100.v20180827-1536.jar was not resolved.

ManagedService appears to be in the org.osgi.service.cm package (not org.eclipse.equinox.cm ) which the org.eclipse.osgi.services plug-in does export. So I think you are importing the wrong packages.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM