首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > Ruby Rails >

解决SSH的有关问题:NoClassDefFoundError: org/aopalliance/aop/Advice

2013-09-11 
解决SSH的问题:NoClassDefFoundError: org/aopalliance/aop/Advice????? 在集成Struts2+Spring3+Hibernate

解决SSH的问题:NoClassDefFoundError: org/aopalliance/aop/Advice

????? 在集成Struts2+Spring3+Hibernate3时,用到了Spring的声明式事务代理bean,tomcat启动时报错,说不能实例化某个service的bean,具体报错如下:

?

?

/* 控制台信息:2012-4-30 3:30:43 org.apache.catalina.core.ApplicationContext log信息: Initializing Spring root WebApplicationContext2012-4-30 3:41:16 org.apache.catalina.core.StandardContext listenerStart严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListenerorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'employeeService' defined in file [D:\projects2\SSHDemo\war\WEB-INF\classes\com\liany\demo\pubs\org\employee\pubs-spring-employee.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/aopalliance/aop/Adviceat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:997)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:943)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:567)at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:384)at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:675)at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:601)at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502)at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)at org.apache.catalina.core.StandardService.start(StandardService.java:525)at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)at org.apache.catalina.startup.Catalina.start(Catalina.java:595)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)at java.lang.reflect.Method.invoke(Method.java:597)at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)Caused by: java.lang.NoClassDefFoundError: org/aopalliance/aop/Adviceat java.lang.Class.getDeclaredConstructors0(Native Method)at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)at java.lang.Class.getConstructor0(Class.java:2699)at java.lang.Class.getDeclaredConstructor(Class.java:1985)at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:67)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:990)... 37 more*/

?

上面有句:"nested?exception?is?java.lang.NoClassDefFoundError:?org/aopalliance/aop/Advice "

表明引入的jar包中未能找到这个类:org.aopalliance.aop.Advice.class。

原来是少了一个额外的aop的工具包,不过奇怪的是org.springframework.aop-3.1.0.RELEASE.jar
这个jar包竟然不含Advice类,
spring3.1的release中下面这个文件
org.springframework.spring-library-3.1.0.RELEASE.libd
中有写: com.springsource.org.aopalliance;version="[1.0.0, 1.0.0]"
但是却没有com.springsource.org.aopalliance-1.0.0.jar包。
老外也发现这个问题:
http://forum.springsource.org/showthread.php?82282-ava-lang-ClassNotFoundException-org-aopalliance-aop-Advice
下载地址:
http://sourceforge.net/projects/aopalliance/files/aopalliance/

????? 公司以前的项目中是用spring1.2,我看了一下也没有用这个jar包, 但是aopalliance.jar里的类都集中放到spring.jar里去了,现在已经是spring3.1了,官方可能是想把aopalliance的相关类从spring.jar中分离去来,就像其它已经分离出来的各种jar一样, 并且已经给aopalliance.jar改好名字了:

com.springsource.org.aopalliance-1.0.0.RELEASE.jar,
不过为什么spring3.1的release没有将它包含进来,而仅仅在org.springframework.spring-library-3.1.0.RELEASE.libd
中提到这个工具的版本信息,很是奇怪哈。。。

?

?

?

?


我的异常网推荐解决方案:org.springframework.beans.factory.BeanCreationException:,http://www.myexception.cn/j2ee/10759.html

热点排行