Caused by: java.lang.NoClassDefFoundError: org/osgi/framework/BundleActivator: when importing multiple packages - osgi

I'm trying out OSGi samples from apache felix
The first and second examples installed and started fine. But the third example where there is a dependency with osgi and previously installed service fails with class not found error.
MANIFEST.MF
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: French dictionary
Bundle-SymbolicName: fr-dict
Bundle-Description: A bundle that registers a French dictionary service
Bundle-Vendor: Apache Felix
Bundle-Version: 1.0.0
Bundle-Activator: tutorial.example2b.Activator
Import-Package: org.osgi.framework,
tutorial.example2.service
Note: I have given a new line after the last line.
g! start file:/Users/johne/Desktop/bundle-dict-fr.jar 10:18:39
org.osgi.framework.BundleException: Activator start error in bundle fr-dict [11].
at org.apache.felix.framework.Felix.activateBundle(Felix.java:2289)
at org.apache.felix.framework.Felix.startBundle(Felix.java:2145)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998)
at org.apache.felix.gogo.command.Basic.start(Basic.java:739)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.felix.gogo.runtime.Reflective.invoke(Reflective.java:136)
at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:91)
at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:571)
at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:497)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:386)
at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:417)
at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229)
at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoClassDefFoundError: org/osgi/framework/BundleActivator
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.defineClass(BundleWiringImpl.java:2375)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.findClass(BundleWiringImpl.java:2159)
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1578)
at org.apache.felix.framework.BundleWiringImpl.access$200(BundleWiringImpl.java:80)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2018)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.apache.felix.framework.BundleWiringImpl.getClassByDelegation(BundleWiringImpl.java:1404)
at org.apache.felix.framework.Felix.createBundleActivator(Felix.java:4505)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:2220)
... 19 more
Caused by: java.lang.ClassNotFoundException: org.osgi.framework.BundleActivator not found by fr-dict [11]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1610)
at org.apache.felix.framework.BundleWiringImpl.access$200(BundleWiringImpl.java:80)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2018)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 30 more
java.lang.NoClassDefFoundError: org/osgi/framework/BundleActivator
Here is lb output after that,
g! lb 10:19:40
START LEVEL 1
ID|State |Level|Name
0|Active | 0|System Bundle (5.6.8)|5.6.8
1|Active | 1|jansi (1.16.0)|1.16.0
2|Active | 1|JLine Bundle (3.3.0)|3.3.0
3|Active | 1|Apache Felix Bundle Repository (2.0.10)|2.0.10
4|Active | 1|Apache Felix Gogo Command (1.0.2)|1.0.2
5|Active | 1|Apache Felix Gogo JLine Shell (1.0.6)|1.0.6
6|Active | 1|Apache Felix Gogo Runtime (1.0.6)|1.0.6
7|Active | 1|Service listener example (1.0.0)|1.0.0
8|Active | 1|English dictionary (1.0.0)|1.0.0
11|Resolved | 1|French dictionary (1.0.0)|1.0.0

I had the same problem and I got it fixed by rewriting the Import-Package line. Originally I copy-pasted the manifest file so there is propably some illegal character in it.

You have a newline between the two imported packages:
Import-Package: org.osgi.framework,
tutorial.example2.service
Can you try to put both on the same line:
Import-Package: org.osgi.framework, tutorial.example2.service
I guess that in your current Manifest the Import-Package is ignored as the syntax is invalid. So your bundle resolves fine but does not import any packages. When the activator is then run it can not find any external classes.

Related

AEM OSGI Bundle for MSSQL - error javax.net.SocketFactory classdefnotfound

I am trying to create an OSGI bundle for MSSQL driver. I'll post my Manifest below.
Basically, I get an error javax.net.SocketFactory no class def found.
I am able to upload the bundle and start it but, fails when trying to use the a datasource.
Here is my manifest:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Jdbc
Bundle-SymbolicName: com.s360g.mssql.jdbc
Bundle-Version: 1.0.0
Automatic-Module-Name: com.s360g.mssql.jdbc
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: com.microsoft.sqlserver.jdbc,
microsoft.sql
Import-Package: javax.naming,
javax.naming.spi,
javax.net,
javax.net.ssl,
javax.security.auth,
javax.security.auth.login,
javax.security.auth.x500,
javax.sql,
javax.transaction.xa,
javax.xml.parsers,
javax.xml.stream,
javax.xml.transform,
javax.xml.transform.dom,
javax.xml.transform.sax,
javax.xml.transform.stax,
javax.xml.transform.stream,
org.ietf.jgss,
org.w3c.dom,
org.xml.sax,
org.xml.sax.helpers
com.adobe.granite.workflow.WorkflowException: Process execution resulted in an error
at com.adobe.granite.workflow.core.job.HandlerBase.executeProcess(HandlerBase.java:201) [com.adobe.granite.workflow.core:2.0.240.CQ650-B0016]
at com.adobe.granite.workflow.core.job.JobHandler.process(JobHandler.java:260) [com.adobe.granite.workflow.core:2.0.240.CQ650-B0016]
at org.apache.sling.event.impl.jobs.JobConsumerManager$JobConsumerWrapper.process(JobConsumerManager.java:502) [org.apache.sling.event:4.2.12]
at org.apache.sling.event.impl.jobs.queues.JobQueueImpl.startJob(JobQueueImpl.java:293) [org.apache.sling.event:4.2.12]
at org.apache.sling.event.impl.jobs.queues.JobQueueImpl.access$100(JobQueueImpl.java:60) [org.apache.sling.event:4.2.12]
at org.apache.sling.event.impl.jobs.queues.JobQueueImpl$1.run(JobQueueImpl.java:229) [org.apache.sling.event:4.2.12]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.NoClassDefFoundError: javax/net/SocketFactory
at com.microsoft.sqlserver.jdbc.SocketFinder.getSocketFactory(IOBuffer.java:2636)
at com.microsoft.sqlserver.jdbc.SocketFinder.getConnectedSocket(IOBuffer.java:2687)
at com.microsoft.sqlserver.jdbc.SocketFinder.getDefaultSocket(IOBuffer.java:2674)
at com.microsoft.sqlserver.jdbc.SocketFinder.findSocket(IOBuffer.java:2358)
at com.microsoft.sqlserver.jdbc.TDSChannel.open(IOBuffer.java:672)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2747)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:2418)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:2265)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1291)[!
Bundle information]1
Help is appreciated.

Apache Camel on Karaf with Spring DSL + OSGi

I am new to OSGI world.
Versions:
Karaf: 4.1.0
Camel: 2.18.2
Spring: 4.3.5_RELEASE_1 (Apache Service Mix Bundles)
Ref: Camel-UserForum-on same question
I spent lot of time (even days ) in searching/understanding camel-spring with osgi container. I didn't find a good article for begginer like me which works with some setup or github..etc.
We are having camel-spring application running well. Now we want to move to OSGI environment like Karaf .
We are doing some work on migration to OSGI, we are having severe issues we were able to solve couple of them ,but end up with having below issues:
I dont know where to place camel-spring xml context and route files (previuosly in classpath with NON-OSGi) .So its not loading context getting file not found .
if I put that as below , i know its may be a wrong way
ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext(
new String[] {"file:app-camel-spring.xml" });
Exception:
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://camel.apache.org/schema/spring]
Offending resource: URL [file:app-camel-spring.xml]
Even with Spring DM it doesn't work
Thanks,
Update-1
1. After forums asked me to look into GEMINI Blueprint(GB) I am now checking with GB. But Still I am getting same error with JAXB errors.
I am using now :
Felix:
runtimelib group: 'org.apache.felix', name: 'org.apache.felix.gogo.command', version: '1+'
runtimelib group: 'org.apache.felix', name: 'org.apache.felix.gogo.runtime', version: '1+'
runtimelib group: 'org.apache.felix', name: 'org.apache.felix.gogo.shell', version: '1+'
runtimelib group: 'org.apache.felix', name: 'org.apache.felix.bundlerepository', version: '2+'
runtimelib group: 'org.apache.felix', name: 'org.apache.felix.fileinstall', version: '3+'
runtimelib group: 'org.apache.felix', name: 'org.apache.felix.scr.annotations', version: '1.12.0'
Bundle List:
lb
START LEVEL 1
ID|State |Level|Name
0|Active | 0|System Bundle (5.6.2)|5.6.2
1|Active | 1|Apache Felix Bundle Repository (2.0.8)|2.0.8
2|Active | 1|Apache Felix File Install (3.5.8)|3.5.8
3|Active | 1|Apache Felix Gogo Command (1.0.2)|1.0.2
4|Active | 1|Apache Felix Gogo Runtime (1.0.2)|1.0.2
5|Active | 1|Apache Felix Gogo Shell (1.0.0)|1.0.0
6|Active | 1|file:/E:/Codes/GIT/Repos/Experiments/osgi/felix/bundle/org.apache.felix.scr.annotations-1.12.0.jar (0.0.0)|0.0.0
7|Active | 1|Apache MINA Core (2.0.14)|2.0.14
8|Active | 1|Apache ServiceMix :: Bundles :: spring-context (4.3.1.RELEASE_1)|4.3.1.RELEASE_1
9|Active | 1|Logback Core Module (1.1.1)|1.1.1
10|Active | 1|slf4j-api (1.7.21)|1.7.21
11|Active | 1|camel-mina2 (2.18.0)|2.18.0
12|Active | 1|osgi_testing.test_cons (0.0.4.1488767989530)|0.0.4.1488767989530
13|Active | 1|Logback Classic Module (1.1.1)|1.1.1
14|Active | 1|Old JAXB Runtime (2.2.11)|2.2.11
15|Active | 1|Apache Log4j (1.2.17)|1.2.17
16|Active | 1|gemini-blueprint-core (2.0.9.BUILD-atlassian-m003)|2.0.9.BUILD-atlassian-m003
17|Installed | 1|Apache ServiceMix :: Bundles :: spring-context-support (4.3.1.RELEASE_1)|4.3.1.RELEASE_1
18|Active | 1|camel-core (2.18.0)|2.18.0
19|Active | 1|Apache ServiceMix :: Bundles :: aopalliance (1.0.0.6)|1.0.0.6
20|Active | 1|Apache ServiceMix :: Bundles :: spring-tx (4.3.1.RELEASE_1)|4.3.1.RELEASE_1
21|Active | 1|Apache ServiceMix :: Bundles :: spring-core (4.3.1.RELEASE_1)|4.3.1.RELEASE_1
22|Active | 1|gemini-blueprint-extender (2.0.9.BUILD-atlassian-m003)|2.0.9.BUILD-atlassian-m003
23|Active | 1|Apache ServiceMix :: Bundles :: spring-beans (4.3.1.RELEASE_1)|4.3.1.RELEASE_1
24|Active | 1|osgi_testing.test_impl2 (0.0.1.1488767989534)|0.0.1.1488767989534
25|Active | 1|camel-spring (2.18.0)|2.18.0
26|Active | 1|Apache Commons Logging (1.2.0)|1.2.0
27|Active | 1|test_api (0.0.2.1488767989527)|0.0.2.1488767989527
28|Active | 1|Apache Commons IO (2.5.0)|2.5.0
29|Active | 1|Old JAXB Core (2.2.11)|2.2.11
30|Active | 1|osgi_testing.test_impl3 (0.0.1.1488767989536)|0.0.1.1488767989536
31|Active | 1|Apache ServiceMix :: Bundles :: spring-expression (4.3.1.RELEASE_1)|4.3.1.RELEASE_1
32|Active | 1|Apache ServiceMix :: Bundles :: spring-aop (4.3.1.RELEASE_1)|4.3.1.RELEASE_1
33|Active | 1|gemini-blueprint-io (2.0.9.BUILD-atlassian-m003)|2.0.9.BUILD-atlassian-m003
34|Active | 1|osgi_testing.test_impl (0.0.1.1488767989532)|0.0.1.1488767989532
g! start 17
org.osgi.framework.BundleException: Unable to resolve org.apache.servicemix.bundles.spring-context-support [17](R 17.0): missing requirement
[org.apache.servicemix.bundles.spring-context-support [17](R 17.0)] osgi.wiring.package; (osgi.wiring.package=com.github.benmanes.caffeine.cache)
Unresolved requirements: [[org.apache.servicemix.bundles.spring-context-support [17](R 17.0)] osgi.wiring.package;
(osgi.wiring.package=com.github.benmanes.caffeine.cache)]
10:41:25.836 [fileinstall-load] ERROR com.tp.boot.ApplicationBootActivator - ERROR::
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://camel.apache.org/schema/spring]
Offending resource: URL [file:app-camel-spring.xml]
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:70) ~[na:na]
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85) ~[na:na]
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:80) ~[na:na]
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.error(BeanDefinitionParserDelegate.java:301) ~[na:na]
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1408) ~[na:na]
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1401) ~[na:na]
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:172) ~[na:na]
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:142) ~[na:na]
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:94) ~[na:na]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:508) ~[na:na]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:392) ~[na:na]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336) ~[na:na]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304) ~[na:na]
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181) ~[na:na]
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217) ~[na:na]
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188) ~[na:na]
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:252) ~[na:na]
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127) ~[na:na]
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93) ~[na:na]
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129) ~[na:na]
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:612) ~[na:na]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:513) ~[na:na]
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) ~[na:na]
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93) ~[na:na]
at com.tp.boot.ApplicationBootActivator.start(ApplicationBootActivator.java:54) ~[na:na]
at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:697) ~[felix.jar:na]
at org.apache.felix.framework.Felix.activateBundle(Felix.java:2238) ~[felix.jar:na]
at org.apache.felix.framework.Felix.startBundle(Felix.java:2144) ~[felix.jar:na]
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998) ~[felix.jar:na]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1253) ~[na:na]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1225) ~[na:na]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:512) ~[na:na]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:361) ~[na:na]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:312) ~[na:na]
10:41:25.870 [fileinstall-load] DEBUG org.apache.camel.impl.osgi.Activator - Bundle started: osgi_testing.test_api
10:41:25.903 [fileinstall-load] DEBUG org.apache.camel.impl.osgi.Activator - Bundle started: org.apache.mina.core
10:41:25.915 [fileinstall-load] DEBUG org.apache.camel.impl.osgi.Activator - Bundle started: ch.qos.logback.core
10:41:25.928 [fileinstall-load] DEBUG org.apache.camel.impl.osgi.Activator - Bundle started: slf4j.api
10:41:25.954 [fileinstall-load] DEBUG org.apache.camel.impl.osgi.Activator - Bundle started: com.sun.xml.bind.jaxb-core
10:41:25.990 [fileinstall-load] DEBUG org.apache.camel.impl.osgi.Activator - Bundle started: org.eclipse.gemini.blueprint.core
10:41:26.022 [fileinstall-load] DEBUG com.tp.device.rba.Activator - Started [osgi_testing.test_impl3]
10:41:26.035 [fileinstall-load] DEBUG org.apache.camel.impl.osgi.Activator - Bundle started: osgi_testing.test_impl3
10:41:26.096 [fileinstall-load] DEBUG org.apache.camel.impl.osgi.Activator - Bundle started: com.sun.xml.bind.jaxb-impl
10:41:26.123 [fileinstall-load] DEBUG com.tp.app.cons.Activator - start CONS
10:41:26.131 [fileinstall-load] DEBUG com.tp.app.cons.Activator - Device Bundle Tracker - started
10:41:26.139 [fileinstall-load] DEBUG com.tp.app.cons.DeviceHub - Device [rbaonguard] ClassName [com.tp.device.rba.RBADeviceImpl] Added
10:41:26.188 [fileinstall-load] DEBUG com.tp.app.cons.DeviceHub - Written to File [Config/devices]
10:41:26.195 [fileinstall-load] DEBUG com.tp.app.cons.DeviceServiceTracker - Service Reference- Added Device [rbaonguard] Device Class [com.tp.device.rba.RBADeviceImpl]
10:41:26.204 [fileinstall-load] DEBUG com.tp.app.cons.DeviceHub - Device [rbavoltagetep2] ClassName [com.tp.device.rba.RBADeviceImpl] Added
10:41:26.218 [fileinstall-load] DEBUG com.tp.app.cons.DeviceHub - Written to File [Config/devices]
10:41:26.225 [fileinstall-load] DEBUG com.tp.app.cons.DeviceServiceTracker - Service Reference- Added Device [rbavoltagetep2] Device Class [com.tp.device.rba.RBADeviceImpl]
10:41:26.240 [fileinstall-load] DEBUG com.tp.app.cons.DeviceHub - Device [xpi] ClassName [com.tp.device.xpi.XPIDeviceImpl] Added
10:41:26.266 [fileinstall-load] DEBUG com.tp.app.cons.DeviceHub - Written to File [Config/devices]
10:41:26.271 [fileinstall-load] DEBUG com.tp.app.cons.DeviceServiceTracker - Service Reference- Added Device [xpi] Device Class [com.tp.device.xpi.XPIDeviceImpl]
10:41:26.278 [fileinstall-load] DEBUG com.tp.app.cons.Activator - Device Service Tracker - started
10:41:26.283 [fileinstall-load] DEBUG org.apache.camel.impl.osgi.Activator - Bundle started: osgi_testing.test_cons
10:41:26.295 [fileinstall-load] DEBUG org.apache.camel.impl.osgi.Activator - Bundle started: org.apache.servicemix.bundles.spring-tx
10:41:26.832 [EclipseGeminiBlueprintExtenderThread-1] INFO o.e.g.b.c.s.AbstractDelegatedExecutionApplicationContext - About to begin startRefresh for osgi_testing.test_api [27]
10:41:26.985 [fileinstall-load] DEBUG org.apache.camel.impl.osgi.Activator - Bundle started: org.eclipse.gemini.blueprint.extender
10:41:27.000 [EclipseGeminiBlueprintExtenderThread-2] INFO o.e.g.b.c.s.AbstractDelegatedExecutionApplicationContext - About to begin startRefresh for osgi_testing.test_api [27]
10:41:27.336 [fileinstall-load] DEBUG org.apache.camel.impl.osgi.Activator - Bundle started: org.apache.servicemix.bundles.aopalliance
10:41:27.455 [fileinstall-load] DEBUG org.apache.camel.impl.osgi.Activator - Bundle started: ch.qos.logback.classic
10:41:27.559 [EclipseGeminiBlueprintExtenderThread-1] DEBUG o.a.c.s.h.CamelNamespaceHandler - Using org.apache.camel.spring.CamelContextFactoryBean as CamelContextBeanDefinitionParser
10:41:27.561 [EclipseGeminiBlueprintExtenderThread-2] DEBUG o.a.c.s.h.CamelNamespaceHandler - Using org.apache.camel.spring.CamelContextFactoryBean as CamelContextBeanDefinitionParser
10:41:27.762 [EclipseGeminiBlueprintExtenderThread-2] DEBUG o.e.g.b.c.s.AbstractDelegatedExecutionApplicationContext - Pre refresh error for osgi_testing.test_api [27]
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to create the JAXB binder; nested exception is javax.xml.bind.JAXBException: Provider com.sun.xml.internal.bind.v2.ContextFactory could not be instantiated: javax.xml.bind.JAXBException: "org.apache.camel.model.config" doesnt contain ObjectFactory.class or jaxb.index
- with linked exception:
[javax.xml.bind.JAXBException: "org.apache.camel.model.config" doesnt contain ObjectFactory.class or jaxb.index]
at org.apache.camel.spring.handler.CamelNamespaceHandler$CamelContextBeanDefinitionParser.doParse(CamelNamespaceHandler.java:380) ~[na:na]
at org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser.parseInternal(AbstractSingleBeanDefinitionParser.java:85) ~[na:na]
at org.springframework.beans.factory.xml.AbstractBeanDefinitionParser.parse(AbstractBeanDefinitionParser.java:61) ~[na:na]
at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:74) ~[na:na]
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1411) ~[na:na]
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1401) ~[na:na]
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:172) ~[na:na]
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:142) ~[na:na]
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:94) ~[na:na]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:508) ~[na:na]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:392) ~[na:na]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336) ~[na:na]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304) ~[na:na]
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181) ~[na:na]
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217) ~[na:na]
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188) ~[na:na]
at org.eclipse.gemini.blueprint.context.support.OsgiBundleXmlApplicationContext.loadBeanDefinitions(OsgiBundleXmlApplicationContext.java:170) ~[na:na]
at org.eclipse.gemini.blueprint.context.support.OsgiBundleXmlApplicationContext.loadBeanDefinitions(OsgiBundleXmlApplicationContext.java:140) ~[na:na]
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129) ~[na:na]
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:612) ~[na:na]
at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.access$800(AbstractDelegatedExecutionApplicationContext.java:63) ~[na:na]
at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext$3.run(AbstractDelegatedExecutionApplicationContext.java:249) ~[na:na]
at org.eclipse.gemini.blueprint.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85) ~[na:na]
at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.startRefresh(AbstractDelegatedExecutionApplicationContext.java:224) ~[na:na]
at org.eclipse.gemini.blueprint.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.stageOne(DependencyWaiterApplicationContextExecutor.java:224) ~[na:na]
at org.eclipse.gemini.blueprint.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.refresh(DependencyWaiterApplicationContextExecutor.java:177) ~[na:na]
at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.refresh(AbstractDelegatedExecutionApplicationContext.java:159) ~[na:na]
at org.eclipse.gemini.blueprint.extender.internal.activator.LifecycleManager$1.run(LifecycleManager.java:207) ~[na:na]
at java.lang.Thread.run(Unknown Source) ~[na:1.8.0_102]
Caused by: javax.xml.bind.JAXBException: Provider com.sun.xml.internal.bind.v2.ContextFactory could not be instantiated: javax.xml.bind.JAXBException: "org.apache.camel.model.config" doesnt contain ObjectFactory.class or jaxb.index
at javax.xml.bind.ContextFinder.newInstance(Unknown Source) ~[na:1.8.0_102]
at javax.xml.bind.ContextFinder.find(Unknown Source) ~[na:1.8.0_102]
at javax.xml.bind.JAXBContext.newInstance(Unknown Source) ~[na:1.8.0_102]
at javax.xml.bind.JAXBContext.newInstance(Unknown Source) ~[na:1.8.0_102]
at org.apache.camel.impl.DefaultModelJAXBContextFactory.newJAXBContext(DefaultModelJAXBContextFactory.java:31) ~[na:na]
at org.apache.camel.spring.handler.CamelNamespaceHandler.getJaxbContext(CamelNamespaceHandler.java:217) ~[na:na]
at org.apache.camel.spring.handler.CamelNamespaceHandler$CamelContextBeanDefinitionParser.doParse(CamelNamespaceHandler.java:378) ~[na:na]
... 28 common frames omitted
Caused by: javax.xml.bind.JAXBException: "org.apache.camel.model.config" doesnt contain ObjectFactory.class or jaxb.index
at com.sun.xml.internal.bind.v2.ContextFactory.createContext(Unknown Source) ~[na:1.8.0_102]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_102]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_102]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_102]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_102]
at javax.xml.bind.ContextFinder.newInstance(Unknown Source) ~[na:1.8.0_102]
... 35 common frames omitted
10:41:27.770 [EclipseGeminiBlueprintExtenderThread-1] DEBUG o.e.g.b.c.s.AbstractDelegatedExecutionApplicationContext - Pre refresh error for osgi_testing.test_api [27]
Use Apache Karaf 4.0.8 as 4.1.0 is buggy and not supported for that Camel release.
And the spring XML files should be placeholder in the folder as shown in that example, eg META-INF/spring.
But mind that Spring DM is deprecated and dead. So its highly recommended to use OSGi Blueprint instead.
And in the future Karaf will have some kind of spring XML to blueprint XML auto converter so it can run spring xml files as if they are blueprints. But for more details on that ask on the Karaf community.
[caused by: Unable to resolve camel-spring-dm/2.18.2: missing requirement
[camel-spring-dm/2.18.2] osgi.identity; osgi.identity=spring-dm;
The error is pretty clear, the feature resolver can't find the spring-dm feature, you need to install it first
feature:install spring-dm
If i'm correct, karaf dropped the support to spring-dm, so the feature may not be available, you will need to install spring-dm manually. But like was already said, spring-dm is way deprecated and a very buggy way to use spring at an OSGi enviroment. You should move to aries blueprint, or if spring is really indispensable, you should use gemini-blueprint, it's a blueprint implementation compatible with Spring 4.2.x .
https://eclipse.org/gemini/blueprint/
http://www.eclipse.org/gemini/blueprint/documentation/migration/
Finally moving out of Camel-Spring with OSGi. Its a a nightmare combination to try. Lots of issues with this combination.
Now Trying Camel+Blueprint+Karaf.
Thanks for all your support.
With Karaf 4.2.3, Camel 2.22.3 and Spring 5.1 it works just like with old spring-dm and Spring 3.2.
It worked for me for an old integration crafted years ago for Spring 3.2 and Spring DM using:
services/references, tested with referencing transaction manager
compendium properties
#Transactional annotation on bean's method which also correctly created transaction aspect
Above proves it is doable and should allow most of the old integrations to work almost out of the box.
There are possible benefits also over blueprint- like being able to use Spring Data (not tested yet) for example with mongo, which I am also looking at.
Obviously, you need to recompile your project with new dependencies to get your manifest right.
It works thanks to what Claus has mentioned- the Spring to Blueprint compatibility layer.
The feature providing this functionality is called "aries-blueprint-spring".
I am not using it yet in real life, but I am doing research on how to migrate our Spring integrations from Karaf 2 (Fuse 6.3) to Karaf 4 (Fuse 7.2).
I am not personally big fan of blueprint, as it has some annoying limitations especially if you have been using Spring for more than a decade like me.
The compatibility layer is not perfect yet as:
It has some non-critical bugs- like if you restart the bundle with camel route, it will fail to start with some "template" bean registration error, which I am sure will be addressed by the community at some point.
This seems to be related to this issue done decade ago: https://issues.apache.org/jira/browse/CAMEL-1899 where Camel is adding some extra beans which was created to improve unit testing.
You can workaround it until fixed by adding to your Spring Context:
<bean id="template" class="java.lang.String"/>
<bean id="fluentTemplate" class="java.lang.String"/>
<bean id="consumerTemplate" class="java.lang.String"/>
I cannot get spring deployer to work- deploying raw Spring XMLs as bundles, like as we use for JDBC connection pool for bundles. But this is a niche approach- a nice to have.
Also, there are problems with ActiveMQ 5 client which currently works only with Spring 4, but there is a solution for that from Red Hat as they have their own version of ActiveMQ client, which seems to work with Spring 5.
With all the above, you should be sorted and happy to use Spring 5 with Camel in Karaf 4.2.3.
Update
Sadly community decided to kill camel spring support for karaf.
Camel 3 spring component does not work anymore and fails on class and resources loading.

Unable to install KAR containing camel-spring: spring beans missing

I've built an application bundled in an OSGi JAR package and now I'm trying to create a KAR file to easy deployment to Apache Karaf 4.0.8.
When I drop the KAR file there's a warning message complaining that it's impossible to resolve camel-spring due to the missing org.springframework.beans requirement.
2017-01-18 19:07:12,239 | WARN | raf-4.0.8/deploy | KarServiceImpl | 36 -
org.apache.karaf.kar.core - 4.0.8 | Unable to install Kar feature
interfacturas-kar/1.0.0.SNAPSHOT
org.osgi.service.resolver.ResolutionException: Unable to resolve root:
missing requirement [root] osgi.identity;
osgi.identity=interfacturas-kar;
type=karaf.feature;
version="[1.0.0.SNAPSHOT,1.0.0.SNAPSHOT]";
filter:="(&(osgi.identity=interfacturas-kar)
(type=karaf.feature(version>=1.0.0.SNAPSHOT)
(version<=1.0.0.SNAPSHOT))"
[caused by: Unable to resolve interfacturas-kar/1.0.0.SNAPSHOT:
missing requirement [interfacturas-kar/1.0.0.SNAPSHOT] osgi.identity;
osgi.identity=org.apache.camel.camel-spring;
type=osgi.bundle;
version="[2.17.0.redhat-630187,2.17.0.redhat-630187]";
resolution:=mandatory
[caused by: Unable to resolve org.apache.camel.camel-spring/2.17.0.redhat-630187:
missing requirement [org.apache.camel.camel-spring/2.17.0.redhat-630187]
osgi.wiring.package;
filter:="(&(osgi.wiring.package=org.springframework.beans)
(version>=3.2.0)(!(version>=4.0.0)))"]]
I cannot figure why this is happening! The kar file does contain spring-beans JAR file of an appropriate version:
$ unzip -l interfacturas-kar-1.0.0-SNAPSHOT.kar
...
614354 2017-01-11 19:07 repository/org/springframework/spring-beans/3.2.16.RELEASE/spring-beans-3.2.16.RELEASE.jar
...
The KAR file and its associated feature XML file is completely generated by karaf-maven-plugin, and it also lists the spring-beans dependency:
<bundle>wrap:mvn:org.springframework/spring-beans/3.2.16.RELEASE</bundle>
along with other spring related resources.
Any has some idea how to fix this? Or why is it happening?
BTW, camel-spring actually comes as a dependency of camel-cxf; I'm using blueprint for defining the routes.

"NoClassDefFoundError: GenericApplicationListener" when switching from Spring Boot 1.3.0M1 to 1.3.0M2

In my Spring Starter created Soring Boot application I switched from Spring Boot 1.3.0M1 to 1.3.0M2. When trying to start the application (either from STS 3.7.0 or via spring-boot:run at the command line) I get the following exception:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run(AbstractRunMojo.java:435)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalArgumentException: Cannot instantiate interface org.springframework.context.ApplicationListener : org.springframework.boot.logging.ClasspathLoggingApplicationListener
at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:385)
at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:362)
at org.springframework.boot.SpringApplication.initialize(SpringApplication.java:231)
at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:206)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:971)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:960)
at com.daimler.daivb.services.application.dummyservice.DummyServiceApplication.main(DummyServiceApplication.java:18)
... 6 more
Caused by: java.lang.NoClassDefFoundError: org/springframework/context/event/GenericApplicationListener
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:250)
at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:378)
... 12 more
Caused by: java.lang.ClassNotFoundException: org.springframework.context.event.GenericApplicationListener
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 25 more
The mentioned class has been added in spring-context version 4.2.0 but when looking at the dependency tree I can see that Spring Boot 1.3.0M2 still depends on spring-context 4.1.6:
[INFO] com.company.services.application:dummyservice:war:0.0.1-SNAPSHOT
[INFO] +- org.springframework.boot:spring-boot-devtools:jar:1.3.0.M2:compile
[INFO] | +- org.springframework.boot:spring-boot:jar:1.3.0.M2:compile
[INFO] | | \- org.springframework:spring-context:jar:4.1.6.RELEASE:compile
[INFO] | \- org.springframework.boot:spring-boot-autoconfigure:jar:1.3.0.M2:compile
[INFO] | \- org.yaml:snakeyaml:jar:1.15:compile
Spring Boot manages a bunch of dependencies for you and allows you to add them without specifying the version. Spring Boot is obviously based on Spring Framework and uses the latest and greatest so you should avoid at all cost to fix the spring framework version to use yourself.
If you have upgraded to a newer version (to include a bug fix or something) make sure to remove the override before you upgrade Spring Boot as the new version it requires may be incompatible with your override.
If you are using other projects that also provide a dependency management on Spring Framework (such as Spring Cloud) make sure that the dependency management of Spring Boot takes precedence. With Maven, make sure to add the spring-boot-dependencies BOM as the first entry in the <dependenciesManagement> section.
I had the same problem because my POM had a properties section with a <spring.version> tag copied from another project.
Remove any <abc.version> tag in your properties section that may conflict with Spring Boot libraries.
Caused by: java.lang.NoClassDefFoundError: org/springframework/context/event/GenericApplicationListener
From the above error, application is unable to find the class defined from the jar dependencies. GenericApplicationListener is added from spring version 4.2.
Upgrade your Spring version to 4.2 and recheck.

maven-pax-provision + equinox: java.lang.Long cannot be cast to java.lang.String

i am experiencing some strang, non reproducible, behavior.
I am developing an OSGi Application using the maven-bundle-plugin and the maven-pax-plugin to run it in Apache Felix and Eclipse Equinox.
Since today i sometimes get the following error when i try to start or stop a bundle e.g.
lb works fine
Output (excerpt):
0|Active | 0|OSGi System Bundle (3.8.1.v20120830-144521)
1|Active | 1|Console plug-in (1.0.0.v20120522-1841)
2|Active | 1|Apache Felix Gogo Command (0.12.0)
3|Active | 1|Apache Felix Gogo Runtime (0.10.0)
4|Active | 1|Apache Felix Gogo Shell (0.10.0)
5|Active | 5|OSGi R4 Core Bundle (4.1.0)
6|Active | 5|slf4j-api (1.6.6)
7|Active | 5|Logback Core Module (1.0.7)
8|Active | 5|Logback Classic Module (1.0.7)
but when i try stop 6 for example i get the following exception:
g! stop 6
java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String
at org.eclipse.equinox.console.commands.EquinoxCommandsConverter.convert(EquinoxCommandsConverter.java:61)
at org.apache.felix.gogo.runtime.CommandProcessorImpl.convert(CommandProcessorImpl.java:254)
at org.apache.felix.gogo.runtime.CommandSessionImpl.convert(CommandSessionImpl.java:374)
at org.apache.felix.gogo.runtime.Reflective.coerce(Reflective.java:389)
at org.apache.felix.gogo.runtime.Reflective.coerce(Reflective.java:310)
at org.apache.felix.gogo.runtime.Reflective.invoke(Reflective.java:110)
at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:82)
at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:477)
at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:403)
at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)
at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:89)
at org.apache.felix.gogo.shell.Console.run(Console.java:62)
at org.apache.felix.gogo.shell.Shell.console(Shell.java:203)
at org.apache.felix.gogo.shell.Shell.gosh(Shell.java:128)
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:601)
at org.apache.felix.gogo.runtime.Reflective.invoke(Reflective.java:137)
at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:82)
at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:477)
at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:403)
at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)
at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:89)
at org.apache.felix.gogo.shell.Activator.run(Activator.java:75)
at java.lang.Thread.run(Thread.java:722)
This happens with every Bundle
Everything works fine in Felix tough.
Any Ideas?
It's an error inside equinox commands bundle. It cannot convert type correctly. gogo runtime prints printStackTrace and executes the command correctly with felix commands.

Resources