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
tip
Do you know that we can give you better hits? Get more relevant results from Samebug’s stack trace search.
  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

    Help:basic RMI question

    Google Groups | 2 decades ago | Paolo De Lutiis
    java.lang.ClassCastException: serverPackage.ServerClass_Stub at clientPackage.myApplet.init(myApplet.java:line#) at sun.applet.AppletPanel.run(AppletPanel.java:273) at java.lang.Thread.
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Shared hosting Bungeecord problems.

    GitHub | 3 years ago | Arksenu
    java.lang.ClassCastException: bka cannot be cast to fs All my servers are set to onlinemode: false Here is my config.yml groups: arksenu: - admin disabled_commands: - find player_limit: -1 stats: 347d1d62-6fb6-4869-bd43-7d0745de8e3c permissions: default: - bungeecord.command.server - bungeecord.command.list admin: - bungeecord.command.ip - bungeecord.command.alert - bungeecord.command.end - bungeecord.command.reload listeners: - max_players: 18 fallback_server: hub host: 0.0.0.0:35289 bind_local_address: true ping_passthrough: false tab_list: GLOBAL_PING default_server: hub forced_hosts: pvp.md-5.net: hub tab_size: 60 force_default_server: true motd: ’Network’ query_enabled: false query_port: 25565 timeout: 30000 connection_throttle: 4000 servers: hub: address: 108.170.8.146:35289 restricted: false motd: test UvGames: address: 66.85.165.170:26200 restricted: false motd: test UvPrison: address: 66.85.128.90:25928 restricted: false motd: test ip_forward: false online_mode: true And here is my console message -> UpstreamBridge has disconnected disconnected with: Exception Connecting:RuntimeException : Server is online mode! @ net.md_5.bungee.ServerConnector:188
  6. 0

    Shared hosting Bungeecord problems.

    GitHub | 3 years ago | Arksenu
    java.lang.ClassCastException: bka cannot be cast to fs All my servers are set to onlinemode: false Here is my config.yml groups: arksenu: - admin disabled_commands: - find player_limit: -1 stats: 347d1d62-6fb6-4869-bd43-7d0745de8e3c permissions: default: - bungeecord.command.server - bungeecord.command.list admin: - bungeecord.command.ip - bungeecord.command.alert - bungeecord.command.end - bungeecord.command.reload listeners: - max_players: 18 fallback_server: hub host: 0.0.0.0:35289 bind_local_address: true ping_passthrough: false tab_list: GLOBAL_PING default_server: hub forced_hosts: pvp.md-5.net: hub tab_size: 60 force_default_server: true motd: ’Network’ query_enabled: false query_port: 25565 timeout: 30000 connection_throttle: 4000 servers: hub: address: 108.170.8.146:35289 restricted: false motd: test UvGames: address: 66.85.165.170:26200 restricted: false motd: test UvPrison: address: 66.85.128.90:25928 restricted: false motd: test ip_forward: false online_mode: true And here is my console message -> UpstreamBridge has disconnected disconnected with: Exception Connecting:RuntimeException : Server is online mode! @ net.md_5.bungee.ServerConnector:188

    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