I have been trying most things I can think off, googling and chatgpt. My app runs "fine", in development and so on. But I'm mainly doing this project to teach myself working with GraalVM, native images and micronaut. I have some ancient SpringBoot knowledge coming into this. It builds fine with gradlew dockerbuildnative, but it crashes when I start the docker container. I'm getting the this message.
2025-01-02 22:49:18 21:49:18.760 [main] ERROR io.micronaut.runtime.Micronaut - Error starting Micronaut server: Bean definition [org.hibernate.SessionFactory] could not be loaded: Error instantiating bean of type [org.hibernate.SessionFactory]
2025-01-02 22:49:18
2025-01-02 22:49:18 Message: org.hibernate.bytecode.spi.BytecodeProvider: Provider org.hibernate.bytecode.internal.bytebuddy.BytecodeProviderImpl could not be instantiated
2025-01-02 22:49:18 Path Taken: SessionFactoryPerDataSourceFactory.buildHibernateSessionFactoryBuilder(SessionFactoryBuilder sessionFactoryBuilder) --> SessionFactoryPerDataSourceFactory.buildHibernateSessionFactoryBuilder([SessionFactoryBuilder sessionFactoryBuilder])
I'm understanding this as problem with bytebuddy being used. But I'm not sure which dependency is injecting this.
This is my build.gradle
plugins {
id("com.github.johnrengelman.shadow") version "8.1.1"
id("io.micronaut.application") version "4.4.4"
id("io.micronaut.test-resources") version "4.4.4"
id("io.micronaut.aot") version "4.4.4"
}
version = "0.1"
group = "com.julian"
repositories {
mavenCentral()
}
dependencies {
annotationProcessor("io.micronaut.data:micronaut-data-processor")
annotationProcessor("io.micronaut:micronaut-http-validation")
annotationProcessor("io.micronaut.openapi:micronaut-openapi")
annotationProcessor("io.micronaut.serde:micronaut-serde-processor")
annotationProcessor("io.micronaut:micronaut-graal")
implementation("io.micronaut.data:micronaut-data-hibernate-jpa")
implementation("io.micronaut.serde:micronaut-serde-jackson")
implementation("io.micronaut.sql:micronaut-jdbc-hikari")
implementation "jakarta.validation:jakarta.validation-api:3.0.2"
implementation 'org.yaml:snakeyaml:1.8'
implementation "org.javassist:javassist:3.28.0-GA"
implementation("org.hibernate.orm:hibernate-core:5.6.15.Final")
implementation("org.slf4j:jul-to-slf4j")
compileOnly("io.micronaut:micronaut-http-client")
compileOnly("io.micronaut.openapi:micronaut-openapi-annotations")
runtimeOnly("ch.qos.logback:logback-classic")
runtimeOnly("org.postgresql:postgresql")
testImplementation("io.micronaut:micronaut-http-client")
}
application {
mainClass = "com.julian.Application"
}
java {
sourceCompatibility = JavaVersion.toVersion("17")
targetCompatibility = JavaVersion.toVersion("17")
}
graalvmNative.toolchainDetection = false
micronaut {
runtime("netty")
testRuntime("junit5")
processing {
incremental(true)
annotations("com.julian.*")
}
aot {
// Please review carefully the optimizations enabled below
// Check / for more details
optimizeServiceLoading = false
convertYamlToJava = false
precomputeOperations = true
cacheEnvironment = true
optimizeClassLoading = true
deduceEnvironment = true
optimizeNetty = true
replaceLogbackXml = true
}
}
And this is my application.yml
micronaut:
application:
name: julian-auth-service
server:
port: 8081
openapi:
enabled: true
endpoints:
swagger-ui:
enabled: true
path: /swagger-ui
redoc:
enabled: true
path: /redoc
jpa:
packages-to-scan: com.julian.entity
properties:
hibernate:
hbm2ddl:
auto: update # Use "update" for development; switch to "validate" or "none" for production
format_sql: true
use_sql_comments: true
show_sql: true
format_sql: true
use_sql_comments: true
hibernate.bytecode.provider: javassist
security:
intercept-url-map:
- pattern: "/swagger-ui/**"
access:
- isAnonymous()
- pattern: "/swagger/**"
access:
- isAnonymous()
- pattern: "/redoc/**"
access:
- isAnonymous()
enabled: true
router:
static-resources:
swagger:
paths: classpath:META-INF/swagger
mappping: /swagger/**
swagger-ui:
paths: classpath:META-INF/swagger/views/swagger-ui
mapping: /swagger-ui/*
datasources:
default:
url: *****
username: *****
password: *****
driverClassName: *****
dialect: *****
#jpa:
# default:
# entity-scan:
# packages:
## - com.julian.entity
#properties:
# hibernate:
# hbm2ddl:
# auto: update # Use "update" for development; switch to "validate" or "none" for production
#format_sql: true
#use_sql_comments: true
#show_sql: true
#format_sql: true
#use_sql_comments: true
#hibernate.bytecode.provider: javassist
logger:
levels:
ROOT: DEBUG
io.micronaut: DEBUG
io.micronaut.http: DEBUG
io.micronaut.data: DEBUG
io.micronaut.sql: DEBUG
org.hibernate.tool.hbm2ddl: DEBUG
org.hibernate.SQL: DEBUG
org.hibernate.type.descriptor.sql: TRACE
org.hibernate: DEBUG
io.micronaut.sql: DEBUG
I have wasted countless hours earlier with mistakes that was just incorrectly written application.yml. And I have a feeling its the same here. I'm just not sure what. Any help or pointer