chromadbjava-21spring-boot-3spring-ai

Spring Boot application failed to create/initialize/connect ChromaDB collection


My Spring Boot application failed to create/initialize/connect the ChromaDB collection.

Entry in the application.properties of my Spring Boot project:

spring.ai.vectorstore.chroma.initialize-schema=true
spring.ai.vectorstore.chroma.collection-name=demo

Docker command:

docker run -it --rm --name chroma -p 8000:8000 ghcr.io/chroma-core/chroma:latest

Console LOG for docker:

INFO:     [19-01-2025 10:56:08] Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
WARNING:  [19-01-2025 10:58:19] Unsupported upgrade request.
INFO:     [19-01-2025 10:58:19] 172.17.0.1:42208 - "GET /api/v1/collections/demo HTTP/1.1" 400

Console log for Spring Boot:

2025-01-19T11:22:39.559Z[0;39m [32m INFO[0;39m [35m20088[0;39m [2m--- [Learning-SpringAI] [           main] [0;39m[36mo.apache.catalina.core.StandardService  [0;39m [2m:[0;39m Stopping service [Tomcat]
[2m2025-01-19T11:22:39.573Z[0;39m [32m INFO[0;39m [35m20088[0;39m [2m--- [Learning-SpringAI] [           main] [0;39m[36m.s.b.a.l.ConditionEvaluationReportLogger[0;39m [2m:[0;39m 

Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
[2m2025-01-19T11:22:39.595Z[0;39m [31mERROR[0;39m [35m20088[0;39m [2m--- [Learning-SpringAI] [           main] [0;39m[36mo.s.boot.SpringApplication              [0;39m [2m:[0;39m Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'embeddingDemo': Unsatisfied dependency expressed through field 'service': Error creating bean with name 'openAiService': Unsatisfied dependency expressed through field 'vectorStore': Error creating bean with name 'vectorStore' defined in class path resource [org/springframework/ai/autoconfigure/vectorstore/chroma/ChromaVectorStoreAutoConfiguration.class]: cannot unpack non-iterable coroutine object

Accessing http://localhost:8000/api/v1/collections/demo from the browser returned the following JSON:

{
    "error": "InvalidCollection",
    "message": "Collection demo does not exist."
}

Versions:

Java version: 21
Spring Boot version: 3.4.1
spring-ai.version:1.0.0-M4

I also tried with chroma:0.4.15 and chroma:0.5.20 but the result was the same.

Please help me with versions (Java, Spring Boot, Spring AI and ChromaDB) that have worked for you.

Update 1

I tried with spring-ai.version: 1.0.0-M5 and chroma:0.5.20 and this time, the console LOG for docker changed to:

INFO:     [19-01-2025 12:01:55] Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
WARNING:  [19-01-2025 12:02:23] Unsupported upgrade request.
INFO:     [19-01-2025 12:02:23] 172.17.0.1:42890 - "GET /api/v1/collections/demo HTTP/1.1" 400
WARNING:  [19-01-2025 12:02:23] Unsupported upgrade request.
INFO:     [19-01-2025 12:02:23] 172.17.0.1:42890 - "POST /api/v1/collections HTTP/1.1" 422
WARNING:  [19-01-2025 12:02:23] Invalid HTTP request received.

I have not yet been able to resolve the issue.

Update 2

The accepted answer worked for chroma:0.4.15. It didn't work for chroma:latest but I am happy with chroma:0.4.15.


Solution

  • I had similar issue and it was due to version of Spring

    https://docs.spring.io/spring-ai/reference/getting-started.html -> Spring AI supports Spring Boot 3.2.x and 3.3.x

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.3.5</version>
        <relativePath/>
    </parent>