Uploaded image for project: 'Weld'
  1. Weld
  2. WELD-996

ClassCastException validating custom Interceptor implementation

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Critical
    • Resolution: Done
    • Affects Version/s: 1.1.2.Final
    • Fix Version/s: 1.1.3.Final
    • Component/s: None
    • Labels:
      None
    • Affects:
      Release Notes

      Description

      Having a custom implementation of the Interceptor interface registered with Weld, the validation always fails if the interceptor happens to intercept a passivation capable bean. Weld incorrectly casts the interceptor to InterceptorImpl which is not valid for extension-provided interceptors.

      java.lang.ClassCastException: org.jboss.seam.classic.intercept.ClassicInterceptor cannot be cast to org.jboss.weld.bean.InterceptorImpl
              at org.jboss.as.weld.services.WeldService.start(WeldService.java:96)
              at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
              at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
              at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_24]
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_24]
              at java.lang.Thread.run(Thread.java:662) [:1.6.0_24]
      Caused by: java.lang.ClassCastException: org.jboss.seam.classic.intercept.ClassicInterceptor cannot be cast to org.jboss.weld.bean.InterceptorImpl
              at org.jboss.weld.bootstrap.Validator.validateInterceptors(Validator.java:171)
              at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:151)
              at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:351)
              at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:336)
              at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:404)
              at org.jboss.as.weld.WeldContainer.start(WeldContainer.java:82)
              at org.jboss.as.weld.services.WeldService.start(WeldService.java:89)
              ... 5 more
      

        Gliffy Diagrams

          Issue Links

            Activity

            Hide
            jharting Jozef Hartinger added a comment -

            Added test org.jboss.weld.tests.interceptors.extension.CustomInterceptorRegistrationTest.testCustomInterceptorRegistration()

            Show
            jharting Jozef Hartinger added a comment - Added test org.jboss.weld.tests.interceptors.extension.CustomInterceptorRegistrationTest.testCustomInterceptorRegistration()
            Hide
            alesj Ales Justin added a comment -

            Cast is fixed – checking for actual instance.
            TODO on real custom iceptor usage.

            Show
            alesj Ales Justin added a comment - Cast is fixed – checking for actual instance. TODO on real custom iceptor usage.
            Hide
            jharting Jozef Hartinger added a comment -

            I don't think the Serializable check is correct. According to the spec (6.6.1) we should check for the PassivationCapable interface to see if a given Bean implementation is passivation capable or not.

            Show
            jharting Jozef Hartinger added a comment - I don't think the Serializable check is correct. According to the spec (6.6.1) we should check for the PassivationCapable interface to see if a given Bean implementation is passivation capable or not.
            Hide
            alesj Ales Justin added a comment -

            OK, fix it accordingly then.
            But I guess that means then we shouldn't (and can't) do a check on actual Interceptor instance.

            Show
            alesj Ales Justin added a comment - OK, fix it accordingly then. But I guess that means then we shouldn't (and can't) do a check on actual Interceptor instance.
            Hide
            jharting Jozef Hartinger added a comment - - edited

            My understanding is that if an extension-provided Interceptor implementation (e.g. CustomInterceptorImpl) is registered, Weld should recognize it to be passivation capable if and only if CustomInterceptorImpl implements the PassivationCapable interface. That should be the only indicator and we should not check if the underlying class, which CustomInterceptorImpl may be using, implements Serializable or not. Otherwise, that would go against the abstraction the SPI provides.

            Show
            jharting Jozef Hartinger added a comment - - edited My understanding is that if an extension-provided Interceptor implementation (e.g. CustomInterceptorImpl) is registered, Weld should recognize it to be passivation capable if and only if CustomInterceptorImpl implements the PassivationCapable interface. That should be the only indicator and we should not check if the underlying class, which CustomInterceptorImpl may be using, implements Serializable or not. Otherwise, that would go against the abstraction the SPI provides.

              People

              • Assignee:
                jharting Jozef Hartinger
                Reporter:
                jharting Jozef Hartinger
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Development