3

My code compiles fine but when I try to run my Jar, I get the following error in the stack trace

java.lang.IllegalStateException: Error processing condition on org.springframework.cloud.stream.config.codec.kryo.KryoCodecAutoConfiguration
Caused by: java.lang.IllegalStateException: Failed to introspect Class [org.springframework.cloud.stream.config.ChannelBindingAutoConfiguration] from ClassLoader       [org.springframework.boot.loader.LaunchedURLClassLoader@439f5b3d]

Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/actuate/endpoint/AbstractEndpoint
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.actuate.endpoint.AbstractEndpoint

I have added actuator as a dependency in my pom.xml as well. Here are all the dependencies :

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-amqp</artifactId>
    </dependency>
    <dependency>
        <groupId>org.apache.kafka</groupId>
        <artifactId>kafka-streams</artifactId>
        <version>1.0.1</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-stream-rabbit</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
</dependencies>

What am I missing? Can it be because of the spring boot version that I am using?

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.1.RELEASE</version>
</parent>

I also want to understand where this actuator is coming in the picture from, as I have just two classes in this dummy project.

package demo.example.jobIDProcessor;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Processor;
import org.springframework.integration.annotation.Transformer;
@EnableBinding(Processor.class)
@SpringBootApplication
public class JobIDProcessorApplication {

 @Transformer(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT)
    public String fetchJD(String jobID) {
        return "ye raha JD of "+jobID;
    }

public static void main(String[] args) {
    SpringApplication.run(JobIDProcessorApplication.class, args);
}
}

and the following

package demo.example.jobIDProcessor;

import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Processor;
import org.springframework.integration.annotation.Transformer;


@EnableBinding(Processor.class)
public class JobIDProcessorConfig {
 @Transformer(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT)
    public String fetchJD(String jobID) {
        return "ye raha JD of "+jobID;
    }
}

Where is this "org/springframework/boot/actuate/endpoint/AbstractEndpoint" being called from?

frigocat
  • 283
  • 2
  • 13
  • It appears you're building a Spring Cloud Stream application. Can you also edit the post showing all the dependencies in entirety? One other thing. Along with Actuator, you also need to add `spring-boot-starter-web` to be able to access the Actuator endpoints via HTTP. – Sabby Anandan Apr 19 '18 at 16:32
  • Yes I was trying my hands on Spring Cloud data flow. I tried after adding spring-boot-starter-web as well. Still the same error. – frigocat Apr 19 '18 at 21:29
  • Odd! Few things: 1) `KryoCodecAutoConfiguration` is not in Spring Cloud Stream 2.0 anymore; it used to be in 1.3.x - not sure why you've that in stacktrace. 2) It appears you're using Rabbit binder, but you also have KStreams library - why can't you directly use KStream binder instead? – Sabby Anandan Apr 19 '18 at 21:41
  • 1
    For clarity, please download a brand new App from Initializr with Rabbit binder and package that to a uber-jar. Follow this instruction from [quick-start](https://docs.spring.io/spring-cloud-stream/docs/Elmhurst.RELEASE/reference/htmlsingle/#_quick_start). Once it runs standalone via `java -jar ...`, it will then also work in SCDF. – Sabby Anandan Apr 19 '18 at 21:42
  • Works just fine now! In my original demo, I had added both RabbitMQ and kafka as dependency. But now when I created separate apps from scratch, its working fine! Thanks @SabbyAnandan – frigocat Apr 20 '18 at 06:23

1 Answers1

0

This is mainly related to the cloud stream dependencies version you are using. Please try to add the following in the pom.xml

 <dependencyManagement>
    <dependencies>
        <dependency>
            <!-- Import dependency management from Spring Boot -->
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-stream-dependencies</artifactId>
            <version>Fishtown.BUILD-SNAPSHOT</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>
<repositories>
    <repository>
        <id>spring-snapshots</id>
        <name>Spring Snapshots</name>
        <url>https://repo.spring.io/libs-snapshot</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>

This will point to the latest version of cloud-stream-dependencies which refers to the right version of actuator