Thursday, April 27, 2017

spring boot some error log draft


1.What
> java.lang.NoClassDefFoundError jackson.databind.exc.InvalidDefinitionException

Why
because i used spring boot 2.0.0.BUILD-SNAPSHOT, it reference jackson-databind 2.9.0.pr3, but i manual code reference  jackson-databind with old version 2.5.1 in my pom.xml.

How
delete my old 2.5.1 reference, it is ok!

2. What
> Caused by: java.lang.IllegalStateException: You need to configure a uri for the git repository

Why
because i used spring config with native not git mode,and spring.cloud.config.server.native need match with spring.profiles.active=native

How
define below row in application profile:
spring.profiles.active=native

3.What
> Binding to target org.springframework.cloud.config.server.environment.NativeEnvironmentRepository@1584c019 failed:

    Property: spring.cloud.config.server.native.searchLocations
    Value: null
    Reason: Property 'searchLocations' threw exception; nested exception is java.lang.NullPointerException

    Property: spring.cloud.config.server.native.searchLocations
    Value: null,null
    Reason: Property 'searchLocations' threw exception; nested exception is java.lang.NullPointerException

Why
my code is like below, i do not known which is yaml right grammar:
spring:
  cloud:
    config:
      server:
        native:
          search-locations:
          - classpath:/config/
          - classpath:/config/${spring.profiles.active}

How
change to below ,it can run no error:
spring:
  cloud:
    config:
      server:
        native:
          search-locations: classpath:/config/, classpath:/config/${spring.profiles.active}

4. What
> Caused by: java.lang.NoSuchMethodError: com.netflix.servo.monitor.Monitors.isObjectRegistered(Ljava/lang/String;Ljava/lang/Object;)Z

Why
 may be is maven spring boot reference jar version confit, see Wrong dependencies on spring cloud #3316.

How
reference servo-core with new version 0.10+, for example:

<dependency>
    <groupId>com.netflix.servo</groupId>
    <artifactId>servo-core</artifactId>
    <version>0.12.16</version>
</dependency>

5.What
Caused by: java.lang.NoSuchMethodError: org.springframework.aop.framework.AopProxyUtils.getSingletonTarget(Ljava/lang/Object;)Ljava/lang/Object;

Why
Because Spring-Cloud-Config-Server reference spring-aop (1.3.0.RELEASE) with 4.3.7, but spring-boot-startor (1.3.0.RELEASE)  reference spring-aop with 4.3.8, and org.springframework.aop.framework.AopProxyUtils.getSingletonTarget sina 4.3.8,see here

How
reference spring-aop with new version 4.3.8, for example:

<dependency>
    <groupId>com.netflix.servo</groupId>
    <artifactId>servo-core</artifactId>
    <version>0.12.16</version>
</dependency>

6. What
Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.core.filter.TokenFilter

Why
Because Spring-Cloud-Startor-Eureka(1.3.0.RELEASE) reference jackson-core(2.4.3), but spring-cloud-config-server(1.3.0.RELEASE) reference jackson-databind(2.8.7)

How
reference jackson-core with new version 2.8.8, for example:

<dependency>
    <groupId>com.netflix.archaius</groupId>
    <artifactId>archaius-core</artifactId>
    <version>0.7.5</version>
</dependency>
<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-core</artifactId>
    <version>2.8.8</version>
</dependency>

7. What
Caused by: java.lang.ClassNotFoundException: com.ecwid.consul.v1.ConsulClient

Why

How
<dependency>
    <groupId>com.ecwid.consul</groupId>
    <artifactId>consul-api</artifactId>
    <version>1.2.2</version>
</dependency>

8. What
Description Resource Path Location Type
Class dependency error 'org/springframework/integration/dsl/IntegrationFlow' occurred on aspect definition 'Aspect definition [\myzc_microsrv_consul\src\main\java\consul\Application.java:-1] advise type [after] advise [com.netflix.hystrix.contrib.javanica.aop.aspectj.HystrixCommandAspect.methodsAnnotatedWithHystrixCommand(org.aspectj.lang.ProceedingJoinPoint)]' while processing bean 'org.springframework.cloud.consul.bus.ConsulBusAutoConfiguration (53) [org.springframework.cloud.consul.bus.ConsulBusAutoConfiguration]'. Check if builder classpath is complete Application.java /myzc_microsrv_consul/src/main/java/consul line 53 Spring AOP Problem

How
<dependency>
    <groupId>org.springframework.integration</groupId>
    <artifactId>spring-integration-java-dsl</artifactId>
    <version>1.2.1.RELEASE</version>
</dependency>

9. What
Class dependency error 'org/joda/time/Period'

How
<dependency>
    <groupId>joda-time</groupId>
    <artifactId>joda-time</artifactId>
   <version>2.9.9</version>
</dependency>

10. What
Class dependency error 'org/springframework/cloud/bus/event/RemoteApplicationEvent' occurred on aspect definition 'Aspect definition [\myzc_microsrv_consul\src\main\java\consul\Application.java:-1] advise type [after] advise [org.springframework.cloud.netflix.metrics.RestTemplateUrlTemplateCapturingAspect.captureUrlTemplate(org.aspectj.lang.ProceedingJoinPoint)]' while processing bean 'application (53) [consul.Application]'. Check if builder classpath is complete Application.java /myzc_microsrv_consul/src/main/java/consul line 53 Spring AOP Problem

How
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-bus</artifactId>
    <version>1.3.0.RELEASE</version>
</dependency>

11. What
com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server ...
or
com.sun.jersey.api.client.ClientHandlerException: java.lang.IllegalArgumentException: Host name may not be null ...

Why
I used eureka hostname has only word,not split with '.'
eureka:
  instance:
    hostname: myzc_microsrv_config
  client:
    registerWithEureka: true
    fetchRegistry: true
    serviceUrl:
      defaultZone: http://myzc_microsrv_discovery:8761/eureka/

How change host name with '.' not '_'
defaultZone: http://myzc.microsrv.discovery:8761/eureka/

12. What
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.WebApplicationType


Caused by: java.lang.ClassNotFoundException: org.springframework.boot.context.properties.bind.PlaceholdersResolver

 
Caused by: java.lang.ClassNotFoundException: class org.springframework.cloud.client.HostInfoEnvironmentPostProcessor

How
in parent's project, edit pom.xml:
    <parent>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-parent</artifactId>
        <version>Camden.SR6</version>
        <relativePath/>
    </parent>

13.
What
spring boot jpa Not a managed type:

How:
In application main class,add annotation:
@EntityScan("your domain package name")

14.
What Caused by: org.hibernate.MappingException: Could not determine type for: java.util.Map, at table: myzc_json_record, for columns: [org.hibernate.mapping.Column(ext)]

How:
see How to use Postgres JSONB datatype with JPA?.