Hi,
I'm trying run an osgi integration (extending AbstractConfigurableBundleCreatorTests) that use a Jetty web server.
The following bundles are supposed to be started by my test:
com.springsource.org.mortbay.jetty.server;6.1.9
com.springsource.org.mortbay.util;6.1.9
org.springframework.osgi.jetty.web.extender.fragme nt.osgi;1.0.0
org.springframework.bundle.osgi.web.extender;1.1.1
org.springframework.bundle.osgi.web;1.1.1
...
But when my test runs, I get the following exception:
Code:
16:49:32,361 INFO WarLoaderListener - Starting [org.springframework.osgi.web.extender] bundle v.[1.1.1.A]
16:49:32,361 INFO WarListenerConfiguration - No custom extender configuration detected; using defaults...
16:49:32,361 ERROR NodesManagerServiceIntegrationTest - cannot start bundle [Spring DM Web Extender (org.springframework.osgi.web.extender)|file:/C:/svn/griffin/core-platform/logical-master/integration-tests/./target/it-dependencies/org.springframework.osgi.web.extender-1.1.1.A.jar]
org.osgi.framework.BundleException: Exception in org.springframework.osgi.web.extender.internal.activator.WarLoaderListener.start() of bundle org.springframework.osgi.web.extender.
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:1018)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:974)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:346)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:260)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:252)
at org.springframework.osgi.test.AbstractOsgiTests.startBundle(AbstractOsgiTests.java:341)
at org.springframework.osgi.test.AbstractOsgiTests.startup(AbstractOsgiTests.java:258)
at org.springframework.osgi.test.AbstractOsgiTests.prepareTestExecution(AbstractOsgiTests.java:374)
at org.springframework.osgi.test.AbstractOsgiTests.runBare(AbstractOsgiTests.java:203)
at org.springframework.osgi.test.AbstractOsgiTests$1.protect(AbstractOsgiTests.java:184)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at org.springframework.osgi.test.AbstractOsgiTests.run(AbstractOsgiTests.java:181)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:165)
at org.apache.maven.surefire.Surefire.run(Surefire.java:107)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:289)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:993)
Caused by: java.lang.NoClassDefFoundError: org/apache/catalina/Loader
at org.springframework.osgi.web.extender.internal.activator.WarListenerConfiguration.createDefaultWarDeployer(WarListenerConfiguration.java:188)
at org.springframework.osgi.web.extender.internal.activator.WarListenerConfiguration.<init>(WarListenerConfiguration.java:102)
at org.springframework.osgi.web.extender.internal.activator.WarLoaderListener.start(WarLoaderListener.java:339)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl$2.run(BundleContextImpl.java:999)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:993)
... 24 more
Caused by: java.lang.ClassNotFoundException: org.apache.catalina.Loader
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClassInternal(BundleLoader.java:434)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:369)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:357)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:83)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
... 30 more
It looks like the fragment bundle that configure the web extender (to use the JettyWarDeployer) is not attached to the web-extender when the activator of the web-extender is called...
I take a look to find how bundles are started by the org.springframework.osgi.test.AbstractOsgiTests and I find that the bundles are started by calling bundle.start()... This means that the bundles are started with the activation policy equal to eager activation. I am not familiar with the activation policies but from what I understand the bundle activator of the fragment-host will always be called before the fragment bundle could be attached to the host. Is it correct?
Do you know how I can avoid this error?