Chinaunix首页 | 论坛 | 博客
  • 博客访问: 893366
  • 博文数量: 282
  • 博客积分: 10843
  • 博客等级: 上将
  • 技术积分: 2435
  • 用 户 组: 普通用户
  • 注册时间: 2006-07-01 15:23
文章分类

全部博文(282)

文章存档

2013年(1)

2012年(18)

2011年(14)

2010年(30)

2009年(48)

2008年(55)

2007年(55)

2006年(61)

分类: Java

2011-12-17 11:45:36

先是用是spring的批注applicationContext.xml:

XML code

xml version="1.0" encoding="UTF-8"?>

<beans xmlns=""

xmlns:xsi="" xmlns:p=""

xmlns:context=""

xmlns:aop="" xmlns:tx=""

xsi:schemaLocation="

/spring-context-2.5.xsd

/spring-beans-2.5.xsd

/spring-aop-3.0.xsd

/spring-tx-3.0.xsd">

<context:annotation-config />

<context:component-scan base-package="cn.text">

context:component-scan>

......

某个ManagerImpl中:

Java code

@Service("d0510mgr")

@RemoteProxy(name = "d0510mgr")

public class D0510ManagerImpl{

......

}

Action中:

Java code

@Controller("D05_10action")

@RemoteProxy(name = "D05_10action")

public class D0510Action extends GenericAction {

private static final long serialVersionUID = 1L;

@Resource(name = "d0510mgr")

private D0510ManagerImpl mgr;

......

可以正常使用没问题。现在增加了spring的事务配置applicationContext.xml:

XML code

xml version="1.0" encoding="UTF-8"?>

<beans xmlns=""

xmlns:xsi="" xmlns:p=""

xmlns:context=""

xmlns:aop="" xmlns:tx=""

xsi:schemaLocation="

/spring-context-2.5.xsd

/spring-beans-2.5.xsd

/spring-aop-3.0.xsd

/spring-tx-3.0.xsd">

<context:annotation-config />

<context:component-scan base-package="cn.text">

context:component-scan>

<tx:annotation-driven transaction-manager="transactionManager" />

......

beans>

某个ManagerImpl中增加了一个方法:

Java code

@Service("d0510mgr")

@RemoteProxy(name = "d0510mgr")

public class D0510ManagerImpl{

@Transactional(propagation=Propagation.REQUIRED)

public boolean delete(Integer id){

......

}

启动tomcat时出现了如下错误:[ERROR][context.ContextLoader] Context initialization failedorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'D05_10action': Injection of resource fields failed; nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'd0510mgr' must be of type [cn.qianaq.manager.impl.D0510ManagerImpl], but was actually of type [$Proxy35]at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessAfterInstantiation(CommonAnnotationBeanPostProcessor.java:292)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:959)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)at java.security.AccessController.doPrivileged(Native Method)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4135)at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1244)at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1342)at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:303)at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337)at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)at java.lang.Thread.run(Thread.java:619)Caused by: org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'd0510mgr' must be of type [cn.qianaq.manager.impl.D0510ManagerImpl], but was actually of type [$Proxy35]at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322)at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:168)at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:435)at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:409)at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:537)at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:180)at org.springframework.beans.factory.annotation.InjectionMetadata.injectFields(InjectionMetadata.java:105)at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessAfterInstantiation(CommonAnnotationBeanPostProcessor.java:289)... 27 more什么原因呢?

阅读(1144) | 评论(0) | 转发(0) |
0

上一篇:双城生活

下一篇:Dwr中的Bean

给主人留下些什么吧!~~