You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Freeman Yue Fang (Jira)" <ji...@apache.org> on 2021/04/07 14:06:00 UTC

[jira] [Commented] (CXF-8450) Cached JAXB databinding

    [ https://issues.apache.org/jira/browse/CXF-8450?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17316365#comment-17316365 ] 

Freeman Yue Fang commented on CXF-8450:
---------------------------------------

Hi [~Dragas],

First of all, thanks for bringing this up and the contribution.

If I read your patch correctly, your "Cached JAXB databinding" needs to initialize JAXBContext each time for a specific Service, which is time consuming. I don't think this is a good idea TBH, since a wsdl file is relatively stable and once we init a JAXBDatabinding, we assume the JAXBContext of it is static, to avoid recreating the service model over and over again. If the wsdl has changed, we normally recreate everything from the scratch. 

IMO, the better way here is that you should break your giant wsdl into small pieces, hence when new interfaces get introduced and released, it only affects small part of your applications.

Cheers
Freeman

> Cached JAXB databinding 
> ------------------------
>
>                 Key: CXF-8450
>                 URL: https://issues.apache.org/jira/browse/CXF-8450
>             Project: CXF
>          Issue Type: New Feature
>          Components: JAXB Databinding
>            Reporter: Mantas Gridinas
>            Assignee: Freeman Yue Fang
>            Priority: Minor
>         Attachments: Creates_a_reordered_JAXBDataBinding_implementation_that_permits_expanding_internal_class_l.patch
>
>
> Background: we use CXF 3.3.9 via apache camel 2.25
> Our internal system provides single WSDL file every release which contains roughly 30 interfaces and produces about 3.2K classes. When using regular JAXBDatabinding implementation we found that it rescans the classes every time we attempt to create one of those interfaces endpoint when we use new instances of JAXBDatabinding. When we reuse an existing instance of JAXBDatabinding, there's a check in it that prevents expanding the class list in existing context:
> {code:java}
> // context is already set, don't redo it
> if (context != null) {
>     return;
> }
> {code}
> and as a result, it crashes with the following error
> {code:java}
> org.apache.camel.RuntimeCamelException: org.apache.cxf.service.factory.ServiceConstructionException: Service class se.foo.schemas.bar.webservices.wsdl.BenefitInterface method getBenefit part {http://schemas.foo.se/bar/WebServices/wsdl}request cannot be mapped to schema. Check for use of a JAX-WS-specific type without the JAX-WS service factory bean.
> 	at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1826)
> 	at org.apache.camel.spring.SpringCamelContext.start(SpringCamelContext.java:136)
> 	at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:174)
> 	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
> 	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
> 	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
> 	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:398)
> 	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:355)
> 	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:882)
> 	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:163)
> 	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
> 	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142)
> 	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775)
> 	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
> 	at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
> 	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
> 	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
> 	at se.internal.integration.bar.configuration.IntegrationBarApplication.main(IntegrationBarApplication.java:22)
> 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
> 	at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
> Caused by: org.apache.cxf.service.factory.ServiceConstructionException: Service class se.foo.schemas.bar.webservices.wsdl.BenefitInterface method getBenefit part {http://schemas.foo.se/bar/WebServices/wsdl}request cannot be mapped to schema. Check for use of a JAX-WS-specific type without the JAX-WS service factory bean.
> 	at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.createBareMessage(ReflectionServiceFactoryBean.java:1266)
> 	at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:479)
> 	at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:693)
> 	at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:529)
> 	at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:262)
> 	at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:199)
> 	at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:103)
> 	at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:91)
> 	at org.apache.camel.component.cxf.CxfEndpoint.createClient(CxfEndpoint.java:649)
> 	at org.apache.camel.component.cxf.CxfProducer.doStart(CxfProducer.java:84)
> 	at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:72)
> 	at org.apache.camel.impl.SynchronousDelegateProducer.start(SynchronousDelegateProducer.java:66)
> 	at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:75)
> 	at org.apache.camel.impl.DeferServiceStartupListener.onCamelContextStarted(DeferServiceStartupListener.java:49)
> 	at org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:3868)
> 	at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:3647)
> 	at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3488)
> 	at org.apache.camel.impl.DefaultCamelContext$4.call(DefaultCamelContext.java:3247)
> 	at org.apache.camel.impl.DefaultCamelContext$4.call(DefaultCamelContext.java:3243)
> 	at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:3266)
> 	at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:3243)
> 	at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:72)
> 	at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:3159)
> 	at org.apache.camel.spring.SpringCamelContext.start(SpringCamelContext.java:133)
> 	... 21 common frames omitted
> {code}
> I've attached the changes patch that would be made to existing JAXBDatabinding class to support the expanding internal cache. I'm sure that the cachedjaxbdatabinding breaks some existing concerns.
>  
> Looking through existing tests that refer to JAXBDatabinding class it seems I would have to duplicate quite a few of them. Is there a TCK that could be used for JAXBDatabinding implementations instead?



--
This message was sent by Atlassian Jira
(v8.3.4#803005)