首页 新闻 会员 周边 捐助

Spring和Struts2结合出错

0
悬赏园豆:10 [待解决问题]

type Exception report

message Unable to instantiate Action, com.zkx.registeration.action.UserAction, defined for 'user' in namespace '/'Unexpected exception parsing XML document from class path resource [beans.xml]; nested exception is java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor

description The server encountered an internal error that prevented it from fulfilling this request.

exception

Unable to instantiate Action, com.zkx.registeration.action.UserAction,  defined for 'user' in namespace '/'Unexpected exception parsing XML document from class path resource [beans.xml]; nested exception is java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor
	com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:306)
	com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:387)
	com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:186)
	org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
	org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
	com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:47)
	org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:458)
	org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
	org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:76)

 

root cause

org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [beans.xml]; nested exception is java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor
	org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:414)
	org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336)
	org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)
	org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181)
	org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217)
	org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188)
	org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:252)
	org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127)
	org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93)
	org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129)
	org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:605)
	org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:509)
	org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
	org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
	com.zkx.registeration.action.UserAction.<init>(UserAction.java:19)
	sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	java.lang.reflect.Constructor.newInstance(Constructor.java:422)
	java.lang.Class.newInstance(Class.java:442)
	com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:119)
	com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:150)
	com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:139)
	com.opensymphony.xwork2.ObjectFactory.buildAction(ObjectFactory.java:109)
	com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:287)
	com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:387)
	com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:186)
	org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
	org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
	com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:47)
	org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:458)
	org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
	org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:76)

struts.xml

<struts>
<package name="registeration" extends="struts-default">

<action name="user" class="com.zkx.registeration.action.UserAction">

<result name="success">/registersuccess.jsp</result>
<result name="fail">/registerfail.jsp</result>

</action>
</package>

 

beans.xml

<context:annotation-config />
<context:component-scan base-package="com.zkx" />

<!--
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">


<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/spring" />
<property name="username" value="root" />
<property name="password" value="bjsxt" />
</bean>
-->

<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>classpath:jdbc.properties</value>
</property>
</bean>

<bean id="dataSource" destroy-method="close"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>

<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<!--
<property name="annotatedClasses">
<list>
<value>com.bjsxt.model.User</value>
<value>com.bjsxt.model.Log</value>
</list>
</property>
-->
<property name="packagesToScan">
<list>
<value>com.zkx.registeration.model</value>

</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>

<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>

<bean id="txManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>

<aop:config>
<aop:pointcut id="bussinessService"
expression="execution(public * com.zkx.registeration.service.*.*(..))" />
<aop:advisor pointcut-ref="bussinessService"
advice-ref="txAdvice" />
</aop:config>

<tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="exists" read-only="true" />
<tx:method name="add*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>



zhanglala的主页 zhanglala | 初学一级 | 园豆:168
提问于:2015-10-31 08:54
< >
分享
所有回答(2)
0
http://mavenrepository.com/artifact/aopalliance/aopalliance

试试这个jar包呢?

之奇一昂 | 园豆:1421 (小虾三级) | 2015-10-31 17:33
0

有可能是缺少楼上的包,也有可能是缺少插件包struts2-spring-plugin-xx.jar,你都试试

jasondyoung | 园豆:424 (菜鸟二级) | 2016-01-20 00:06
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册