java.lang.ClassCastException: TestController cannot be cast to TestController

Spring JIRA | arnolf | 4 years ago
  1. 0

    To use Groovy controllers, proxy-target-class attribute has to be set to true (SPR-6268). To turn on the refreshable beans feature, refresh-check-delay has to be set. {code:xml} <lang:groovy refresh-check-delay="500" proxy-target-class="true" script-source="classpath:TestController.groovy"/> {code} When we use both, refreshing modified Groovy controller throws {{ClassCastException}} : {noformat} java.lang.ClassCastException: TestController cannot be cast to TestController at TestController$$FastClassByCGLIB$$bfb641ee.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:698) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131) at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:631) at TestController$$EnhancerByCGLIB$$a8e94a91.printWelcome(<generated>) 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.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:439) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:427) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:915) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:811) at javax.servlet.http.HttpServlet.service(HttpServlet.java:617) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:796) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646) at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:551) at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:488) at org.apache.taglibs.standard.tag.common.core.ImportSupport.acquireString(ImportSupport.java:296) at org.apache.taglibs.standard.tag.common.core.ImportSupport.doEndTag(ImportSupport.java:161) at org.apache.jsp.WEB_002dINF.pages.hello_jsp._jspx_meth_c_005fimport_005f0(hello_jsp.java:98) {noformat}

    Spring JIRA | 4 years ago | arnolf
    java.lang.ClassCastException: TestController cannot be cast to TestController
  2. 0

    To use Groovy controllers, proxy-target-class attribute has to be set to true (SPR-6268). To turn on the refreshable beans feature, refresh-check-delay has to be set. {code:xml} <lang:groovy refresh-check-delay="500" proxy-target-class="true" script-source="classpath:TestController.groovy"/> {code} When we use both, refreshing modified Groovy controller throws {{ClassCastException}} : {noformat} java.lang.ClassCastException: TestController cannot be cast to TestController at TestController$$FastClassByCGLIB$$bfb641ee.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:698) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131) at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:631) at TestController$$EnhancerByCGLIB$$a8e94a91.printWelcome(<generated>) 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.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:439) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:427) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:915) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:811) at javax.servlet.http.HttpServlet.service(HttpServlet.java:617) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:796) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646) at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:551) at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:488) at org.apache.taglibs.standard.tag.common.core.ImportSupport.acquireString(ImportSupport.java:296) at org.apache.taglibs.standard.tag.common.core.ImportSupport.doEndTag(ImportSupport.java:161) at org.apache.jsp.WEB_002dINF.pages.hello_jsp._jspx_meth_c_005fimport_005f0(hello_jsp.java:98) {noformat}

    Spring JIRA | 4 years ago | arnolf
    java.lang.ClassCastException: TestController cannot be cast to TestController
  3. 0

    Memcached Java客户端2.6.1发布 - 编程语言 - ITeye资讯

    iteye.com | 1 year ago
    java.lang.ClassCastException: cannot be cast to
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    ClassCastException in HandleFactory.getPkgFragmentRoot (355)

    Eclipse Bugzilla | 1 year ago | error-reports-inbox
    java.lang.ClassCastException: cannot be cast to org.eclipse.wst.jsdt.internal.core.PackageFragmentRoot
  6. 0

    Bug ID: JDK-6499662 "java.lang.ClassCastException: cannot be cast to java.lang.String" happens from time to time

    sun.com | 4 months ago
    java.lang.ClassCastException: cannot be cast to java.lang.String

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.ClassCastException

      TestController cannot be cast to TestController

      at TestController$$FastClassByCGLIB$$bfb641ee.invoke()
    2. Unknown
      TestController$$FastClassByCGLIB$$bfb641ee.invoke
      1. TestController$$FastClassByCGLIB$$bfb641ee.invoke(<generated>)
      1 frame
    3. Spring Core
      MethodProxy.invoke
      1. org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
      1 frame
    4. Spring AOP
      CglibAopProxy$DynamicAdvisedInterceptor.intercept
      1. org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:698)
      2. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
      3. org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
      4. org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
      5. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      6. org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:631)
      6 frames
    5. Unknown
      TestController$$EnhancerByCGLIB$$a8e94a91.printWelcome
      1. TestController$$EnhancerByCGLIB$$a8e94a91.printWelcome(<generated>)
      1 frame
    6. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      4. java.lang.reflect.Method.invoke(Method.java:597)
      4 frames
    7. Spring
      HandlerMethodInvoker.invokeHandlerMethod
      1. org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
      1 frame
    8. Spring MVC
      FrameworkServlet.doGet
      1. org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:439)
      2. org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:427)
      3. org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
      4. org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
      5. org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:915)
      6. org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:811)
      6 frames
    9. JavaServlet
      HttpServlet.service
      1. javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
      1 frame
    10. Spring MVC
      FrameworkServlet.service
      1. org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:796)
      1 frame
    11. JavaServlet
      HttpServlet.service
      1. javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      1 frame
    12. Glassfish Core
      ApplicationDispatcher.include
      1. org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      2. org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      3. org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
      4. org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:551)
      5. org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:488)
      5 frames
    13. JSTL
      ImportSupport.doEndTag
      1. org.apache.taglibs.standard.tag.common.core.ImportSupport.acquireString(ImportSupport.java:296)
      2. org.apache.taglibs.standard.tag.common.core.ImportSupport.doEndTag(ImportSupport.java:161)
      2 frames
    14. org.apache.jsp
      hello_jsp._jspx_meth_c_005fimport_005f0
      1. org.apache.jsp.WEB_002dINF.pages.hello_jsp._jspx_meth_c_005fimport_005f0(hello_jsp.java:98)
      1 frame