Hi, On 16.10.2010, at 14:47, Thiébault Benoît wrote:
> Thank you Clément for the quick fix. > > On what repository can I find iPOJO 1.7-SNAPSHOT? > > Currently, Maven can't find one of the required artifacts I just deployed it on apache.snapshots: https://repository.apache.org/content/repositories/snapshots/org/apache/felix/org.apache.felix.ipojo.manipulator/1.7.0-SNAPSHOT/ Regards, Clement > > Kind regards, > > Benoît > > ---------- > 1) org.apache.felix:org.apache.felix.ipojo.manipulator:jar:1.7.0-SNAPSHOT > > Try downloading the file manually from the project website. > > > Le 15 oct. 2010 à 20:15, Clement Escoffier a écrit : > >> Hi, >> >> So first it was an iPOJO issue >> (https://issues.apache.org/jira/browse/FELIX-2664). I've fixed it in the >> trunk. To check, compile the manipulator form the iPOJO trunk and configure >> the maven-ipojo-plugin with: >> <plugin> >> <groupId>org.apache.felix</groupId> >> <artifactId>maven-ipojo-plugin</artifactId> >> <executions> >> <execution> >> <goals> >> <goal>ipojo-bundle</goal> >> </goals> >> </execution> >> </executions> >> <dependencies> >> <dependency> >> >> <artifactId>org.apache.felix.ipojo.manipulator</artifactId> >> <groupId>org.apache.felix</groupId> >> <version>1.7.0-SNAPSHOT</version> >> </dependency> >> </dependencies> >> </plugin> >> >> Regards, >> >> Clement >> >> On 12.10.2010, at 19:48, Clement Escoffier wrote: >> >>> Hi, >>> >>> Could you send me your code or (better) a simplified version. We have code >>> using JNI and iPOJO but it's not integrated in the test suite (shame on >>> me...). >>> It probably comes from an issue during the manipulation of the native >>> methods. >>> >>> Regards, >>> >>> Clement >>> >>> On 12.10.2010, at 14:51, Thiébault Benoît wrote: >>> >>>> I tried. >>>> Still got the same error. >>>> >>>> Ben >>>> >>>> Le 12 oct. 2010 à 14:44, Derek Baum a écrit : >>>> >>>>> Try putting System.loadLibrary() in a static block, rather than in the >>>>> start() method. >>>>> >>>>> public class HelloWorld { >>>>> static { >>>>> System.loadLibrary("HelloWorld"); >>>>> } >>>>> ... >>>>> } >>>>> >>>>> Derek >>>>> >>>>> >>>>> 2010/10/12 Thiébault Benoît <[email protected]> >>>>> >>>>>> This is definitely an iPOJO problem: I just used an OSGi BundleActivator >>>>>> and it works... >>>>>> >>>>>> Ben >>>>>> >>>>>> Le 12 oct. 2010 à 12:30, Derek Baum a écrit : >>>>>> >>>>>>> I doubt this problem is related to iPOJO, but it may be worth factoring >>>>>> this >>>>>>> out of the equation by testing with a BundleActivator instead of iPOJO. >>>>>> It >>>>>>> may still fail, but you may get a more meaningful exception. >>>>>>> >>>>>>> I created a Mac native bundle about 6 months ago, and was caught out by >>>>>> the >>>>>>> .jnilib extension, which was required on OSX 10.6.3. >>>>>>> >>>>>>> Derek >>>>>>> >>>>>>> >>>>>>> 2010/10/12 Thiébault Benoît <[email protected]> >>>>>>> >>>>>>>> Hi Derek, >>>>>>>> >>>>>>>> I tried to run it under Linux (changing the Bundle-NativeCode >>>>>> accordingly) >>>>>>>> and got the same result. >>>>>>>> >>>>>>>> The jnilib extension was mandatory in MacOSX early days, it is now >>>>>> supposed >>>>>>>> to supports both ( >>>>>>>> >>>>>> http://markmail.org/message/cksb24oiwjszohvl#query:jnilib%20dylib+page:1+mid:nvmhqaimybukzg4l+state:results >>>>>>>> ). >>>>>>>> >>>>>>>> Anyway, if the problem was here, it would crash when using "java >>>>>>>> -Djava.library.path=./lib org.test.jni.HelloWorld" as well, which is >>>>>>>> not >>>>>> the >>>>>>>> case. >>>>>>>> >>>>>>>> Regarding the OS name, I tried to use MacOSX instead of "Mac OS X" and >>>>>>>> still got the same error. On old equinox versions (prior 3.3 I think), >>>>>> the >>>>>>>> MacOSX alias was not recognized, this is why I chose to be conservative >>>>>> at >>>>>>>> first and used "Mac OS X" instead, which was supported. >>>>>>>> >>>>>>>> Kind regards, >>>>>>>> >>>>>>>> Ben >>>>>>>> >>>>>>>> Le 12 oct. 2010 à 11:57, Derek Baum a écrit : >>>>>>>> >>>>>>>>> System.loadLibrary() on OSX expects the shared library to have a >>>>>> .jnilib >>>>>>>>> extension. >>>>>>>>> >>>>>>>>> So try renaming libHelloWorld.dylib to libHelloWorld.jnilib and adjust >>>>>>>> the >>>>>>>>> Bundle-NativeCode header accordingly. I actually use osname=MacOSX, >>>>>>>>> but >>>>>>>> "Mac >>>>>>>>> OS X" may work too. >>>>>>>>> >>>>>>>>> regards, >>>>>>>>> >>>>>>>>> Derek >>>>>>>>> >>>>>>>>> 2010/10/12 Thiébault Benoît <[email protected]> >>>>>>>>> >>>>>>>>>> Hi everyone, >>>>>>>>>> >>>>>>>>>> I'm trying a very simple JNI example with iPOJO and OSGi. >>>>>>>>>> Basically, I implemented the HelloWorld example provided by SUN ( >>>>>>>>>> http://java.sun.com/docs/books/jni/html/start.html) and packaged it >>>>>> as >>>>>>>> an >>>>>>>>>> iPOJO bundle. The HelloWorld.java file looks like this: >>>>>>>>>> >>>>>>>>>>> package org.test.jni; >>>>>>>>>>> >>>>>>>>>>> public class HelloWorld { >>>>>>>>>>> public native void nativePrint(); >>>>>>>>>>> >>>>>>>>>>> public static void main(String[] args) { >>>>>>>>>>> (new HelloWorld()).start(); >>>>>>>>>>> } >>>>>>>>>>> >>>>>>>>>>> public void start() { >>>>>>>>>>> System.loadLibrary("HelloWorld"); >>>>>>>>>>> >>>>>>>>>>> nativePrint(); >>>>>>>>>>> } >>>>>>>>>>> >>>>>>>>>>> public void stop() { >>>>>>>>>>> System.out.println("Goodbye"); >>>>>>>>>>> } >>>>>>>>>>> } >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> While the HelloWorld.c is: >>>>>>>>>> >>>>>>>>>>> #include <jni.h> >>>>>>>>>>> #include <stdio.h> >>>>>>>>>>> #include "org_test_jni_HelloWorld.h" >>>>>>>>>>> >>>>>>>>>>> JNIEXPORT void JNICALL >>>>>>>>>>> Java_org_test_jni_HelloWorld_nativePrint(JNIEnv *env, jobject obj) >>>>>>>>>>> { >>>>>>>>>>> printf("Hello World!\n"); >>>>>>>>>>> return; >>>>>>>>>>> } >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> The BND configuration is: >>>>>>>>>> >>>>>>>>>>> <plugin> >>>>>>>>>>> <groupId>org.apache.felix</groupId> >>>>>>>>>>> <artifactId>maven-bundle-plugin</artifactId> >>>>>>>>>>> <version>1.4.3</version> >>>>>>>>>>> <extensions>true</extensions> >>>>>>>>>>> <configuration> >>>>>>>>>>> <instructions> >>>>>>>>>>> >>>>>>>>>> <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName> >>>>>>>>>>> <Private-Package>org.test.jni</Private-Package> >>>>>>>>>>> <Import-Package></Import-Package> >>>>>>>>>>> <Export-Package></Export-Package> >>>>>>>>>>> <Include-Resource> >>>>>>>>>>> {maven-resources}, >>>>>>>>>>> lib=src/main/c/lib >>>>>>>>>>> </Include-Resource> >>>>>>>>>>> <Bundle-NativeCode> >>>>>>>>>>> lib/libHelloWorld.dylib; >>>>>>>>>>> osname="Mac OS X" >>>>>>>>>>> </Bundle-NativeCode> >>>>>>>>>>> </instructions> >>>>>>>>>>> </configuration> >>>>>>>>>>> </plugin> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> and the iPOJO metadata.xml: >>>>>>>>>>> <ipojo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >>>>>>>>>>> xsi:schemaLocation="org.apache.felix.ipojo >>>>>>>>>> http://felix.apache.org/ipojo/schemas/CURRENT/core.xsd" >>>>>>>>>>> xmlns="org.apache.felix.ipojo"> >>>>>>>>>>> <component classname="org.test.jni.HelloWorld"> >>>>>>>>>>> <callback transition="validate" method="start"/> >>>>>>>>>>> <callback transition="invalidate" method="stop"/> >>>>>>>>>>> </component> >>>>>>>>>>> <instance component="org.test.jni.HelloWorld" /> >>>>>>>>>>> </ipojo> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> When I run this sample application via command line, it works: >>>>>>>>>>> java -Djava.library.path=./lib org.test.jni.HelloWorld >>>>>>>>>>> Hello World! >>>>>>>>>> >>>>>>>>>> But when I load it in OSGi (equinox), I have the following error: >>>>>>>>>>> [ERROR] org.test.jni.HelloWorld : Code attribute in native or >>>>>> abstract >>>>>>>>>> methods in class file org/test/jni/HelloWorld >>>>>>>>>>> java.lang.ClassFormatError: Code attribute in native or abstract >>>>>>>> methods >>>>>>>>>> in class file org/test/jni/HelloWorld >>>>>>>>>>> at java.lang.ClassLoader.defineClass1(Native Method) >>>>>>>>>>> at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632) >>>>>>>>>>> at java.lang.ClassLoader.defineClass(ClassLoader.java:616) >>>>>>>>>>> at >>>>>>>>>> >>>>>>>> >>>>>> org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.defineClass(DefaultClassLoader.java:188) >>>>>>>>>>> at >>>>>>>>>> >>>>>>>> >>>>>> org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClass(ClasspathManager.java:580) >>>>>>>>>>> at >>>>>>>>>> >>>>>>>> >>>>>> org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findClassImpl(ClasspathManager.java:550) >>>>>>>>>>> at >>>>>>>>>> >>>>>>>> >>>>>> org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClassImpl(ClasspathManager.java:481) >>>>>>>>>>> at >>>>>>>>>> >>>>>>>> >>>>>> org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass_LockClassLoader(ClasspathManager.java:469) >>>>>>>>>>> at >>>>>>>>>> >>>>>>>> >>>>>> org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:449) >>>>>>>>>>> at >>>>>>>>>> >>>>>>>> >>>>>> org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:216) >>>>>>>>>>> at >>>>>>>>>> >>>>>>>> >>>>>> org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:393) >>>>>>>>>>> at >>>>>>>>>> >>>>>>>> >>>>>> org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:469) >>>>>>>>>>> at >>>>>>>>>> >>>>>>>> >>>>>> org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422) >>>>>>>>>>> at >>>>>>>>>> >>>>>>>> >>>>>> org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410) >>>>>>>>>>> at >>>>>>>>>> >>>>>>>> >>>>>> org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107) >>>>>>>>>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:248) >>>>>>>>>>> at >>>>>>>>>> >>>>>>>> >>>>>> org.eclipse.osgi.internal.loader.BundleLoader.loadClass(BundleLoader.java:338) >>>>>>>>>>> at >>>>>>>>>> >>>>>>>> >>>>>> org.eclipse.osgi.framework.internal.core.BundleHost.loadClass(BundleHost.java:232) >>>>>>>>>>> at >>>>>>>>>> >>>>>>>> >>>>>> org.eclipse.osgi.framework.internal.core.AbstractBundle.loadClass(AbstractBundle.java:1197) >>>>>>>>>>> at >>>>>>>>>> >>>>>>>> >>>>>> org.apache.felix.ipojo.ComponentFactory.loadClass(ComponentFactory.java:220) >>>>>>>>>>> at >>>>>>>>>> org.apache.felix.ipojo.InstanceManager.load(InstanceManager.java:542) >>>>>>>>>>> at >>>>>>>>>> >>>>>>>> >>>>>> org.apache.felix.ipojo.InstanceManager.createObject(InstanceManager.java:574) >>>>>>>>>>> at >>>>>>>>>> >>>>>>>> >>>>>> org.apache.felix.ipojo.InstanceManager.getPojoObject(InstanceManager.java:777) >>>>>>>>>>> at >>>>>>>>>> >>>>>>>> >>>>>> org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.__stateChanged(LifecycleCallbackHandler.java:156) >>>>>>>>>>> at >>>>>>>>>> >>>>>>>> >>>>>> org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.stateChanged(LifecycleCallbackHandler.java) >>>>>>>>>>> at >>>>>>>>>> >>>>>>>> >>>>>> org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.java:441) >>>>>>>>>>> at >>>>>>>>>> org.apache.felix.ipojo.InstanceManager.start(InstanceManager.java:322) >>>>>>>>>>> at >>>>>>>>>> >>>>>>>> >>>>>> org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFactory.java:155) >>>>>>>>>>> at >>>>>>>>>> >>>>>>>> >>>>>> org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:301) >>>>>>>>>>> at >>>>>>>>>> >>>>>>>> >>>>>> org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:238) >>>>>>>>>>> at >>>>>>>>>> >>>>>>>> >>>>>> org.apache.felix.ipojo.InstanceCreator$ManagedInstance.create(InstanceCreator.java:343) >>>>>>>>>>> at >>>>>>>>>> >>>>>>>> >>>>>> org.apache.felix.ipojo.InstanceCreator.addInstance(InstanceCreator.java:89) >>>>>>>>>>> at org.apache.felix.ipojo.Extender.parse(Extender.java:269) >>>>>>>>>>> at >>>>>>>>>> org.apache.felix.ipojo.Extender.startManagementFor(Extender.java:208) >>>>>>>>>>> at org.apache.felix.ipojo.Extender.access$600(Extender.java:52) >>>>>>>>>>> at >>>>>>>>>> org.apache.felix.ipojo.Extender$CreatorThread.run(Extender.java:682) >>>>>>>>>>> at java.lang.Thread.run(Thread.java:637) >>>>>>>>>>> [ERROR] org.test.jni.HelloWorld : Code attribute in native or >>>>>> abstract >>>>>>>>>> methods in class file org/test/jni/HelloWorld >>>>>>>>>>> [ERROR] iPOJO Instance Creator : A matching factory was found for >>>>>>>>>> {component=org.test.jni.HelloWorld, instance.name >>>>>>>> =org.test.jni.HelloWorld-0}, >>>>>>>>>> but the instantiation failed : The configuration is not correct for >>>>>> the >>>>>>>> type >>>>>>>>>> org.test.jni.HelloWorld : Code attribute in native or abstract >>>>>>>>>> methods >>>>>>>> in >>>>>>>>>> class file org/test/jni/HelloWorld >>>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> What did go wrong? >>>>>>>>>> >>>>>>>>>> Kind regards, >>>>>>>>>> Ben >>>>>>>>>> --------------------------------------------------------------------- >>>>>>>>>> To unsubscribe, e-mail: [email protected] >>>>>>>>>> For additional commands, e-mail: [email protected] >>>>>>>>>> >>>>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> --------------------------------------------------------------------- >>>>>>>> To unsubscribe, e-mail: [email protected] >>>>>>>> For additional commands, e-mail: [email protected] >>>>>>>> >>>>>>>> >>>>>> >>>>>> >>>>>> --------------------------------------------------------------------- >>>>>> To unsubscribe, e-mail: [email protected] >>>>>> For additional commands, e-mail: [email protected] >>>>>> >>>>>> >>>> >>>> >>>> --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: [email protected] >>>> For additional commands, e-mail: [email protected] >>>> >>> >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] >

