dubbo provider启动报NoClassDefFoundError

lin楷彬 发布于 2016/01/08 12:40
阅读 854
收藏 0

    将服务提供端接口和实现分离成两个项目,实现依赖接口,如下图

服务端dubbo配置如下:


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd 
        http://code.alibabatech.com/schema/dubbo  http://code.alibabatech.com/schema/dubbo/dubbo.xsd  ">

	<!-- 提供方应用信息,用于计算依赖关系 -->
	<dubbo:application name="forum-user" />

	<!-- 使用multicast广播注册中心暴露服务地址 -->
	<!-- <dubbo:registry address="multicast://224.5.6.7:1234" /> -->
	<dubbo:registry address="zookeeper://10.75.201.49:2181"
		client="zkclient" />

	<!-- 用dubbo协议在20880端口暴露服务 -->
	<dubbo:protocol name="dubbo" port="29011" />

	<bean id="userQueryService" class="org.lkb.forum.user.impl.UserQueryServiceImpl" />

	<!-- 声明需要暴露的服务接口 -->
	<dubbo:service interface="org.lkb.forum.user.service.UserQueryService"
		ref="userQueryService" />

</beans>



启动的时候报错



org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [org.lkb.forum.user.impl.UserQueryServiceImpl] for bean with name 'userQueryService' defined in file [E:\workspaces\.metadata\.plugins\org.eclipse.wst.server.core\tmp2\wtpwebapps\forum-user\WEB-INF\classes\dubbo\provider.xml]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/lkb/forum/user/service/UserQueryService
	at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1331) ~[spring-beans-4.1.8.RELEASE.jar:4.1.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:622) ~[spring-beans-4.1.8.RELEASE.jar:4.1.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:591) ~[spring-beans-4.1.8.RELEASE.jar:4.1.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1397) ~[spring-beans-4.1.8.RELEASE.jar:4.1.8.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:434) [spring-beans-4.1.8.RELEASE.jar:4.1.8.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:404) [spring-beans-4.1.8.RELEASE.jar:4.1.8.RELEASE]
	at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:82) [spring-context-4.1.8.RELEASE.jar:4.1.8.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:607) [spring-context-4.1.8.RELEASE.jar:4.1.8.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:462) [spring-context-4.1.8.RELEASE.jar:4.1.8.RELEASE]
	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:434) [spring-web-4.1.8.RELEASE.jar:4.1.8.RELEASE]
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306) [spring-web-4.1.8.RELEASE.jar:4.1.8.RELEASE]
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) [spring-web-4.1.8.RELEASE.jar:4.1.8.RELEASE]
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4793) [catalina.jar:8.0.29]
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5236) [catalina.jar:8.0.29]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [catalina.jar:8.0.29]
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408) [catalina.jar:8.0.29]
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398) [catalina.jar:8.0.29]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_66]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_66]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_66]
	at java.lang.Thread.run(Thread.java:745) [na:1.8.0_66]
Caused by: java.lang.NoClassDefFoundError: org/lkb/forum/user/service/UserQueryService
	at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0_66]
	at java.lang.ClassLoader.defineClass(ClassLoader.java:760) ~[na:1.8.0_66]
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[na:1.8.0_66]
	at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2494) ~[catalina.jar:8.0.29]
	at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:860) ~[catalina.jar:8.0.29]
	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1302) ~[catalina.jar:8.0.29]
	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1167) ~[catalina.jar:8.0.29]
	at org.springframework.util.ClassUtils.forName(ClassUtils.java:249) ~[spring-core-4.1.8.RELEASE.jar:4.1.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:395) ~[spring-beans-4.1.8.RELEASE.jar:4.1.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1349) ~[spring-beans-4.1.8.RELEASE.jar:4.1.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1320) ~[spring-beans-4.1.8.RELEASE.jar:4.1.8.RELEASE]
	... 20 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.lkb.forum.user.service.UserQueryService
	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1333) ~[catalina.jar:8.0.29]
	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1167) ~[catalina.jar:8.0.29]
	... 31 common frames omitted



其中userQueryService这个接口类我是放在forum-user-service这个项目里的,并且forum-user这个项目已经依赖了forum-user-service,不知道为什么forum-user启动还会报这种错

使用的是tomcat启动的

请各位大哥指点迷津,百度谷歌没有找到相关解决方案,谢了


加载中
返回顶部
顶部