Spring代理的问题 报java.lang.ClassCastException: $Proxy19 只有一个出问题 诡异~ 无解啊

问题描述

通过SpringAop配置的service报一下的错误 BaseService baseService; baseService = (BaseService) applicationContext.getBean("service_111"); BaseService 是一个接口,beanId为service_111的类实现这个接口,而且还有很多类实现这个接口,唯独调用这个累的时候进行强转的时候报以下错误,使用junit测试都好用,放在测试环境就报错 ,请大家帮忙! 这个时间 人很少么?大家帮看看 诡异问题出在别的类调用没有问题 只有一个出问题java.lang.ClassCastException: $Proxy19 at com.tstn.report.action.ReportDispatchImpl.dispatch(ReportDispatchImpl.java:51) at sun.reflect.GeneratedMethodAccessor1096.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:592) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at $Proxy18.dispatch(Unknown Source) at com.tstn.report.webservice.OnReportServiceImpl.OnBoss4Report(OnReportServiceImpl.java:32) at sun.reflect.GeneratedMethodAccessor731.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:592) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198) at $Proxy23.OnBoss4Report(Unknown Source) at sun.reflect.GeneratedMethodAccessor731.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:592) at org.codehaus.xfire.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:59) at org.codehaus.xfire.service.binding.ServiceInvocationHandler.sendMessage(ServiceInvocationHandler.java:320) at org.codehaus.xfire.service.binding.ServiceInvocationHandler$1.run(ServiceInvocationHandler.java:86) at org.codehaus.xfire.service.binding.ServiceInvocationHandler.execute(ServiceInvocationHandler.java:134) at org.codehaus.xfire.service.binding.ServiceInvocationHandler.invoke(ServiceInvocationHandler.java:109) at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131) at org.codehaus.xfire.transport.DefaultEndpoint.onReceive(DefaultEndpoint.java:64) at org.codehaus.xfire.transport.AbstractChannel.receive(AbstractChannel.java:38) at org.codehaus.xfire.transport.http.XFireServletController.invoke(XFireServletController.java:304) at org.codehaus.xfire.transport.http.XFireServletController.doService(XFireServletController.java:129) at org.codehaus.xfire.spring.remoting.XFireServletControllerAdapter.handleRequest(XFireServletControllerAdapter.java:67) at org.codehaus.xfire.spring.remoting.XFireExporter.handleRequest(XFireExporter.java:48) at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511) at javax.servlet.http.HttpServlet.service(HttpServlet.java:709) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:253) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:216) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:891) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:783) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:548) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) at java.lang.Thread.run(Thread.java:595)

解决方案

或者直接查条代码:Object bean = applicationContext.getBean("service_111");if(bean instanceof BaseService) { baseService = (BaseService) bean ; } else { logger.warn("Error Type: " + bean.getClass().getName());}看看类型到底是啥
解决方案二:
应该与代理无关,多检查下代码吧,呵呵
解决方案三:
BaseService baseService; baseService = (BaseService) applicationContext.getBean("service_111"); 类型强制转换出错

时间: 2024-10-24 02:59:14

Spring代理的问题 报java.lang.ClassCastException: $Proxy19 只有一个出问题 诡异~ 无解啊的相关文章

wordcountapp-hadoop 报java.lang.InstantiationException

问题描述 hadoop 报java.lang.InstantiationException package mapreduce; import java.io.IOException; import org.apache.hadoop.conf.Configuration;import org.apache.hadoop.fs.Path;import org.apache.hadoop.io.LongWritable;import org.apache.hadoop.io.Text;import

c java jna-window2008server上用jna调用Native.loadlibrary报java.lang.UnsatisfiedLinkError:

问题描述 window2008server上用jna调用Native.loadlibrary报java.lang.UnsatisfiedLinkError: window2008server上用jna调用Native.loadlibrary报java.lang.UnsatisfiedLinkError: Unable to load library 'helloworld.dll: ???????¨,32位win系统好用,请问大侠们有谁遇到过类似的情况,怎么解决,急!!! 解决方案 去掉.dll

图片-svn更新后,jsp页面报java.lang.NullPointerException

问题描述 svn更新后,jsp页面报java.lang.NullPointerException 请大神指点 谢谢 解决方案 svn一般要先更新再提交,有报错的话就先修改错误 解决方案二: 空指针异常,看看你同组的人有没有修改过东西,没有全部上传

db4o数据库存放的class含有相同的字段名且字段的类型也相同。现在想把这个库中数据读出来,但总是报 java.lang.ClassCastException错误

db4o数据库存放的class含有相同的字段名且字段的类型也相同.现在想把这个库中数据读出来,但总是报 java.lang.ClassCastException错误,请大侠指教 具体情况如下:   ObjectContainer db =null;    try {    db = Db4o.openFile("bean.yap");List<AlarmFilter> list_a = db.get(AlarmFilter.class);     for(int x = 0

没有方法异常-做ssh项目报java.lang.NoSuchMethodException

问题描述 做ssh项目报java.lang.NoSuchMethodException type Exception report message com.action.LoginAction.Login() description The server encountered an internal error that prevented it from fulfilling this request. exception java.lang.NoSuchMethodException: c

图片打印报错-java打印图片报 java.lang.ArrayIndexOutOfBoundsException: 6

问题描述 java打印图片报 java.lang.ArrayIndexOutOfBoundsException: 6 public class Print { public static void main(String[] args) { FileInputStream fin=null; try { fin = new FileInputStream("D:/image/image1.jpg"); } catch (FileNotFoundException e) { // TOD

cts-CTS测试报java.lang.SecurityException

问题描述 CTS测试报java.lang.SecurityException java.lang.AssertionError: Failed to successfully run device tests for com.android.cts.net.hostside: Instrumentation run failed due to 'java.lang.SecurityException' at com.android.cts.net.HostsideNetworkTests.run

android eclipse 2.2版本ChatUIDemo集成红包报java.lang.NoClassDefFoundError: com.easemob.chat.EMChat(已解决)

问题描述 android eclipse下,sdk为2.2版本下,仅仅demo(ChatUIDemo)可编译运行.Android版本为6.0集成红包,编译可通过,运行报java.lang.NoClassDefFoundError: com.easemob.chat.EMChat. 解决方案 问题已解决.解决方式:使用Android studio来开发就行.环信团队在开发红包功能时是在Android studio环境下开发,是好的.估计因为时间紧,没有在eclipse下充分测试.虽然做出来了,但是

websphere下报java.lang.NoSuchMethodError

问题描述 我使用的webspherewas7.0服务器,会报java.lang.NoSuchMethodError,但是在测试环境上是正常的,测试环境和生产环境是同样的 解决方案 解决方案二:提供一条线索-非常有可能就是你的project引用的lib库包和was里面的库包冲突了,自己排查吧