cxf3.1+spring4+maven启动报错

Posted pthwang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了cxf3.1+spring4+maven启动报错相关的知识,希望对你有一定的参考价值。

cxf3.1+spring4+maven启动报错

[ERROR 2018-08-01 19:03:33 ResourceInjector:449 RMI TCP Connection(3)-127.0.0.1] exception raied when invoking setter public final void org.apache.cxf.wsdl11.WSDLManagerImpl.setBus(org.apache.cxf.Bus)
java.lang.reflect.InvocationTargetException
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:498)
 at org.apache.cxf.common.injection.ResourceInjector.invokeSetter(ResourceInjector.java:287)
 at org.apache.cxf.common.injection.ResourceInjector.visitMethod(ResourceInjector.java:232)
 at org.apache.cxf.common.annotation.AnnotationProcessor.processMethods(AnnotationProcessor.java:89)
 at org.apache.cxf.common.annotation.AnnotationProcessor.accept(AnnotationProcessor.java:72)
 at org.apache.cxf.common.injection.ResourceInjector.inject(ResourceInjector.java:118)
 at org.apache.cxf.common.injection.ResourceInjector.inject(ResourceInjector.java:112)
 at org.apache.cxf.bus.extension.ExtensionManagerImpl.loadAndRegister(ExtensionManagerImpl.java:242)
 at org.apache.cxf.bus.extension.ExtensionManagerImpl.getBeanOfType(ExtensionManagerImpl.java:320)
 at org.apache.cxf.bus.extension.ExtensionManagerBus.getExtension(ExtensionManagerBus.java:215)
 at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:85)
 at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.buildServiceFromWSDL(ReflectionServiceFactoryBean.java:393)
 at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:527)
 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:102)
 at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:168)
 at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:211)
 at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:460)
 at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:338)
 at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:255)
 at org.apache.cxf.ws.discovery.internal.WSDiscoveryServiceImpl.startup(WSDiscoveryServiceImpl.java:259)
 at org.apache.cxf.ws.discovery.internal.WSDiscoveryServiceImpl.serverStarted(WSDiscoveryServiceImpl.java:154)
 at org.apache.cxf.ws.discovery.listeners.WSDiscoveryServerListener.startServer(WSDiscoveryServerListener.java:73)
 at org.apache.cxf.bus.managers.ServerLifeCycleManagerImpl.startServer(ServerLifeCycleManagerImpl.java:61)
 at org.apache.cxf.endpoint.ServerImpl.start(ServerImpl.java:137)
 at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:366)
 at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:255)
 at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:543)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:498)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1759)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1696)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1626)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
 at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)
 at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
 at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
 at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
 at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:443)
 at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325)
 at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
 at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4760)
 at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5184)
 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
 at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:724)
 at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:700)
 at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714)
 at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1588)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:498)
 at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
 at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
 at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
 at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:463)
 at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:413)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:498)
 at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
 at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
 at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
 at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468)
 at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)
 at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309)
 at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1401)
 at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:498)
 at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:324)
 at sun.rmi.transport.Transport$1.run(Transport.java:200)
 at sun.rmi.transport.Transport$1.run(Transport.java:197)
 at java.security.AccessController.doPrivileged(Native Method)
 at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
 at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
 at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
 at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
 at java.security.AccessController.doPrivileged(Native Method)
 at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
 at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.cxf.bus.extension.ExtensionException: Could not create object of extension class org.apache.cxf.binding.corba.wsdl.WSDLExtensionRegister.
 at org.apache.cxf.bus.extension.Extension.load(Extension.java:241)
 at org.apache.cxf.bus.extension.ExtensionManagerImpl.loadAndRegister(ExtensionManagerImpl.java:213)
 at org.apache.cxf.bus.extension.ExtensionManagerImpl.getBeansOfType(ExtensionManagerImpl.java:348)
 at org.apache.cxf.wsdl11.WSDLManagerImpl.setBus(WSDLManagerImpl.java:122)
 ... 96 more
Caused by: java.lang.NullPointerException
 at org.apache.cxf.wsdl.JAXBExtensionHelper.createExtensionClass(JAXBExtensionHelper.java:471)
 at org.apache.cxf.wsdl.JAXBExtensionHelper.addExtensions(JAXBExtensionHelper.java:199)
 at org.apache.cxf.binding.corba.wsdl.WSDLExtensionRegister.createExtensor(WSDLExtensionRegister.java:71)
 at org.apache.cxf.binding.corba.wsdl.WSDLExtensionRegister.registerCXFExtensors(WSDLExtensionRegister.java:44)
 at org.apache.cxf.binding.corba.wsdl.WSDLExtensionRegister.<init>(WSDLExtensionRegister.java:39)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
 at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
 at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
 at org.apache.cxf.bus.extension.Extension.load(Extension.java:217)
 ... 99 more

定位过程

引起异常的地方

Caused by: java.lang.NullPointerException
at org.apache.cxf.wsdl.JAXBExtensionHelper.createExtensionClass(JAXBExtensionHelper.java:471)
at org.apache.cxf.wsdl.JAXBExtensionHelper.addExtensions(JAXBExtensionHelper.java:199)

网上找不到答案,于是自己定位:

查看源代码如下:

JAXBExtensionHelper.java:471

ClassWriter cw = helper.createClassWriter();
            cw.visit(Opcodes.V1_6, Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER + Opcodes.ACC_SYNTHETIC, className + "Extensibility", (String)null, className, new String[]{"javax/wsdl/extensions/ExtensibilityElement"});

看下来是cw为Null,跟代码到helper.createClassWriter里,查看源码

public ASMHelper.ClassWriter createClassWriter() {
        Object newCw = null;
        if(!badASM) {
            if(cwClass == null) {
                try {
                    cwClass = getASMClass();
                } catch (Throwable var8) {
                    badASM = true;
                    throw new RuntimeException("No ASM ClassWriterFound", var8);
                }
            }

            try {
                Constructor e = cwClass.getConstructor(new Class[]{Boolean.TYPE});

                try {
                    cwClass.getMethod("newConstInt", new Class[]{Integer.TYPE});
                    badASM = true;
                } catch (Throwable var6) {
                    newCw = e.newInstance(new Object[]{Boolean.TRUE});
                }
            } catch (Throwable var7) {
                try {
                    Constructor cons = cwClass.getConstructor(new Class[]{Integer.TYPE});
                    int i = cwClass.getField("COMPUTE_MAXS").getInt((Object)null);
                    i |= cwClass.getField("COMPUTE_FRAMES").getInt((Object)null);
                    newCw = cons.newInstance(new Object[]{Integer.valueOf(i)});
                } catch (Throwable var5) {
                    ;
                }
            }
        }

        return newCw != null?(ASMHelper.ClassWriter)ReflectionInvokationHandler.createProxyWrapper(newCw, ASMHelper.ClassWriter.class):null;
    }

其中Constructor e = cwClass.getConstructor(new Class[]{Boolean.TYPE});没有Throwable,导致newCw没有被赋值。
查看cwClass的值为class org.objectweb.asm.ClassWriter。初步定位是class org.objectweb.asm的jar包冲突。

查看lib库发现同时存在

Maven:asm:asm:1.5.3
Maven:org.ow2.asm:asm:5.0.4
再看Maven:asm:asm:1.5.3由cglib2.1_3引入的
更新cglib2.1_3为cglib3.2.5问题解决。
















以上是关于cxf3.1+spring4+maven启动报错的主要内容,如果未能解决你的问题,请参考以下文章

Maven + Spring4

Spring4 mvc+maven 框架搭建

myeclipse启动maven报错

Spring4 mvc+maven 框架搭建

maven compile启动报错

maven引入dubbo包后启动报错