0

I'm trying to send messages from a Java service to RabbitMQ.

I'm using some Java RabbitMQ client library and trying to run the following code:

    private static Client setAcceptAllSSL() throws Exception {
        TrustStrategy acceptingTrustStrategy = (cert, authType) -> true;
        SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(null, acceptingTrustStrategy).build();
        SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE);
        requestFactory = new HttpComponentsRestTemplateConfigurator(sslsf,sslContext);
        return new Client(new ClientParameters().url(url).username(username).password(password).restTemplateConfigurator(requestFactory));
    }

In the last line (Client objectinitialization), the following error is thrown:

java.lang.NoClassDefFoundError: org/springframework/http/converter/json/Jackson2ObjectMapperBuilder

I think I might be missing something in my pom.xml or maybe something with the version of Spring. However, I have not been able to find any missing import/library/version issues.

Please help :)

3
  • For me, this method throws ClassNotFoundException: org.springframework.http.client.ClientHttpRequestFactory. Commented May 9, 2021 at 16:06
  • 1
    Do you have this? <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>${jackson.databind-version}</version> </dependency> Commented May 9, 2021 at 16:07
  • That did it, thanks! Commented May 10, 2021 at 15:00

1 Answer 1

1

Add this jackson dependency in pom.xml:

<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>${jackson.databind-version}</version>
</dependency>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.