I have a Third party jar that contains class SampleClass with @javax.xml.ws.WebServiceClient
annotation. I have used CXF in my project for REST layer and not for Web Services. However, since CXF infrastructure is configured for my project, it is trying to auto-wire into SampleClass when I instantiate it (In fact it is ending up in an error when trying to do so). I want to use the class as a simple POJO and not web service client. is there a way I can tell CXF to ignore @javax.xml.ws.WebServiceClient
annotation?
Just for information, the exception I get is:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.cxf.common.injection.ResourceInjector.invokePostConstruct(ResourceInjector.java:302)
at org.apache.cxf.common.injection.ResourceInjector.construct(ResourceInjector.java:86)
at org.apache.cxf.bus.spring.Jsr250BeanPostProcessor.postProcessAfterInitialization(Jsr250BeanPostProcessor.java:58)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:357)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1308)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:463)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:404)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:375)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:263)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:170)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:260)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:184)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:163)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:430)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381)
at org.apache.cxf.bus.spring.BusApplicationContext.<init>(BusApplicationContext.java:88)
at org.apache.cxf.bus.spring.SpringBusFactory.createApplicationContext(SpringBusFactory.java:103)
at org.apache.cxf.bus.spring.SpringBusFactory.createBus(SpringBusFactory.java:94)
at org.apache.cxf.bus.spring.SpringBusFactory.createBus(SpringBusFactory.java:87)
at org.apache.cxf.bus.spring.SpringBusFactory.createBus(SpringBusFactory.java:65)
at org.apache.cxf.bus.spring.SpringBusFactory.createBus(SpringBusFactory.java:54)
at org.apache.cxf.BusFactory.getDefaultBus(BusFactory.java:70)
at org.apache.cxf.BusFactory.getThreadDefaultBus(BusFactory.java:107)
at org.apache.cxf.BusFactory.getThreadDefaultBus(BusFactory.java:98)
at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:64)
at javax.xml.ws.Service.<init>(Unknown Source)
Caused by: java.lang.NullPointerException
at org.apache.cxf.binding.corba.wsdl.WSDLExtensionRegister.createCompatExtensor(WSDLExtensionRegister.java:63)
at org.apache.cxf.binding.corba.wsdl.WSDLExtensionRegister.registerYokoCompatibleExtensors(WSDLExtensionRegister.java:47)
... 34 more
java.lang.ExceptionInInitializerError
Caused by: java.lang.NullPointerException
at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:81)
at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:141)
at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:133)
at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:65)
at javax.xml.ws.Service.<init>(Unknown Source)
We had used Super() in our class which extends from Service. The code for the parent “Service” class is
Which in turn calls the Static method “Provider.provider()” to load the provider at the runtime. Code for which is
Javadoc comment on this method is:
Blockquote
Creates a new provider object.
The algorithm used to locate the provider subclass to use consists of the following steps:
Blockquote
CXF seems to have chosen first way to load its Provider implementation. ie: "If a resource with the name of META-INF/services/javax.xml.ws.spi.Provider exists, then its first line, if present, is used as the UTF-8 encoded name of the implementation class."
CXF jar has this file inside the jar with Provider class mentioned as a CXF implementation. Since this is the first thing that is used for lookup, CXF's provider will be loaded instead of the default provider. However, our implementation expected default provider to be loaded.
The only viable work around that we could think of is to add the file javax.xml.ws.spi.Provider ourselves under META-INF\\services and specify the provider as default implementation class com.sun.xml.internal.ws.spi.ProviderImpl. The only risk with this is class com.sun.xml.internal.ws.spi.ProviderImpl is an internal implementation of JRE and is not bound to API contract. So the class name/package can potentially change with future releases.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.