Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not start springboot admin, java.lang.NoClassDefFoundError: org/springframework/cloud/netflix/zuul/filters/TraceProxyRequestHelper

when i create the sample project try to use springboot admin follow: http://codecentric.github.io/spring-boot-admin/1.4.1/ kickoff gradle bootRun, i got a java.lang.NoClassDefFoundError: org.springframework.cloud.netflix.zuul.filters.TraceProxyRequestHelper when i changed to the spring boot admin to 1.3.2, it works fine, what jar file i lost? i just want to spring boot admin client via http.

my application java code:

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Configuration;

import de.codecentric.boot.admin.config.EnableAdminServer;

@Configuration
@EnableAutoConfiguration
@EnableAdminServer
public class SpringBootAdminApplication {
    public static void main(String[] args) {
        SpringApplication.run(SpringBootAdminApplication.class, args);
    }
}

my build.gradle

buildscript {
    ext { springBootVersion = '1.4.0.RELEASE' }
    repositories { mavenCentral() }
    dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'spring-boot'

jar {
    baseName = 'demo'
    version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories { mavenCentral() }


dependencies {
    compile('de.codecentric:spring-boot-admin-server:1.4.0')
    compile('de.codecentric:spring-boot-admin-server-ui:1.4.0')
}

error:

  2016-09-01 15:54:46.223  INFO 5678 --- [           main] com.example.DemoApplication              : Starting DemoApplication on E440 with PID 5678 (/home/kalaliu/workspace/springboot/build/classes/main started by kalaliu in /home/kalaliu/workspace/springboot)
  2016-09-01 15:54:46.227  INFO 5678 --- [           main] com.example.DemoApplication              : No active profile set, falling back to default profiles: default
  2016-09-01 15:54:46.294  INFO 5678 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@478190fc: startup date [Thu Sep 01 15:54:46 CST 2016]; root of context hierarchy
  2016-09-01 15:54:47.383 ERROR 5678 --- [           main] o.s.boot.SpringApplication               : Application startup failed

  java.lang.IllegalStateException: Could not evaluate condition on org.springframework.cloud.netflix.zuul.ZuulConfiguration#routeLocator due to org/springframework/cloud/netflix/zuul/filters/TraceProxyRequestHelper not found. Make sure your own configuration does not rely on that class. This can also happen if you are @ComponentScanning a springframework package (e.g. if you put a @ComponentScan in the default package by mistake)
      at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:55) ~[spring-boot-autoconfigure-1.4.0.RELEASE.jar:1.4.0.RELEASE]
      at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:102) ~[spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE]
      at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:178) ~[spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE]
      at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:140) ~[spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE]
      at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:116) ~[spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE]
      at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:333) ~[spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE]
      at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:243) ~[spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE]
      at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProegistrationDelegate.java:273) ~[spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE]
      at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:98) ~[spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE]
      at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:681) ~[spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE]
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:523) ~[spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE]
      at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
      at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
      at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:369) [spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:313) [spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185) [spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174) [spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
      at com.example.DemoApplication.main(DemoApplication.java:15) [main/:na]
  Caused by: java.lang.NoClassDefFoundError: org/springframework/cloud/netflix/zuul/filters/TraceProxyRequestHelper
      at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_60]
      at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[na:1.8.0_60]
      at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[na:1.8.0_60]
      at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:612) ~[spring-core-4.3.2.RELEASE.jar:4.3.2.RELEASE]
      at org.springframework.util.ReflectionUtils.doWithMethodstionUtils.java:524) ~[spring-core-4.3.2.RELEASE.jar:4.3.2.RELEASE]
      at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:510) ~[spring-core-4.3.2.RELEASE.jar:4.3.2.RELEASE]
      at org.springframework.util.ReflectionUtils.getUniqueDeclaredMethods(ReflectionUtils.java:570) ~[spring-core-4.3.2.RELEASE.jar:4.3.2.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:683) ~[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:627) ~[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:597) ~[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1450) ~[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:980) ~[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE]
      at org.springframework.boot.autoconfigure.condition.BeanTypeRegistry$OptimizedBeanTypeRegistry.addBeanTypeForNonAliasDefinition(BeanTypeRegistry.java:289) ~[spring-boot-autoconfigure-1.4.0.RELEASE.jar:1.4.0.RELEASE]
      at org.springframework.boot.autoconfigure.condition.BeanTypeRegistry$OptimizedBeanTypeRegistry.addBeanType(BeanTypeRegistry.java:278) ~[spring-boot-autoconfigure-1.4.0.RELEASE.jar:1.4.0.RELEASE]
      at org.springframework.boot.autoconfigure.condition.BeanTypeRegistry$OptimizedBeanTypeRegistry.getNamesForType(BeanTypeRegistry.java:259) ~[spring-boot-autoconfigure-1.4.0.RELEASE.jar:1.4.0.RELEASE]
      at org.springframework.boot.autoconfigure.condition.OnBeanCondition.collectBeanNamesForType(OnBeanCondition.java:179) ~[spring-boot-autoconfigure-1.4.0.RELEASE.jar:1.4.0.RELEASE]
      at orgframework.boot.autoconfigure.condition.OnBeanCondition.getBeanNamesForType(OnBeanCondition.java:168) ~[spring-boot-autoconfigure-1.4.0.RELEASE.jar:1.4.0.RELEASE]
      at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchingBeans(OnBeanCondition.java:136) ~[spring-boot-autoconfigure-1.4.0.RELEASE.jar:1.4.0.RELEASE]
      at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchOutcome(OnBeanCondition.java:109) ~[spring-boot-autoconfigure-1.4.0.RELEASE.jar:1.4.0.RELEASE]
      at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47) ~[spring-boot-autoconfigure-1.4.0.RELEASE.jar:1.4.0.RELEASE]
      ... 17 common frames omitted
  Caused by: java.lang.ClassNotFoundException: org.springframework.cloud.netflix.zuul.filters.TraceProxyRequestHelper
      at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_60]
      at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_60]
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_60]
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_60]
      ... 37 common frames omitted      
like image 723
kala888 Avatar asked Sep 01 '16 10:09

kala888


2 Answers

Gradle resolves the wrong version of spring-cloud-netfix-core. It should resolve 1.1.5.RELEASE as listed here: https://mvnrepository.com/artifact/de.codecentric/spring-boot-admin-server/1.4.1 but instead it resolves a 1.1.0.RELEASE.

To mitigate this problem you have to import the Brixton.SR4 bom:

dependencyManagement {
  imports {
    mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Brixton.SR4' 
  }
}

p.s.: Please move to SBA 1.4.1 since 1.4.0 is broken!

like image 125
joshiste Avatar answered Nov 15 '22 09:11

joshiste


When using "org.springframework.cloud:spring-cloud-dependencies:Dalston.SR2" and version "1.5.4" of the admin server you may also get a ClassNotFoundException for "org.springframework.cloud.netflix.zuul.ZuulServerAutoConfiguration". I confirmed this behavior on maven 3.3.9 and 3.5.0, but not with gradle. Updating to the "Dalston.SR3" solves the problem.

like image 22
Pytry Avatar answered Nov 15 '22 07:11

Pytry