java.lang.ClassCastException: org.springframework.boot.autoconfigure.condition.SearchStrategy cannot be cast to org.springframework.boot.autoconfigure.condition.SearchStrategy

SpringSource Issue Tracker | Martin Lippert | 3 years ago
  1. 0

    There is a ClassCastException coming up when building the workspace: {noformat} java.lang.ClassCastException: org.springframework.boot.autoconfigure.condition.SearchStrategy cannot be cast to org.springframework.boot.autoconfigure.condition.SearchStrategy at org.springframework.boot.autoconfigure.condition.OnBeanCondition$BeanSearchSpec.<init>(OnBeanCondition.java:205) at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchOutcome(OnBeanCondition.java:75) at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:44) at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:92) at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader$TrackedConditionEvaluator.shouldSkip(ConfigurationClassBeanDefinitionReader.java:400) at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:127) at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:116) at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:324) at org.springframework.ide.eclipse.metadata.process.JdtConfigurationClassPostProcessor.postProcess(JdtConfigurationClassPostProcessor.java:88) at org.springframework.ide.eclipse.beans.core.internal.model.BeansJavaConfig$3.run(BeansJavaConfig.java:317) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.springframework.ide.eclipse.beans.core.internal.model.BeansJavaConfig.executePostProcessor(BeansJavaConfig.java:310) at org.springframework.ide.eclipse.beans.core.internal.model.BeansJavaConfig.access$5(BeansJavaConfig.java:308) at org.springframework.ide.eclipse.beans.core.internal.model.BeansJavaConfig$2.call(BeansJavaConfig.java:223) at org.springframework.ide.eclipse.beans.core.internal.model.BeansJavaConfig$2.call(BeansJavaConfig.java:1) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:744) {noformat} Steps to reproduce: Import all of the Spring Boot projects into a clean workspace (Import as Existing Maven Project). Doing a clean build of the "spring-boot-actuator" produces this exception. Investigation: This is caused by the project dependency between the actuator and the boot-autoconfigure projects. We use specific classloaders for loading classes from a project (instead of the IDE). Those classloaders share the same parent classloader for the libraries that are on the classpath of the project, but have different child classloaders for the output folders of the projects. Since those classloaders are created in multiple places, there are multiple classloaders sitting around that load classes from project output folders (as well as the output folders of project dependencies within the same workspace). This is causing the ClassCastException. Solution: Creating a new child classloader each time makes sense to avoid caching of loaded classes from those projects (since you are working on them in the IDE). Therefore we need to make sure that the same classloader is using throughout the project build (in case classes are shared among the different parts).

    SpringSource Issue Tracker | 3 years ago | Martin Lippert (c)
    java.lang.ClassCastException: org.springframework.boot.autoconfigure.condition.SearchStrategy cannot be cast to org.springframework.boot.autoconfigure.condition.SearchStrategy
  2. 0

    There is a ClassCastException coming up when building the workspace: {noformat} java.lang.ClassCastException: org.springframework.boot.autoconfigure.condition.SearchStrategy cannot be cast to org.springframework.boot.autoconfigure.condition.SearchStrategy at org.springframework.boot.autoconfigure.condition.OnBeanCondition$BeanSearchSpec.<init>(OnBeanCondition.java:205) at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchOutcome(OnBeanCondition.java:75) at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:44) at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:92) at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader$TrackedConditionEvaluator.shouldSkip(ConfigurationClassBeanDefinitionReader.java:400) at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:127) at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:116) at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:324) at org.springframework.ide.eclipse.metadata.process.JdtConfigurationClassPostProcessor.postProcess(JdtConfigurationClassPostProcessor.java:88) at org.springframework.ide.eclipse.beans.core.internal.model.BeansJavaConfig$3.run(BeansJavaConfig.java:317) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.springframework.ide.eclipse.beans.core.internal.model.BeansJavaConfig.executePostProcessor(BeansJavaConfig.java:310) at org.springframework.ide.eclipse.beans.core.internal.model.BeansJavaConfig.access$5(BeansJavaConfig.java:308) at org.springframework.ide.eclipse.beans.core.internal.model.BeansJavaConfig$2.call(BeansJavaConfig.java:223) at org.springframework.ide.eclipse.beans.core.internal.model.BeansJavaConfig$2.call(BeansJavaConfig.java:1) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:744) {noformat} Steps to reproduce: Import all of the Spring Boot projects into a clean workspace (Import as Existing Maven Project). Doing a clean build of the "spring-boot-actuator" produces this exception. Investigation: This is caused by the project dependency between the actuator and the boot-autoconfigure projects. We use specific classloaders for loading classes from a project (instead of the IDE). Those classloaders share the same parent classloader for the libraries that are on the classpath of the project, but have different child classloaders for the output folders of the projects. Since those classloaders are created in multiple places, there are multiple classloaders sitting around that load classes from project output folders (as well as the output folders of project dependencies within the same workspace). This is causing the ClassCastException. Solution: Creating a new child classloader each time makes sense to avoid caching of loaded classes from those projects (since you are working on them in the IDE). Therefore we need to make sure that the same classloader is using throughout the project build (in case classes are shared among the different parts).

    SpringSource Issue Tracker | 3 years ago | Martin Lippert
    java.lang.ClassCastException: org.springframework.boot.autoconfigure.condition.SearchStrategy cannot be cast to org.springframework.boot.autoconfigure.condition.SearchStrategy
  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

    Scala 2.11.5 and Squeryl?

    Google Groups | 2 years ago | Clint Gilbert
    java.lang.ClassCastException: scala.None$ cannot be cast to
  6. 0

    adam2vcf

    Google Groups | 8 months ago | someya sayeh
    java.lang.ClassCastException: org.bdgenomics.formats.avro.Fragment cannot be cast to

    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

      org.springframework.boot.autoconfigure.condition.SearchStrategy cannot be cast to org.springframework.boot.autoconfigure.condition.SearchStrategy

      at org.springframework.boot.autoconfigure.condition.OnBeanCondition$BeanSearchSpec.<init>()
    2. Spring Boot AutoConfigure
      SpringBootCondition.matches
      1. org.springframework.boot.autoconfigure.condition.OnBeanCondition$BeanSearchSpec.<init>(OnBeanCondition.java:205)
      2. org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchOutcome(OnBeanCondition.java:75)
      3. org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:44)
      3 frames
    3. Spring Context
      ConfigurationClassPostProcessor.processConfigBeanDefinitions
      1. org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:92)
      2. org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader$TrackedConditionEvaluator.shouldSkip(ConfigurationClassBeanDefinitionReader.java:400)
      3. org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:127)
      4. org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:116)
      5. org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:324)
      5 frames
    4. org.springframework.ide
      BeansJavaConfig$3.run
      1. org.springframework.ide.eclipse.metadata.process.JdtConfigurationClassPostProcessor.postProcess(JdtConfigurationClassPostProcessor.java:88)
      2. org.springframework.ide.eclipse.beans.core.internal.model.BeansJavaConfig$3.run(BeansJavaConfig.java:317)
      2 frames
    5. Eclipse Core
      SafeRunner.run
      1. org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
      1 frame
    6. org.springframework.ide
      BeansJavaConfig$2.call
      1. org.springframework.ide.eclipse.beans.core.internal.model.BeansJavaConfig.executePostProcessor(BeansJavaConfig.java:310)
      2. org.springframework.ide.eclipse.beans.core.internal.model.BeansJavaConfig.access$5(BeansJavaConfig.java:308)
      3. org.springframework.ide.eclipse.beans.core.internal.model.BeansJavaConfig$2.call(BeansJavaConfig.java:223)
      4. org.springframework.ide.eclipse.beans.core.internal.model.BeansJavaConfig$2.call(BeansJavaConfig.java:1)
      4 frames
    7. Java RT
      Thread.run
      1. java.util.concurrent.FutureTask.run(FutureTask.java:266)
      2. java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      3. java.util.concurrent.FutureTask.run(FutureTask.java:266)
      4. java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      5. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      6. java.lang.Thread.run(Thread.java:744)
      6 frames