Hello world,

Sorry first for the mail not chaining up in the threads, because I
switched on digest mode... :\

Hello Toni,

Thanks for the tip. For the questions you asked,

> Why do you stick with an old Felix version ? 3.2.2 is current. Try that
> too.
Because I want to keep the environment as close to my final deployment
target, Apache Karaf 2.2.0, as possible - and that uses Felix 3.0.8.
Would like to see if stock configuration works too before upgrading Felix.

But for getting things to work, I did used Felix 3.2.0 in the tests -
same as below.

> - Did you run with pax runner container, too (make sure you remove felix
> from classpath too in that case)

When switch to pax-exam-container-paxrunner and removed felix from my
pom, ran the test without changing code gave me this exception:

--------8X--------
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at
org.ops4j.pax.exam.rbc.internal.RemoteBundleContextImpl.remoteCall(RemoteBundleContextImpl.java:85)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322)
    at sun.rmi.transport.Transport$1.run(Transport.java:177)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
    at
sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:553)
    at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:808)
    at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:667)
    at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:636)
Caused by: org.ops4j.pax.exam.TestContainerException:
java.lang.ClassNotFoundException: com.foo.bar.TestProbe not found by
FoobarService [18]
    at
org.ops4j.pax.exam.raw.extender.intern.ProbeInvokerImpl.call(ProbeInvokerImpl.java:55)
    ... 19 more
Caused by: java.lang.ClassNotFoundException: com.foo.bar.TestProbe not
found by FoobarService [18]
    at
org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:812)
    at org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:72)
    at
org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1801)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
    at
org.apache.felix.framework.ModuleImpl.getClassByDelegation(ModuleImpl.java:670)
    at
org.apache.felix.framework.resolver.WireImpl.getClass(WireImpl.java:102)
    at
org.apache.felix.framework.ModuleImpl.searchImports(ModuleImpl.java:1420)
    at
org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:747)
    at org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:72)
    at
org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1801)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
    at
org.apache.felix.framework.ModuleImpl.getClassByDelegation(ModuleImpl.java:670)
    at org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1629)
    at org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java:909)
    at
org.ops4j.pax.exam.raw.extender.intern.ProbeInvokerImpl.call(ProbeInvokerImpl.java:53)
    ... 19 more
4943 [main] WARN
org.ops4j.pax.exam.rbc.client.intern.RetryRemoteBundleContextClient -
Exception that does not cause Retry : (rooted)
java.lang.ClassNotFoundException in RBC.call
java.lang.ClassNotFoundException: com.foo.bar.TestProbe not found by
FoobarService [18]
    at
org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:812)
    at org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:72)
    at
org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1801)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
    at
org.apache.felix.framework.ModuleImpl.getClassByDelegation(ModuleImpl.java:670)
    at
org.apache.felix.framework.resolver.WireImpl.getClass(WireImpl.java:102)
    at
org.apache.felix.framework.ModuleImpl.searchImports(ModuleImpl.java:1420)
    at
org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:747)
    at org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:72)
    at
org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1801)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
    at
org.apache.felix.framework.ModuleImpl.getClassByDelegation(ModuleImpl.java:670)
    at org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1629)
    at org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java:909)
    at
org.ops4j.pax.exam.raw.extender.intern.ProbeInvokerImpl.call(ProbeInvokerImpl.java:53)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at
org.ops4j.pax.exam.rbc.internal.RemoteBundleContextImpl.remoteCall(RemoteBundleContextImpl.java:85)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322)
    at sun.rmi.transport.Transport$1.run(Transport.java:177)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
    at
sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:553)
    at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:808)
    at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:667)
    at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:636)
--------8X--------

When I explicitly add TestProbe.class to the TinyBundle I built, and
added the necessary imports to the Import-Package: header, it worked...
but I don't think this is the proper way to do the integration test,
because my intention was to call a service exported to the BundleContext
from another bundle.

> Looking at your stacktrace, it looks like related to spring, but need some
> time to look into this.
I suppose I was just getting ClassNotFoundExceptions from the bundle
containing the test probe itself?

I then whipped up another set of test with OSGi blueprint, using Apache
Aries (which Karaf has it built in too) and run on
pax-exam-container-native. That test did worked, and I could get the
service in the test probe.

It does seems like problem may be caused by Spring DM 1.2.1 itself.

If it's true, seems to be an inconvenient truth to me, as I needed some
ConfigurationAdmin dynamics at the configuration XML level that Spring
DM supports while Apache Aries does not support yet :(

> Hello world,
>
> Was trying out Pax Exam 2 (RC4) to do some integration tests for the
> bundle(s) I'm developing for use with OSGi containers.
>
> In the tests, I'm using TinyBundles to assemble a bundle temporarily
> before the artifact is actually packaged.
>
> I use the Player that comes with Pax Exam 2, with code like this (sorry,
> code are edited for asking questions here, hope I didn't miss the
> important parts :( ):
>
> --------8X--------
>         new Player().with(
>            
> systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("OFF"),
>             mavenBundle("org.ops4j.pax.logging", "pax-logging-api",
> "1.6.1"),
>             mavenBundle("org.ops4j.pax.logging", "pax-logging-service",
> "1.6.1"),
>             mavenBundle("commons-io", "commons-io", "2.0.1"),
>             mavenBundle("org.apache.servicemix.bundles",
> "org.apache.servicemix.bundles.asm", "3.3_1"),
>             mavenBundle("org.apache.servicemix.bundles",
> "org.apache.servicemix.bundles.aopalliance", "1.0_5").startLevel(35),
>             mavenBundle("org.apache.servicemix.bundles",
> "org.apache.servicemix.bundles.cglib", "2.2_2").startLevel(35),
>             mavenBundle("org.springframework", "spring-core",
> "3.0.5.RELEASE"),
>             mavenBundle("org.springframework", "spring-beans",
> "3.0.5.RELEASE"),
>             mavenBundle("org.springframework", "spring-asm",
> "3.0.5.RELEASE"),
>             mavenBundle("org.springframework", "spring-aop",
> "3.0.5.RELEASE"),
>             mavenBundle("org.springframework", "spring-context",
> "3.0.5.RELEASE"),
>             mavenBundle("org.springframework", "spring-context-support",
> "3.0.5.RELEASE"),
>             mavenBundle("org.springframework", "spring-expression",
> "3.0.5.RELEASE"),
>             mavenBundle("org.springframework.osgi", "spring-osgi-core",
> "1.2.1"),
>             mavenBundle("org.springframework.osgi", "spring-osgi-io",
> "1.2.1"),
>             mavenBundle("org.springframework.osgi",
> "spring-osgi-extender", "1.2.1"),
>             mavenBundle("org.apache.felix", "org.apache.felix.configadmin"),
>             waitForFrameworkStartup(),
>             felix().version("3.0.8"),
>
>             provision(newBundle().add("META-INF/spring/service.xml", new
> ClassPathResource("/META-INF/spring/service.xml").getInputStream())
>                     .add(FoobarService.class)
>                     .add(FoobarServiceImpl.class)
>                     .add(UpdatableFoobarServiceImpl.class)
>
>                     .set("Spring-Context", "META-INF/spring/service.xml")
>                     .set(Constants.IMPORT_PACKAGE,
> "org.slf4j,org.apache.commons.io,org.springframework.util")
>                     .set(Constants.EXPORT_PACKAGE,
> "com.foo.bar.FoobarService")
>                     .set(Constants.BUNDLE_SYMBOLICNAME, "FoobarService")
>                     .build())
>             )
>
>             .test(WaitForService.class, FoobarService.class.getName(),
> 10000)
>             .play();
> --------8X--------
>
> It goes fine - the test passed. However, when I tried to add a probe for
> my own tests, which I wanted to call the FoobarService above in the
> BundleContext, which could be as simple as
>
> --------8X--------
> public void probe(BundleContext ctx) throws Exception
> {
>     //just wanted to make this line get through before I actually do the
> testing!
>     assert ctx.getServiceReference(FoobarService.class.getName()) != null;
> }
> --------8X--------
>
> then add the test to the player
> --------8X--------
>             //... same as above
>             .test(WaitForService.class, FoobarService.class.getName(),
> 10000)
>             .test(MyTestProbe.class)
>             .play();
> --------8X--------
>
> but when I run the test... bummer.
>
> --------8X--------
> org.springframework.beans.factory.BeanCreationException: Error creating
> bean with name
> 'org.springframework.osgi.service.exporter.support.OsgiServiceFactoryBean#0':
> Initialization of bean failed; nested exception is
> org.springframework.beans.TypeMismatchException: Failed to convert
> property value of type 'java.lang.String' to required type
> 'java.lang.Class[]' for property 'interfaces'; nested exception is
> java.lang.IllegalArgumentException: Cannot find class
> [com.foo.bar.FoobarService]
>     at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
>     at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
>     at
> org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
>     at
> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
>     at
> org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
>     at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
>     at
> org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563)
>     at
> org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
>     at
> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69)
>     at
> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355)
>     at
> org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
>     at
> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
>     at
> org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:132)
>     at java.lang.Thread.run(Thread.java:636)
> Caused by: org.springframework.beans.TypeMismatchException: Failed to
> convert property value of type 'java.lang.String' to required type
> 'java.lang.Class[]' for property 'interfaces'; nested exception is
> java.lang.IllegalArgumentException: Cannot find class
> [com.foo.bar.FoobarService]
>     at
> org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:467)
>     at
> org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:499)
>     at
> org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:493)
>     at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1371)
>     at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1330)
>     at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
>     at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
>     ... 13 more
> Caused by: java.lang.IllegalArgumentException: Cannot find class
> [com.foo.bar.FoobarService]
>     at
> org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:293)
>     at
> org.springframework.beans.propertyeditors.ClassArrayEditor.setAsText(ClassArrayEditor.java:68)
>     at
> org.springframework.beans.TypeConverterDelegate.doConvertTextValue(TypeConverterDelegate.java:416)
>     at
> org.springframework.beans.TypeConverterDelegate.doConvertValue(TypeConverterDelegate.java:388)
>     at
> org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:157)
>     at
> org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:447)
>     ... 19 more
> Caused by: java.lang.ClassNotFoundException: com.foo.bar.FoobarService
> not found from bundle [FoobarService]
>     at
> org.springframework.osgi.util.BundleDelegatingClassLoader.findClass(BundleDelegatingClassLoader.java:103)
>     at
> org.springframework.osgi.util.BundleDelegatingClassLoader.loadClass(BundleDelegatingClassLoader.java:156)
>     at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
>     at org.springframework.util.ClassUtils.forName(ClassUtils.java:257)
>     at
> org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:290)
>     ... 24 more
> Caused by: java.lang.ClassNotFoundException: com.foo.bar.FoobarService
> not found by
> org.ops4j.pax.exam.spi.probesupport.intern.DefaultResourceWriter_54c4ad [21]
>     at
> org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:787)
>     at org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71)
>     at
> org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1768)
>     at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
>     at
> org.apache.felix.framework.ModuleImpl.getClassByDelegation(ModuleImpl.java:645)
>     at
> org.apache.felix.framework.resolver.WireImpl.getClass(WireImpl.java:99)
>     at
> org.apache.felix.framework.ModuleImpl.searchImports(ModuleImpl.java:1390)
>     at
> org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:722)
>     at org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71)
>     at
> org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1768)
>     at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
>     at
> org.apache.felix.framework.ModuleImpl.getClassByDelegation(ModuleImpl.java:645)
>     at org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1612)
>     at org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java:904)
>     at
> org.springframework.osgi.util.BundleDelegatingClassLoader.findClass(BundleDelegatingClassLoader.java:99)
>     ... 28 more
> --------8X--------
>
> For reference, my pom.xml has these dependencies related to Pax Exam
> 2/TinyBundles usage
> --------8X--------
> <dependency>
>             <groupId>junit</groupId>
>             <artifactId>junit</artifactId>
>             <version>4.8.2</version>
>             <scope>test</scope>
>         </dependency>
>         <dependency>
>             <groupId>org.ops4j.pax.exam</groupId>
>             <artifactId>pax-exam-container-native</artifactId>
>             <version>2.0.0-RC4</version>
>             <scope>test</scope>
>         </dependency>
>         <dependency>
>             <groupId>org.ops4j.pax.exam</groupId>
>             <artifactId>pax-exam-spi</artifactId>
>             <version>2.0.0-RC4</version>
>             <scope>test</scope>
>             <exclusions>
>                 <exclusion>
>                     <artifactId>commons-logging</artifactId>
>                     <groupId>commons-logging</groupId>
>                 </exclusion>
>             </exclusions>
>         </dependency>
>         <dependency>
>             <groupId>org.ops4j.pax.exam</groupId>
>             <artifactId>pax-exam-player</artifactId>
>             <version>2.0.0-RC4</version>
>             <scope>test</scope>
>         </dependency>
>         <dependency>
>             <groupId>org.ops4j.pax.exam</groupId>
>             <artifactId>pax-exam-link-mvn</artifactId>
>             <version>2.0.0-RC4</version>
>             <scope>test</scope>
>         </dependency>
>         <dependency>
>             <groupId>org.ops4j.pax.exam</groupId>
>             <artifactId>pax-exam-testforge</artifactId>
>             <version>2.0.0-RC4</version>
>             <scope>test</scope>
>         </dependency>
>         <dependency>
>             <groupId>org.ops4j.pax.swissbox</groupId>
>             <artifactId>pax-swissbox-tinybundles</artifactId>
>             <version>1.3.1</version>
>             <scope>test</scope>
>         </dependency>
>         <dependency>
>             <groupId>org.ops4j.pax.logging</groupId>
>             <artifactId>pax-logging-api</artifactId>
>             <version>1.6.2</version>
>             <scope>test</scope>
>         </dependency>
>         <dependency>
>             <groupId>org.apache.felix</groupId>
>             <artifactId>org.apache.felix.framework</artifactId>
>             <version>3.0.8</version>
>             <scope>test</scope>
>         </dependency>
>         <dependency>
>             <groupId>org.osgi</groupId>
>             <artifactId>org.osgi.compendium</artifactId>
>             <version>4.2.0</version>
>             <scope>test</scope>
>         </dependency>
> --------8X--------
>
> Did I miss anything? Or TinyBundles is not supposed to be used in this
> way for performing integration tests?
>
> Thanks in advance,
> Raymond
>


Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

_______________________________________________
general mailing list
general@lists.ops4j.org
http://lists.ops4j.org/mailman/listinfo/general

Reply via email to