dubbo启动报java.lang.ClassNotFoundException: javassist.ClassPath

       [INFO ] 2016-08-01 20:50:27,913(0) --> [main] org.springframework.context.support.AbstractApplicationContext.prepareRefresh(AbstractApplicationContext.java:578): Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@15f550a: startup date [Mon Aug 01 20:50:27 CST 2016]; root of context hierarchy  
[INFO ] 2016-08-01 20:50:28,145(232) --> [main] org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:317): Loading XML bean definitions from class path resource [applicationContext_Provider.xml]  
[INFO ] 2016-08-01 20:50:28,602(689) --> [main] : using logger: com.alibaba.dubbo.common.logger.log4j.Log4jLoggerAdapter  
[WARN ] 2016-08-01 20:50:29,495(1582) --> [main] org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546): Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dubbo.provider.Interface.DemoService1Interface': Instantiation of bean failed; nested exception is java.lang.ExceptionInInitializerError  
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dubbo.provider.Interface.DemoService1Interface': Instantiation of bean failed; nested exception is java.lang.ExceptionInInitializerError
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1105)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1050)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:93)
at dubbo.demo.Provider.main(Provider.java:14)
Caused by: java.lang.ExceptionInInitializerError
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:408)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:89)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1098)
... 13 more
Caused by: java.lang.IllegalStateException: fail to create adaptive instance: java.lang.IllegalStateException: Can not create adaptive extenstion interface com.alibaba.dubbo.rpc.Protocol, cause: Failed to load extension class(interface: interface com.alibaba.dubbo.common.compiler.Compiler, class line: com.alibaba.dubbo.common.compiler.support.JavassistCompiler) in jar:file:/C:/Users/IBM%20Thinkpad/.gradle/caches/modules-2/files-2.1/com.alibaba/dubbo/2.8.4/33b6df9988eb93d5bc8ebad56face09de377ec3a/dubbo-2.8.4.jar!/META-INF/dubbo/internal/com.alibaba.dubbo.common.compiler.Compiler, cause: javassist/ClassPath
at com.alibaba.dubbo.common.extension.ExtensionLoader.getAdaptiveExtension(ExtensionLoader.java:459)
at com.alibaba.dubbo.config.ServiceConfig.(ServiceConfig.java:62)
... 20 more
Caused by: java.lang.IllegalStateException: Can not create adaptive extenstion interface com.alibaba.dubbo.rpc.Protocol, cause: Failed to load extension class(interface: interface com.alibaba.dubbo.common.compiler.Compiler, class line: com.alibaba.dubbo.common.compiler.support.JavassistCompiler) in jar:file:/C:/Users/IBM%20Thinkpad/.gradle/caches/modules-2/files-2.1/com.alibaba/dubbo/2.8.4/33b6df9988eb93d5bc8ebad56face09de377ec3a/dubbo-2.8.4.jar!/META-INF/dubbo/internal/com.alibaba.dubbo.common.compiler.Compiler, cause: javassist/ClassPath
at com.alibaba.dubbo.common.extension.ExtensionLoader.createAdaptiveExtension(ExtensionLoader.java:723)
at com.alibaba.dubbo.common.extension.ExtensionLoader.getAdaptiveExtension(ExtensionLoader.java:455)
... 21 more
Caused by: java.lang.IllegalStateException: Failed to load extension class(interface: interface com.alibaba.dubbo.common.compiler.Compiler, class line: com.alibaba.dubbo.common.compiler.support.JavassistCompiler) in jar:file:/C:/Users/IBM%20Thinkpad/.gradle/caches/modules-2/files-2.1/com.alibaba/dubbo/2.8.4/33b6df9988eb93d5bc8ebad56face09de377ec3a/dubbo-2.8.4.jar!/META-INF/dubbo/internal/com.alibaba.dubbo.common.compiler.Compiler, cause: javassist/ClassPath
at com.alibaba.dubbo.common.extension.ExtensionLoader.loadFile(ExtensionLoader.java:685)
at com.alibaba.dubbo.common.extension.ExtensionLoader.loadExtensionClasses(ExtensionLoader.java:591)
at com.alibaba.dubbo.common.extension.ExtensionLoader.getExtensionClasses(ExtensionLoader.java:567)
at com.alibaba.dubbo.common.extension.ExtensionLoader.getAdaptiveExtensionClass(ExtensionLoader.java:728)
at com.alibaba.dubbo.common.extension.ExtensionLoader.createAdaptiveExtension(ExtensionLoader.java:721)
at com.alibaba.dubbo.common.extension.ExtensionLoader.getAdaptiveExtension(ExtensionLoader.java:455)
at com.alibaba.dubbo.common.extension.ExtensionLoader.createAdaptiveExtensionClass(ExtensionLoader.java:738)
at com.alibaba.dubbo.common.extension.ExtensionLoader.getAdaptiveExtensionClass(ExtensionLoader.java:732)
at com.alibaba.dubbo.common.extension.ExtensionLoader.createAdaptiveExtension(ExtensionLoader.java:721)
... 22 more
Caused by: java.lang.NoClassDefFoundError: javassist/ClassPath
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:344)
at com.alibaba.dubbo.common.extension.ExtensionLoader.loadFile(ExtensionLoader.java:627)
... 30 more
Caused by: java.lang.ClassNotFoundException: javassist.ClassPath
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 33 more
[INFO ] 2016-08-01 20:50:29,533(1620) --> [DubboShutdownHook] com.alibaba.dubbo.config.AbstractConfig$1.run(AbstractConfig.java:450):  [DUBBO] Run shutdown hook now., dubbo version: 2.8.4, current host: 127.0.0.1  
[INFO ] 2016-08-01 20:50:29,534(1621) --> [DubboShutdownHook] com.alibaba.dubbo.registry.support.AbstractRegistryFactory.destroyAll(AbstractRegistryFactory.java:63):  [DUBBO] Close all registries [], dubbo version: 2.8.4, current host: 127.0.0.1  

dependencies {

compile "javax.validation:validation-api:1.1.0.Final",
"org.apache.bval:bval-jsr303:0.5",
"org.jboss.resteasy:jaxrs-api:3.0.7.Final",

"javax.annotation:javax.annotation-api:1.2",

"javax.servlet:javax.servlet-api:3.1.0", //可选
"javax.ws.rs:javax.ws.rs-api:2.0",

"org.codehaus.jackson:jackson-mapper-asl:1.9.13",
"org.jboss.resteasy:resteasy-client:3.0.7.Final",
"org.jboss.resteasy:resteasy-jackson-provider:3.0.7.Final",


  "org.apache.zookeeper:zookeeper:3.4.6",
    "com.github.sgroschupf:zkclient:0.1",
    "com.alibaba:fastjson:1.1.39",
    "com.alibaba:dubbo:2.8.4",
   
   
    "org.springframework:spring-core:4.2.5.RELEASE",
    "org.springframework:spring-context:4.2.5.RELEASE",
    "org.springframework:spring-beans:4.2.5.RELEASE",
    "org.springframework:spring-web:4.2.5.RELEASE",
    "org.springframework:spring-webmvc:4.2.5.RELEASE",
   
    "org.apache.tomcat.embed:tomcat-embed-core:8.0.11",
    "org.apache.tomcat.embed:tomcat-embed-logging-juli:8.0.11",

"dom4j:dom4j:1.6.1"
}


使用gradle 打包dubbox放到nexus私服上 公司更换私服地址。导致一些资源需要重新定位 上传。中间出了点小插曲竟然让我纠结了半天

在dubbo启动的过程中报错误:java.lang.ClassNotFoundException: javassist.ClassPath,调试发现代码:Class clazz = Class.forName(line, true, classLoader)执行加载类com.alibaba.dubbo.common.compiler.support.JavassistCompiler时报:java.lang.NoClassDefFoundError: javassist/ClassPath,这个错误最后被加工最终变成上边的错误。可是查看项目下发现依赖的包javassist-3.18.1-GA.jar命名存在,打开这些jar包,其中的javassist.ClassPath的确存在啊,于是我换了个版本javassist-3.18.2-GA.jar程序跑起来了。那么到底是怎么回事呢?。

        其实就是因为JavassistCompile使用了类javassist.ClassPath。经过一点点的比较,最后发现 javassist-3.18.1-GA.jar这个包是有问题的,因为其MAINFEST.FM文件是打不开的,解压以后也报各种Class文件格式错误,看来应该是这个问题了,时间紧张也不打算深入验证了,总之当大家出现这种问题时,也算是一种可能问题吧,希望能为大家解决问题提供线索。

你可能感兴趣的:(dubbo启动报java.lang.ClassNotFoundException: javassist.ClassPath)