-
1. Re: JAXB and the system bundle
akoledzhikov Mar 8, 2012 4:23 AM (in response to akoledzhikov)Sorry for the double post, but since getting the JAXB to work properly in osgi environment is really important to me (they've threatened to fire me if I don't solve the problem until the end of the week, and in that case I'll have no choice but to sell my women and children into slavery and become a mule for the local drug lord ).
I've tried to deploy a separate bundle containing the jaxb implementation, but since the system bundle starts first, almost everything else loads the package from it, leading to the result mentioned in the previous post. Any idea how I can modify the exports of the system bundle and remove javax.xml.bind from them?
-
2. Re: JAXB and the system bundle
akoledzhikov Mar 28, 2012 4:19 AM (in response to akoledzhikov)In case someone is interested, you can modify the modules included in the system bundle by adding the org.jboss.osgi.system.modules.extra property to the osgi subsystem. In it you can place a comma-separated list of the modules you need (in my case, javax.xml.bind.api). You can also modify the exports of the bundle by setting org.jboss.osgi.system.packages - please note that this will override the default exports, so make sure that you list everything you need there.
-
3. Re: JAXB and the system bundle
xavier.courangon Sep 6, 2012 11:52 AM (in response to akoledzhikov)Hi Alexander,
I've just read your interesting post and met the same issue.
We are upgrading from JBoss 7.1.0CR1b to 7.1.1.Final and we have this issue too : ClassNotFound javax.xml.bind.JAXBContext
This exception was not raised with 7.1.0.CR1b (but raised for you with the Final release... ???).
We've tryed to add the org.jboss.osgi.system.modules.extra property
<property name="org.jboss.osgi.system.modules.extra">
javax.xml.bind
</property>
without success
17:34:51,728 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-6) MSC00001: Failed to start service jbosgi.AutoInstallProvider.COMPLETE: org.jboss.msc.service.StartException in service jbosgi.AutoInstallProvider.COMPLETE: Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1767) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.7.0_07]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.7.0_07]
at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_07]
Caused by: java.lang.IllegalStateException: org.jboss.modules.ModuleNotFoundException: Module javax.xml.bind:main is not found in local module loader @71fd20 (r
oots: C:\jboss-as-7.1.1.Final\modules)
Have you moved to 7.1.1.Final (or eap) and have you met issues ?
Thanks
-
4. Re: JAXB and the system bundle
mreasy Sep 7, 2012 4:08 AM (in response to xavier.courangon)Hi Xavier,
Alexander and me are working on the same product, so I can answer your question regarding the version with: Yes, we moved to 7.1.1.Final in the meantime.
The following os the configuration we use atm and this works for us. You may need less entries (e.g. not org.apache.santuario), but I post it completely here:
<properties> <property name="org.jboss.osgi.system.modules.extra"> javax.xml.bind.api,org.apache.santuario.xmlsec,javax.xml.soap.api </property> <property name="org.osgi.framework.system.packages.extra"> javax.activation;version=1.1.1, javax.xml.bind;version=2.2, sun.security.provider;version=1.0, com.sun.org.apache.xerces.internal.dom;version=1.0, com.sun.org.apache.xerces.internal.jaxp;version=1.0, com.sun.org.apache.xerces.internal.util;version=1.0, </property> </properties>
-
5. Re: JAXB and the system bundle
xavier.courangon Sep 7, 2012 4:45 AM (in response to mreasy)Hi Rico,
It is a mistake from us !!
Our org.jboss.osgi.system.modules.extra property is not correct : javax.xml.bind -> javax.xml.bind.api (it is expected the module name, not the exported package).
Thank you very must for your help, really.
By the way, do you know why these packages (javax.xml.bind, ...) seem to be exported by system.bundle and correctly imported by application bundles ??
Is it an inducement to use JAXB as a service ?
-
6. Re: JAXB and the system bundle
sivaram123 Sep 12, 2012 8:47 AM (in response to mreasy)Hi Rico,
I am facing the same problem while creating the JAXB context instance in a osgi bundle in jboss as 7.1.1. I have made changes as you mentioned above in the standalone.xml. But now i am getting the following exception while creating the JAXBContext instance
java.lang.Error: Failed to initialize JAXP 1.3 DatatypeFactory class.
at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl.init(RuntimeBuiltinLeafInfoImpl.java:905)
at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl.<clinit>(RuntimeBuiltinLeafInfoImpl.java:899)
at com.sun.xml.bind.v2.model.impl.RuntimeTypeInfoSetImpl.<init>(RuntimeTypeInfoSetImpl.java:65)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.createTypeInfoSet(RuntimeModelBuilder.java:133)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.createTypeInfoSet(RuntimeModelBuilder.java:85)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.<init>(ModelBuilder.java:156)
Caused by: javax.xml.datatype.DatatypeConfigurationException: Provider __redirected.__DatatypeFactory not found
at javax.xml.datatype.DatatypeFactory.newInstance(DatatypeFactory.java:137) [rt.jar:1.6.0_26]
at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl.init(RuntimeBuiltinLeafInfoImpl.java:903)
... 33 more
Caused by: java.lang.ClassNotFoundException: __redirected/__DatatypeFactory
at java.lang.Class.forName0(Native Method) [rt.jar:1.6.0_26]
at java.lang.Class.forName(Class.java:247) [rt.jar:1.6.0_26]
Do i need to add any configuration to resolve this error. Please suggest me if you came around this error.
Thanks in advance.
-
7. Re: JAXB and the system bundle
mreasy Sep 12, 2012 8:54 AM (in response to sivaram123)Hi sivaram,
The error you get is known to me, however is not directly related to the configuration as far as I can say.
Please check your code, whether you are doing the JAXBContext.newInstance() call inside a static-block or in a method called via a static initializer. Removing any access to JAXBContext during such static initialization resolved the issue for us. Instead you can use initialization on access or on object-creation.
The root cause is not really clear to me, but seems to be related to a race-condition during boot-phase, so it can happen that the needed resources are not yet available.
Best Regards,
Rico
-
8. Re: JAXB and the system bundle
sivaram123 Sep 12, 2012 11:11 AM (in response to mreasy)Hi Rico,
Thankyou for the response. I have created a staic jaxbcontext variable now i have removed the static modifer. But now i am getting the following exception.
java.lang.NullPointerException
20:37:29,844 ERROR [stderr] (MSC service thread 1-1) at javax.xml.bind.ContextFinder.find(ContextFinder.java:279)
20:37:29,844 ERROR [stderr] (MSC service thread 1-1) at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:412)
20:37:29,845 ERROR [stderr] (MSC service thread 1-1) at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:375)
20:37:29,845 ERROR [stderr] (MSC service thread 1-1) at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:279)
20:37:29,846 ERROR [stderr] (MSC service thread 1-1) at com.cultagent.gr.hotelde.JaxbUtil.getJaxb(JaxbUtil.java:33)
20:37:29,846 ERROR [stderr] (MSC service thread 1-1) at com.cultagent.gr.hotelde.JaxbUtil.getUnmarshaller(JaxbUtil.java:47)
20:37:29,847 ERROR [stderr] (MSC service thread 1-1) at com.cultagent.gr.hotelde.Activator.start(Activator.java:25)
20:37:29,847 ERROR [stderr] (MSC service thread 1-1) at org.jboss.osgi.framework.internal.HostBundleState.transitionToActive(HostBundleState.java:300)
20:37:29,848 ERROR [stderr] (MSC service thread 1-1) at org.jboss.osgi.framework.internal.HostBundleState.startInternal(HostBundleState.java:223)
20:37:29,848 ERROR [stderr] (MSC service thread 1-1) at org.jboss.osgi.framework.internal.AbstractBundleState.start(AbstractBundleState.java:494)
20:37:29,849 ERROR [stderr] (MSC service thread 1-1) at org.jboss.as.osgi.deployment.BundleStartTracker$1.processService(BundleStartTracker.java:144)
20:37:29,849 ERROR [stderr] (MSC service thread 1-1) at org.jboss.as.osgi.deployment.BundleStartTracker$1.transition(BundleStartTracker.java:119)
20:37:29,849 ERROR [stderr] (MSC service thread 1-1) at org.jboss.msc.service.ServiceControllerImpl.invokeListener(ServiceControllerImpl.java:1416)
20:37:29,850 ERROR [stderr] (MSC service thread 1-1) at org.jboss.msc.service.ServiceControllerImpl.access$2700(ServiceControllerImpl.java:49)
20:37:29,850 ERROR [stderr] (MSC service thread 1-1) at org.jboss.msc.service.ServiceControllerImpl$ListenerTask.run(ServiceControllerImpl.java:1954)
20:37:29,851 ERROR [stderr] (MSC service thread 1-1) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
20:37:29,851 ERROR [stderr] (MSC service thread 1-1) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
20:37:29,852 ERROR [stderr] (MSC service thread 1-1) at java.lang.Thread.run(Thread.java:662)
The code is running perfectly in the eclipse osgi contaner.
Kind Regards,
Siva Ram.
-
9. Re: JAXB and the system bundle
akoledzhikov Sep 14, 2012 3:16 AM (in response to sivaram123)Hi Siva,
Actually, just making the static variable non-static won't help. You have to postpone the creation of JAXB context until after the bundle has finished starting (when your Activator has finished its job), so any jaxb objects will have to be lazily initialized (if possible).
If this is not possible (or will proove too much hassle), you can try passing this property to the jboss' jvm : "-Dcom.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize=true", but it is not guaranteed to work (especially if you have plenty of bundles using jaxb objects in their activators).
Btw, do you get this error every time you start the bundle or only occasionally?
Best regards,
Alex
-
10. Re: JAXB and the system bundle
sivaram123 Sep 17, 2012 8:01 AM (in response to akoledzhikov)Hi Alex,
Thank You for your response. I have tried in first way specified by you. But still i am getting the following exception:
java.lang.NullPointerException
15:32:06,848 ERROR [stderr] (Thread-69) at javax.xml.bind.ContextFinder.find(ContextFinder.java:279)
15:32:06,848 ERROR [stderr] (Thread-69) at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:412)
15:32:06,849 ERROR [stderr] (Thread-69) at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:375)
15:32:06,850 ERROR [stderr] (Thread-69) at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:279)
15:32:06,851 ERROR [stderr] (Thread-69) at com.helloworld.JContext.getJContext(JContext.java:12)
15:32:06,852 ERROR [stderr] (Thread-69) at jboss_as_helloworld.osgi.Activator$1.run(Activator.java:29)
15:32:06,852 ERROR [stderr] (Thread-69) at java.lang.Thread.run(Thread.java:662).
Yes i am getting this exception every time when the bundle is started. Not getting any way to resolve this error . Can you spot where i am doing the mistake. I am attaching the code and jar files here.
Kind Regards,
Siva Ram.
-
JActivator.java.zip 613 bytes
-
HelloWorldActivator.java.zip 427 bytes
-
JContext.java.zip 363 bytes
-
11. Re: JAXB and the system bundle
akoledzhikov Sep 18, 2012 8:50 AM (in response to sivaram123)Hello,
Still not sure if this will help, but when you create the JAXB context, can you pass the classloader of the bundle which contains the jaxb objects as a second argument to the method invocation? I think the problem is that unless provided with specific classloader, JAXB uses the current thread's CL, which is usually null.
In JContext:
jxbc = javax.xml.bind.JAXBContext
.newInstance("la-la-la", getClass().getClassLoader());
If your jaxb objects are in another bundle, you'll have to somehow get its classloader here so you can use it for the context.
Best regards,
Alex
-
12. Re: JAXB and the system bundle
sivaram123 Sep 18, 2012 9:16 AM (in response to akoledzhikov)Hello Alex,
Thank you for you response. I have already tried in the way by specifieng the class loader for the particular package. I this case i am getting the following error again:
java.lang.Error: Failed to initialize JAXP 1.3 DatatypeFactory class.
at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl.init(RuntimeBuiltinLeafInfoImpl.java:905)
at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl.<clinit>(RuntimeBuiltinLeafInfoImpl.java:899)
at com.sun.xml.bind.v2.model.impl.RuntimeTypeInfoSetImpl.<init>(RuntimeTypeInfoSetImpl.java:65)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.createTypeInfoSet(RuntimeModelBuilder.java:133)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.createTypeInfoSet(RuntimeModelBuilder.java:85)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.<init>(ModelBuilder.java:156)
Caused by: javax.xml.datatype.DatatypeConfigurationException: Provider __redirected.__DatatypeFactory not found
at javax.xml.datatype.DatatypeFactory.newInstance(DatatypeFactory.java:137) [rt.jar:1.6.0_26]
at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl.init(RuntimeBuiltinLeafInfoImpl.java:903)
... 33 more
Caused by: java.lang.ClassNotFoundException: __redirected/__DatatypeFactory
at java.lang.Class.forName0(Native Method) [rt.jar:1.6.0_26]
at java.lang.Class.forName(Class.java:247) [rt.jar:1.6.0_26
Regards,
Siva Ram.
-
13. Re: JAXB and the system bundle
akoledzhikov Sep 18, 2012 9:37 AM (in response to sivaram123)Now this is getting strange...
Are you sure that you're trying the correct classloader (the one from HelloWorld_1.0.0.... bundle) and that your application is properly packaged (which I think it is, but I'm no JAXB expert).
If yes, I'd like you to expand the experiment a bit - instead of using new thread to wait 5 seconds and create the context, can you register an mbean which does the same? You can invoke it after the osgi bundle has deployed successfully - this way we'll be sure that no deployment race-conditions exist.
Best regards,
Alex
-
14. Re: JAXB and the system bundle
sivaram123 Sep 18, 2012 10:14 AM (in response to akoledzhikov)Yes i will try in the way and let you know about the result.
I think there was a problem with the jaxb support for osgi bundles the jboss as 7.1.1 as they have added it in the features list :