spring-projects / spring-projects/spring-ai

Unable to start application : VertexAiEmbeddingConnectionAutoConfiguration.class: Failed to instantiate | ClassNotFoundException: com.google.auth.oauth2.SecureSessionAgent

Open
#3,453 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage
Dominant language
Java
Stars
9.5k
Forks
2.9k
Avg merge
1d 7h
Merged PRs (30d)
6

Description

Bug description
Unable to start application after migrating to Spring AI - GA version from M6

`

<spring-ai.version>1.0.0</spring-ai.version>
<dependency>
				<groupId>org.springframework.ai</groupId>
				<artifactId>spring-ai-bom</artifactId>
				<version>${spring-ai.version}</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>`



`

o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'connectionDetails' defined in class path resource [org/springframework/ai/model/vertexai/autoconfigure/embedding/VertexAiEmbeddingConnectionAutoConfiguration.class]: Failed to instantiate [org.springframework.ai.vertexai.embedding.VertexAiEmbeddingConnectionDetails]: Factory method 'connectionDetails' threw exception with message: com/google/auth/oauth2/SecureSessionAgent
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:648) ~[spring-beans-6.1.13.jar:6.1.13]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:636) ~[spring-beans-6.1.13.jar:6.1.13]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1355) ~[spring-beans-6.1.13.jar:6.1.13]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1185) ~[spring-beans-6.1.13.jar:6.1.13]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:562) ~[spring-beans-6.1.13.jar:6.1.13]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522) ~[spring-beans-6.1.13.jar:6.1.13]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:337) ~[spring-beans-6.1.13.jar:6.1.13]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.1.13.jar:6.1.13]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:335) ~[spring-beans-6.1.13.jar:6.1.13]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.1.13.jar:6.1.13]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:975) ~[spring-beans-6.1.13.jar:6.1.13]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:971) ~[spring-context-6.1.13.jar:6.1.13]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:625) ~[spring-context-6.1.13.jar:6.1.13]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.3.4.jar:3.3.4]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) ~[spring-boot-3.3.4.jar:3.3.4]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456) ~[spring-boot-3.3.4.jar:3.3.4]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:335) ~[spring-boot-3.3.4.jar:3.3.4]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1363) ~[spring-boot-3.3.4.jar:3.3.4]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1352) ~[spring-boot-3.3.4.jar:3.3.4]
	at com.dq2.mv2.WebApplication.main(WebApplication.java:16) ~[classes/:na]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.ai.vertexai.embedding.VertexAiEmbeddingConnectionDetails]: Factory method 'connectionDetails' threw exception with message: com/google/auth/oauth2/SecureSessionAgent
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:178) ~[spring-beans-6.1.13.jar:6.1.13]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:644) ~[spring-beans-6.1.13.jar:6.1.13]
	... 19 common frames omitted
Caused by: java.lang.NoClassDefFoundError: com/google/auth/oauth2/SecureSessionAgent
	at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider$Builder.<init>(InstantiatingGrpcChannelProvider.java:855) ~[gax-grpc-2.65.0.jar:2.65.0]
	at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider$Builder.<init>(InstantiatingGrpcChannelProvider.java:847) ~[gax-grpc-2.65.0.jar:2.65.0]
	at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.newBuilder(InstantiatingGrpcChannelProvider.java:844) ~[gax-grpc-2.65.0.jar:2.65.0]
	at com.google.cloud.aiplatform.v1.stub.PredictionServiceStubSettings.defaultGrpcTransportProviderBuilder(PredictionServiceStubSettings.java:373) ~[google-cloud-aiplatform-3.63.0.jar:3.63.0]
	at com.google.cloud.aiplatform.v1.stub.PredictionServiceStubSettings.defaultTransportChannelProvider(PredictionServiceStubSettings.java:378) ~[google-cloud-aiplatform-3.63.0.jar:3.63.0]
	at com.google.cloud.aiplatform.v1.stub.PredictionServiceStubSettings$Builder.createDefault(PredictionServiceStubSettings.java:568) ~[google-cloud-aiplatform-3.63.0.jar:3.63.0]
	at com.google.cloud.aiplatform.v1.stub.PredictionServiceStubSettings$Builder.access$100(PredictionServiceStubSettings.java:428) ~[google-cloud-aiplatform-3.63.0.jar:3.63.0]
	at com.google.cloud.aiplatform.v1.stub.PredictionServiceStubSettings.newBuilder(PredictionServiceStubSettings.java:391) ~[google-cloud-aiplatform-3.63.0.jar:3.63.0]
	at com.google.cloud.aiplatform.v1.PredictionServiceSettings$Builder.createDefault(PredictionServiceSettings.java:278) ~[google-cloud-aiplatform-3.63.0.jar:3.63.0]
	at com.google.cloud.aiplatform.v1.PredictionServiceSettings$Builder.access$000(PredictionServiceSettings.java:259) ~[google-cloud-aiplatform-3.63.0.jar:3.63.0]
	at com.google.cloud.aiplatform.v1.PredictionServiceSettings.newBuilder(PredictionServiceSettings.java:241) ~[google-cloud-aiplatform-3.63.0.jar:3.63.0]
	at org.springframework.ai.vertexai.embedding.VertexAiEmbeddingConnectionDetails$Builder.build(VertexAiEmbeddingConnectionDetails.java:171) ~[spring-ai-vertex-ai-embedding-1.0.0.jar:1.0.0]
	at org.springframework.ai.model.vertexai.autoconfigure.embedding.VertexAiEmbeddingConnectionAutoConfiguration.connectionDetails(VertexAiEmbeddingConnectionAutoConfiguration.java:59) ~[spring-ai-autoconfigure-model-vertex-ai-1.0.0.jar:1.0.0]
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[na:na]
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:146) ~[spring-beans-6.1.13.jar:6.1.13]
	... 20 common frames omitted
Caused by: java.lang.ClassNotFoundException: com.google.auth.oauth2.SecureSessionAgent
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[na:na]
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[na:na]
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526) ~[na:na]
	... 36 common frames omitted

Disconnected from the target VM, address: '127.0.0.1:53506', transport: 'socket'

Process finished with exit code 1`

Environment
spring AI version: 1.0.0
Java 21
Spring boot 3.3.4

Properties file I have set these properties

`spring.ai.vertex.ai.embedding.project-id=<YOUR_PROJECT_ID>
spring.ai.vertex.ai.embedding.location=<YOUR_PROJECT_LOCATION>
 
`

To temporarily make it work I tried to add these properties, but none work

spring.ai.model.embedding.text=none
spring.ai.vertex.ai.embedding.enabled=false //docs suggest this is deprecated.

Steps to reproduce
Add vertext embedding dependency and add properties in .properties file.

Expected behavior
Application should start and dependencies should not be corrupted.

Minimal Complete Reproducible example
Please provide a failing test or a minimal complete verifiable example that reproduces the issue.
Bug reports that are reproducible will take priority in resolution over reports that are not reproducible.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with VertexAiEmbeddingConnectionAutoConfiguration.connectionDetails and VertexAiEmbeddingConnectionDetails.Builder.build, following the stack trace through PredictionServiceSettings and InstantiatingGrpcChannelProvider. Reproduce the Spring AI 1.0.0 setup with Java 21, Spring Boot 3.3.4, and the listed Vertex AI properties, then verify that the application starts without the SecureSessionAgent ClassNotFoundException.

Written by the indexing model from the issue text.

Assessment

Tech stack
google-cloud, java, spring-boot
Domain
ai, backend, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.