Hey fellas I posted this on stackoverflow yesterday and figured I'd have a
better shot here.

I'm writing an OSGI bundle using the javax.script package and am having some
issues getting Felix to load the package correctly. When attempting to start
the bundle, I'm getting:

Failed bundle start for org.plugin.script.plugin-scripter [2]:
org.osgi.framework.BundleException: Unresolved constraint in bundle 2:
package; (package=javax.script)

which I think happens when we try to reference a package which isn't
correctly loaded into the bundle. I'm fairly certain this is down to the
fact that javax.script is only bundled into the JDK starting 1.6 and for
some reason Maven is building using something else. So far I've:

a. Set the necessary import in my Maven POM for Felix by:

<plugin>
    <groupId>org.apache.felix</groupId>

    <artifactId>maven-bundle-plugin</artifactId>
    <extensions>true</extensions>

    <configuration>
        <instructions>
            <Export-Package>org.plugin.script</Export-Package>

            <Private-Package>org.plugin.script.*</Private-Package>
            
<Bundle-Activator>org.plugin.script.ScripterPlugin</Bundle-Activator>

            
<Import-Package>!*,javax.script,org.osgi.framework;version="1.3.0",javax.naming,javax.naming.spi</Import-Package>

            
<Embed-Dependency>!org.apache.felix*;scope=compile|runtime;inline=false</Embed-Dependency>
            <Embed-Transitive>true</Embed-Transitive>

            <Embed-Directory>dependency</Embed-Directory>
            <Embed-StripGroup>true</Embed-StripGroup>

            <_failok>true</_failok>
        </instructions>
    </configuration>
</plugin>

b. Set the Maven compiler to 1.6 since that's the earliest we get
javax.script

<plugin>
    <groupId>org.apache.maven.plugins</groupId>

    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.0.2</version>

    <configuration>
        <source>1.6</source>

        <target>1.6</target>
    </configuration>

</plugin>

c. Not even sure if this makes a difference but I set Felix's framework
properties (in their config.properties) to 1.6.0 and included the
javax.script export. TBH I'm not sure about this one but figured I'd take a
shot.

org.osgi.framework.system.packages=org.osgi.framework; version=1.3.0, \

    [lots of stuff in between]
    javax.script; \

    version="1.6.0"

Still nadda tho. What else did I miss ?

UPDATE: I've tried removing the <Import-Package> completely from the bnd
instructions and still ran into the unresolved constraint. The manifest for
the bundle (after removing the Import-Package tag) looks like

Manifest-Version: 1.0
Export-Package: org.plugin.script;uses:="javax.script, etc etc"
Import-Package: javax.script, etc etc

Reply via email to