spring-projects/spring-ai · error · RuntimeException
Could not create default cache dir
Error message
Could not create default cache dir
What it means
Static initializer failure in TransformersEmbeddingModelProperties: Files.createTempDirectory could not create the default local cache directory for downloaded transformer models (typical causes: no writable temp dir, no permissions, or an I/O error), so class initialization aborts.
Solutions
- Ensure the java.io.tmpdir location exists and is writable by the process
- Set spring.ai.embedding.transformer.cache-directory to an explicitly writable path instead of relying on the default
- Check disk space and filesystem permissions
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at auto-configurations/models/spring-ai-autoconfigure-model-transformers/src/main/java/org/springframework/ai/model/transformers/autoconfigure/TransformersEmbeddingModelProperties.java:50 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of spring-projects/spring-ai@98a7beda4f (2026-09-11).
Data as JSON: /api/errors/e047e0d55e81ea25.
Report an issue: GitHub.
Appendix: source
Thrown at auto-configurations/models/spring-ai-autoconfigure-model-transformers/src/main/java/org/springframework/ai/model/transformers/autoconfigure/TransformersEmbeddingModelProperties.java:50
/**
* Configuration properties for the Transformer Embedding model.
*
* @author Christian Tzolov
*/
@ConfigurationProperties(TransformersEmbeddingModelProperties.CONFIG_PREFIX)
public class TransformersEmbeddingModelProperties {
public static final String CONFIG_PREFIX = "spring.ai.embedding.transformer";
public static final String DEFAULT_CACHE_DIRECTORY;
static {
try {
DEFAULT_CACHE_DIRECTORY = Files.createTempDirectory("spring-ai-model-cache").toAbsolutePath().toString();
}
catch (IOException e) {
throw new RuntimeException("Could not create default cache dir", e);
}
}
@NestedConfigurationProperty
private final Tokenizer tokenizer = new Tokenizer();
/**
* Controls caching of remote, large resources to local file system.
*/
@NestedConfigurationProperty
private final Cache cache = new Cache();
@NestedConfigurationProperty
private final Onnx onnx = new Onnx();
/**
* Specifies what parts of the {@link Document}'s content and metadata will be used
* for computing the embeddings. Applicable for theView on GitHub (pinned to 98a7beda4f)