Hi all,
I'm trying to run an unmarshalling example, using maven with maven-hyperjaxb3-plugin and maven-bundle-plugin, which is supposed to run on Apache Felix.
With unit testing everything works find. But deploy as OSGI bundle into Felix, I get the following error :
org.osgi.framework.BundleException: Activator start error.
at org.apache.felix.framework.Felix._startBundle(Felix.java:1654)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1544)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:371)
at org.apache.felix.shell.impl.StartCommandImpl.execute(StartCommandImpl.java:82)
at org.apache.felix.shell.impl.Activator$ShellServiceImpl.executeCommand(Activator.java:276)
at org.apache.felix.shell.tui.Activator$ShellTuiRunnable.run(Activator.java:167)
at java.lang.Thread.run(Thread.java:595)
Caused by: javax.xml.bind.JAXBException: Unable to create context
- with linked exception:
[java.lang.reflect.InvocationTargetException]
at javax.xml.bind.ContextFinder.find(ContextFinder.java:61)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:77)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:73)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:69)
at org.mobyview.jaxb.Loader.newContext(Loader.java:38)
at org.mobyview.jaxb.Loader.unmarshallProcess(Loader.java:42)
at org.mobyview.jaxb.AppTestActivator.start(AppTestActivator.java:24)
at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:591)
at org.apache.felix.framework.Felix._startBundle(Felix.java:1610)
... 6 more
Caused by: java.lang.reflect.InvocationTargetException
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:585)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:59)
... 14 more
Caused by: javax.xml.bind.JAXBException: "org.mobyview.bibliotheque" doesnt contain ObjectFactory.class or jaxb.index
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:183)
... 19 more
javax.xml.bind.JAXBException: Unable to create context
- with linked exception:
[java.lang.reflect.InvocationTargetException]
This message is caused when the service is creating a new JAXBContext.
JAXBContext.newInstance("org.mobyview.bibliotheque")
My MANIFEST file is the following:
Manifest-Version: 1.0
Built-By: sommavilla
Created-By: Apache Maven Bundle Plugin
Bundle-Activator: org.mobyview.jaxb.AppTestActivator
Import-Package: org.mobyview.bibliotheque,
com.sun.xml.bind.v2,javax.persistence, javax.xml
.bind, javax.xml.bind.annotation,javax.xml.namespace,
org.apache.commons.lang.builder,org.jvnet.jaxb2_commons.lang,
org.jvnet.jaxb2_commons.lang.builder, org.osgi.framework
Bnd-LastModified: 1219528339484
Export-Package: org.mobyview.jaxb;uses:="org.mobyview",org.mobyview
Bundle-Version: 1.0.0.SNAPSHOT
Bundle-Name: Mobyview Test JAXB2
Class-Path: .,lib/commons-lang-2.2.jar
Bundle-ClassPath: .,lib/commons-lang-2.2.jar
Build-Jdk: 1.5.0_15
Bundle-ManifestVersion: 2
Bundle-SymbolicName: mobyview-test-jaxb2
Eclipse-RegisterBuddy: mobyview-test-jaxb2
Bundle-RegisterBuddy: mobyview-test-jaxb2
Eclipse-BuddyPolicy: registered
Bundle-BuddyPolicy: registered
Tool: Bnd-0.0.255
While the error is only produce when package as a bundle and deployed.
After investigation, I've found that, the class loader concept isn't the same as a simple Java application. The client bundle must import the library package otherwise the library is independent of client and it can't see resource file.
Many libraries such as Hibernate, JPA and JAXB use the same thing with the class forName concept to load class with reflection, and due to invisibility of client to such libraries, the ClassNotFound exception is thrown.
Am using Java 5, JAXB 2.2 and Apache Felix 1.0.4.
Can anyone help me out.. Thanks in Advance
Fabrice