After reading the things on http://cxf.apache.org/docs/jaxb.html , seems that CXF depends on RI JAXB implementation, right ? So, could CXF work with other JAXB impl ?
2012/8/16 Ivan <xhh...@gmail.com> > Thanks so much, Freeman. So, does it mean that CXF is depending on RI Jaxb > impl ? Is there any story for that? > > If does, considering that, in my environment, I ship a JAXB 2.2 API, and > also a repackaged RI implementation (due to some special reason ;-( ), is > it possible to make the class name configurable (If it is reasonable, I > could open a improvment JIRA and try to find a way to configure that)? with > that, I could manually configure that, or is there any better way to do > that ? > > > 2012/8/16 Freeman Fang <freeman.f...@gmail.com> > >> Hi, >> >> For the CCE in JAXBDataBinding, I think it's from two >> javax.xml.bind.JAXBContext object somehow loaded by different classloaders. >> Most likely one is from the jaxb api bundle you installed, one from the >> system bundle 0, so you can comment out javax.xml.bind* package from >> system bundle 0 to see if it helps. >> >> And JAXBDataBinding actually can generate RIContext from other jaxb >> implementations, not always load the RI context directly, but yeah,you do >> need jaxb RI in your container. This code piece show it >> JAXBContext riContext; >> if (context.getClass().getName().contains("com.sun.xml.")) { >> riContext = context; >> } else { >> // fall back if we're using another jaxb implementation >> try { >> riContext = JAXBUtils.createRIContext(contextClasses >> .toArray(new Class[contextClasses.size()]), tns); >> } catch (JAXBException e) { >> throw new ServiceConstructionException(e); >> } >> } >> >> Freeman >> >> ------------- >> Freeman Fang >> >> FuseSource >> Email:ff...@fusesource.com >> Web: fusesource.com >> Twitter: freemanfang >> Blog: http://freemanfang.blogspot.com >> http://blog.sina.com.cn/u/1473905042 >> weibo: http://weibo.com/u/1473905042 >> >> On 2012-8-16, at 上午9:51, Ivan wrote: >> >> > Thanks for the info, I have used some hook methods to make the API work, >> > for the packages exported by the system packages, according to the >> wiring >> > rule in OSGi spec, CXF bundles will automatically wire to the latest >> > jaxws2.2 and jaxb 2.2 bundle. >> > >> > The issue blocked me is that the JAXBDataBinding class, it always >> requires >> > to load the RI context, do you have any comment for this ? >> > >> > 2012/8/16 Freeman Fang <freeman.f...@gmail.com> >> > >> >> Hi, >> >> >> >> As I mentioned, you can't simply wrap spec jar like jaxb-api, as SPI >> >> mechanism doesn't work in OSGi container. So the spec jar need have >> >> OSGiLocator stuff, so that it can load jaxb-impl bundles from OSGi >> >> container, servicemix already provide such spec jars with OSGiLocator, >> so >> >> you better use spec jar from servicemix. >> >> >> >> Moreover, you also need fine-tune the system bundle export package, >> some >> >> package like javax.xml.bind*, javax.xml.soap, javax.xml.ws* shouldn't >> >> exported by system bundle. >> >> I'd say adjust a plain OSGi container to support CXF need more effort, >> >> but Servicemix/CXF already do it for you. Please try with >> Servicemix/CXF >> >> if you can, then you will find it's very easy to support CXF. >> >> >> >> Freeman >> >> ------------- >> >> Freeman Fang >> >> >> >> FuseSource >> >> Email:ff...@fusesource.com >> >> Web: fusesource.com >> >> Twitter: freemanfang >> >> Blog: http://freemanfang.blogspot.com >> >> http://blog.sina.com.cn/u/1473905042 >> >> weibo: http://weibo.com/u/1473905042 >> >> >> >> On 2012-8-15, at 下午9:25, Ivan wrote: >> >> >> >>> I use Equonix as the OSGi container, and now I have installed all the >> >>> required bundles, and all of them are resovled and started correctly. >> >> Guess >> >>> that this issue is not related to the actual container is used. even >> turn >> >>> to Karaf (a high level infrasture on the native OSGi runtime), the >> issue >> >>> may still occur, as CXF jaxb databinding bundle will be wired to 2.2 >> JAXB >> >>> API bundle. >> >>> >> >>> Could you show me some light for the CCE in JAXBDataBinding ? Could >> CXF >> >>> work with other JAXB implemenation ? Thanks. >> >>> >> >>> >> >>> 2012/8/15 Freeman Fang <freeman.f...@gmail.com> >> >>> >> >>>> Hi, >> >>>> >> >>>> Which OSGi container you are using? >> >>>> >> >>>> To use CXF in OSGi container, a lot of effort need be done, jaxb-api >> >> and >> >>>> jaxb-impl bundle is one of them, but not all. Servicemix wrap lots of >> >>>> bundles(spec bundle like jaxb-api need use OSGiLocator stuff) and >> karaf >> >>>> provide a provisioning mechanism(feature) to is convenient to install >> >> CXF, >> >>>> so I suggest you use Apache Servicemix or Karaf as the OSGi >> container, >> >>>> which support CXF better. >> >>>> >> >>>> Actually Servicemix support CXF OOTB now, and Karaf 2.2.x also >> support >> >> to >> >>>> install CXF feature easily, you just need replace the jre.properties >> >> with >> >>>> jre.properties.cxf, both in $KARAF_HOME/etc folder. >> >>>> >> >>>> For Karaf 2.3.x and 3.x(which could be released soon), as it endorse >> new >> >>>> spec api jar from Servicemix, so both can support CXF OOTB. >> >>>> >> >>>> Freeman >> >>>> >> >>>> ------------- >> >>>> Freeman Fang >> >>>> >> >>>> FuseSource >> >>>> Email:ff...@fusesource.com >> >>>> Web: fusesource.com >> >>>> Twitter: freemanfang >> >>>> Blog: http://freemanfang.blogspot.com >> >>>> http://blog.sina.com.cn/u/1473905042 >> >>>> weibo: http://weibo.com/u/1473905042 >> >>>> >> >>>> On 2012-8-15, at 下午4:57, Ivan wrote: >> >>>> >> >>>>> I am trying to use CXF 2.6.1 in OSGi environment, as jdk 6 does not >> >> ship >> >>>>> the latest JAXB API and implementation, so deployed a JAXB 2.2 API >> and >> >> a >> >>>>> repackaged RI JAXB impl as bundles. While running my application, it >> >>>> shows >> >>>>> ClassCastException one line 392 of JAXBDataBinding. Think the >> problem >> >> is >> >>>>> that, the CXF bundle is wired to the 2.2 API and the codes load the >> >>>>> hardcode RI JAXB classes (which should be from JDK). >> >>>>> >> >>>>> From the code logic, seems that it is used for schema things, so >> does >> >> it >> >>>>> mean that CXF always need the RI JAXB impl ? If does, it it >> possible to >> >>>>> have a way to configure a RI class name, as I repackaged the RI jaxb >> >> impl >> >>>>> for some other reasons. >> >>>>> Thanks. >> >>>>> -- >> >>>>> Ivan >> >>>> >> >>>> >> >>> >> >>> >> >>> -- >> >>> Ivan >> >> >> >> >> > >> > >> > -- >> > Ivan >> >> > > > -- > Ivan > -- Ivan