Announcement Announcement Module
Collapse
No announcement yet.
Spring Conponent scan in Equinox OSGI container Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Conponent scan in Equinox OSGI container

    Hi,

    I'm deploying an existing WAR file as a WAB that uses Spring component scanning in Equinox (Apache Aries Equinox test harness)

    I noticed that Spring supports "auto-detecting" the equinox container in the PathMatchingResourcePatternResolver by loading the org.eclipse.core.runtime.FileLocator class.

    However, Spring is unable to load the class (ClassNotFoundException) resulting in no specific bundle: or bundleresource: handling during the component scan. (The WAB runs fine when specifying the beans in the context manually and disabling the component scanning).

    What do I need to change to my WAB in terms of import packages, dynamic imports or other configuration in order to make this work ?

    I've already tried using dynamic imports, and importing the org.eclipse.core.runtime package, but the container responds with

    The bundle could not be resolved. Reason: Missing Constraint: Import-Package: org.eclipse.core.runtime; version="[3.1.0,4.0.0)"

  • #2
    Fixed it by installing the org.eclipse.equinox.common-3.6.0.v20100503.jar in Equinox.

    This can be done manually by executing the following command in the equinox console :

    Code:
    install file:///Users/ddewaele/.m2/repository/org/eclipse/equinox/org.eclipse.equinox.common/3.6.0.v20100503/org.eclipse.equinox.common-3.6.0.v20100503.jar
    or by adding the following line in your Equinox config.ini

    Code:
    /Users/ddewaele/.m2/repository/org/eclipse/equinox/org.eclipse.equinox.common/3.6.0.v20100503/org.eclipse.equinox.common-3.6.0.v20100503.jar@start
    If you check your bundles using the ss command, you should see it in the list

    Code:
    46	ACTIVE      org.eclipse.equinox.common_3.6.0.v20100503
    This org.eclipse.equinox.common bundle exports the following package :

    Code:
    org.eclipse.core.internal.runtime;common=split
    This is the package that needs to be imported by the bundle that does the component scanning.

    So in the WAB we need to ensure that we import this package using the Import-Package in the MANIFEST.MF

    Code:
    org.eclipse.core.runtime;version="[3.1.0,4.0.0)";common=split
    After that, when deploying the Spring WAB you should see this if you have debug logging enabled

    Code:
    DEBUG o.s.c.i.s.PathMatchingResourcePatternResolver - Found Equinox FileLocator for OSGi bundle URL resolution
    If all goes well, it should now be able to translate the bundle resource

    Code:
    bundleresource://48.fwk426901684:1/com/ecs/sample/spring/
    into a URL resource

    Code:
    URL [jar:file:/Users/ddewaele/equinox-test-harness/target/configuration/org.eclipse.osgi/bundles/48/1/bundlefile!/WEB-INF/classes/com/ecs/sample/spring/]
    Last edited by ddewaele; Nov 3rd, 2012, 06:53 AM.

    Comment

    Working...
    X