felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guillaume Nodet <gno...@gmail.com>
Subject Re: Unresolved constraint
Date Thu, 18 Nov 2010 21:43:56 GMT
On Thu, Nov 18, 2010 at 22:34, Michael Yap <michaelyap@gmail.com> wrote:
> Finally got this to work.
>
> @Richard thanks mate, turned out to be a major user problem. Didn't do a
> clean build when I should have after modifying the framework properties. One
> of those silly things that took hours to figure out and makes me want to
> amputate a limb with a dull spoon.
>
> @Guillaume I extended the default ScriptEngineManager and implemented my own
> discovery model which works around OSGI's limitations (or restrictions ?).
> Not the most elegant of solutions but fits my use case quite nicely.

I guess that's what we did in ServiceMix too:
     http://svn.apache.org/repos/asf/servicemix/smx4/specs/trunk/scripting-api-1.0/src/main/java/javax/script/ScriptEngineManager.java
where the script engines are discovered in bundles and automatically
available as they would in a plain J2SE environement.

>
> -Michael-
> @michaelyap
>
> On Wed, Nov 17, 2010 at 3:08 PM, Guillaume Nodet <gnodet@gmail.com> wrote:
>
>> Not sure how you plan to use scripting in OSGi, but unless you do some
>> tricks it just won't work because the scripting api rely on the
>> META-INF/services service discovery to find languages, and this will
>> just not work in OSGi.
>> The way we've been solving those problems is by not exporting the
>> package from the JRE and instead use a customized bundle for the api:
>>
>> http://repo2.maven.org/maven2/org/apache/servicemix/specs/org.apache.servicemix.specs.scripting-api-1.0/1.6.0/org.apache.servicemix.specs.scripting-api-1.0-1.6.0.jar
>>
>> I guess that does not really answer the question, but Richard just
>> gave you some hints.
>>
>> On Wed, Nov 17, 2010 at 23:42, Michael Yap <michaelyap@gmail.com> wrote:
>> > 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
>> >
>>
>>
>>
>> --
>> Cheers,
>> Guillaume Nodet
>> ------------------------
>> Blog: http://gnodet.blogspot.com/
>> ------------------------
>> Open Source SOA
>> http://fusesource.com
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
>>
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Mime
View raw message