I have a working Spring AI project, but when I add dependencies for Spring Cloud (such as Eureka or Config Client), I get the following error when invoking the chat client.
Dependencies:
Spring Cloud Dependencies
<spring-ai.version>1.0.0-M6</spring-ai.version>
<spring-cloud.version>4.2.1</spring-cloud.version>
<dependency>
<groupId>.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<version>${spring-cloud.version}</version>
</dependency>
<dependency>
<groupId>.springframework.cloud</groupId>
<artifactId>spring-cloud-config-client</artifactId>
<version>${spring-cloud.version}</version>
</dependency>
Spring AI Dependency
<dependency>
<groupId>.springframework.ai</groupId>
<artifactId>spring-ai-openai-spring-boot-starter</artifactId>
</dependency>
Version Management
<dependencyManagement>
<dependencies>
<dependency>
<groupId>.springframework.ai</groupId>
<artifactId>spring-ai-bom</artifactId>
<version>${spring-ai.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Error Log
2025-03-31T20:28:19.393+02:00 ERROR 53666 --- [nio-8084-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: .springframework.web.client.RestClientException: Error while extracting response for type [.springframework.ai.openai.api.OpenAiApi$ChatCompletion] and content type [application/json]] with root cause
com.fasterxml.jackson.core.io.JsonEOFException: Unexpected end-of-input: expected close marker for Object (start marker at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 1])
at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 2]
Expected Behavior
The chat client should work correctly and return a response from OpenAI, even with Spring Cloud dependencies present.
Troubleshooting Done
The project works fine when Spring Cloud dependencies are removed.
The issue occurs when adding either spring-cloud-starter-netflix-eureka-client
or spring-cloud-config-client
.
The error suggests a JSON parsing issue, possibly due to an incomplete or malformed response.
Questions
Has anyone encountered compatibility issues between Spring AI 1.0.0-M6 and Spring Cloud 4.2.1?
Could Spring Cloud be interfering with the HTTP client used by Spring AI?
Are there any known fixes or workarounds?
Any help or suggestions would be greatly appreciated! Thanks in advance.
I have a working Spring AI project, but when I add dependencies for Spring Cloud (such as Eureka or Config Client), I get the following error when invoking the chat client.
Dependencies:
Spring Cloud Dependencies
<spring-ai.version>1.0.0-M6</spring-ai.version>
<spring-cloud.version>4.2.1</spring-cloud.version>
<dependency>
<groupId>.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<version>${spring-cloud.version}</version>
</dependency>
<dependency>
<groupId>.springframework.cloud</groupId>
<artifactId>spring-cloud-config-client</artifactId>
<version>${spring-cloud.version}</version>
</dependency>
Spring AI Dependency
<dependency>
<groupId>.springframework.ai</groupId>
<artifactId>spring-ai-openai-spring-boot-starter</artifactId>
</dependency>
Version Management
<dependencyManagement>
<dependencies>
<dependency>
<groupId>.springframework.ai</groupId>
<artifactId>spring-ai-bom</artifactId>
<version>${spring-ai.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Error Log
2025-03-31T20:28:19.393+02:00 ERROR 53666 --- [nio-8084-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: .springframework.web.client.RestClientException: Error while extracting response for type [.springframework.ai.openai.api.OpenAiApi$ChatCompletion] and content type [application/json]] with root cause
com.fasterxml.jackson.core.io.JsonEOFException: Unexpected end-of-input: expected close marker for Object (start marker at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 1])
at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 2]
Expected Behavior
The chat client should work correctly and return a response from OpenAI, even with Spring Cloud dependencies present.
Troubleshooting Done
The project works fine when Spring Cloud dependencies are removed.
The issue occurs when adding either spring-cloud-starter-netflix-eureka-client
or spring-cloud-config-client
.
The error suggests a JSON parsing issue, possibly due to an incomplete or malformed response.
Questions
Has anyone encountered compatibility issues between Spring AI 1.0.0-M6 and Spring Cloud 4.2.1?
Could Spring Cloud be interfering with the HTTP client used by Spring AI?
Are there any known fixes or workarounds?
Any help or suggestions would be greatly appreciated! Thanks in advance.
Share Improve this question edited Mar 31 at 18:57 Hilory 2,1417 gold badges14 silver badges30 bronze badges asked Mar 31 at 18:39 ZuzzuzZuzzuz 111 bronze badge 2 |1 Answer
Reset to default 0If you want use a beta version of Spring AI (Spring AI 1.0.0-M6), You must use same period of versions of Spring Cloud (one beta version, not version 4.2.1 of Spring Cloud).
Best way: Use dependency management from Spring Boot and Spring Cloud (v2025.0.0-M1
https://github/spring-cloud/spring-cloud-release/releases) , all are latest snapshot version at this time of writing.
REDACTED
) of the AI actually contains JSON? These AI models are known to sometimes not follow the requested JSON schema and answer with plain text or invalid JSON. Maybe it's a coincidence that this happened when you added a Spring Cloud library. – Dimitri Mestdagh Commented Mar 31 at 19:36