我们用spring注入了一个类,
<bean id="frameService" class="com.test.service.FrameService" lazy-init="true">
</bean>而宁外的一个服务类(不能有延迟注入的类)中需要这个对象,
ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(sc);
WebServiceServerImpl frameServiceImpl = null;我通过这样的方式获取bean,但是我们spring的配置文件中,上面有事务的切入:
<!-- Spring AOP config -->
<aop:config>
<!-- 切入点 -->
<aop:pointcut id="newServicesPointcut"
expression="execution(* com.test.service.*.*(..))" />
<aop:advisor advice-ref="txAdvice"
pointcut-ref="newServicesPointcut" />
</aop:config>所以通过获取的bean又会有类型转换异常!
<bean id="frameService" class="com.test.service.FrameService" lazy-init="true">
</bean>而宁外的一个服务类(不能有延迟注入的类)中需要这个对象,
ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(sc);
WebServiceServerImpl frameServiceImpl = null;我通过这样的方式获取bean,但是我们spring的配置文件中,上面有事务的切入:
<!-- Spring AOP config -->
<aop:config>
<!-- 切入点 -->
<aop:pointcut id="newServicesPointcut"
expression="execution(* com.test.service.*.*(..))" />
<aop:advisor advice-ref="txAdvice"
pointcut-ref="newServicesPointcut" />
</aop:config>所以通过获取的bean又会有类型转换异常!
解决方案 »
- 数据类型的问题
- jsp连接sqlserver2005问题
- 有人能讲下jsp里 用hidden传一个string数组到另外一个页面怎么传吗?
- tomcat4.0配置出错,请教?PARSE error at line 195 column 11
- 关于STRUST2.0 的提问。。新手 勿笑
- 我有一个全站程序,他的数据库是access的,可选"查询"项,如下网址所示,出现了很多表,(我以前做网站时都没在"查询"项内建过表,都是直接在表
- ????????????
- 关于JSP的一个小问题,困绕小弟很久了,请大家帮帮忙!
- SSH的网络教学平台遇到了数据不能在jsp显示的问题 行数是对的,但行里面没有数据
- ext 后台获取数据源
- eclipse连接sql server2008 出现错误
- java 权限管理
ClassCastException: Cannot cast $Proxy41
你是用WebServiceServerImpl 这个的引用去获得这个bean的么, WebServiceServerImpl 和FrameService是什么关系啊.
我代码没有粘全。全文如下:
ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(sc);
FrameService frameService = ctx.getBean(“frameService”, FrameService.class);
实现了接口的!
我觉得问题可能在我们spring事务配置这个地方。因为我们其他的注入类,我用这样的方式是可以访问到的。除了那些有事务切入的类,我访问的时候,才会有对象转换异常!