-
Notifications
You must be signed in to change notification settings - Fork 353
Missing reflection entries for com.zaxxer.hikari.HikariDataSource #1599
Comments
I faced this as well, The setup doesn't work only when you add pool properties. HikariPool has an issues when built using native. I commented out the pool properties to proceed further, let me know if it helps
|
Can you provide a minimal sample to reproduce this problem? The repo you linked is quite heavy on dependencies. We have a |
I'm facing a similar problem with the following code. @SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
public class App {
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
@Bean
@Profile({"jdbc", "jpa"})
public DataSource datasource(DataSourceProperties dataSourceProperties) {
HikariDataSource dataSource = dataSourceProperties.initializeDataSourceBuilder().type(HikariDataSource.class).build();
dataSource.setMaximumPoolSize(Runtime.getRuntime().availableProcessors() * 2);
return dataSource;
}
} I can compile it, but during the startup it throws the following exception:
If I delete @SpringBootApplication()
public class App {
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
} application.yaml
spring:
profiles: jdbc,jpa
datasource:
url: jdbc:postgresql://${database.host}:${database.port}/${database.name}
username: ${database.username}
password: ${database.password}
driverClassName: org.postgresql.Driver
maximumPoolSize: ${database.poolsize}
database:
name: hello_world
#host: tfb-database
host: 127.0.0.1
port: 5432
username: XXX
password: XXX
poolsize: 16
The code above is from this application that I'm trying to run as native image. Update 1: Update 2: If I keep @SpringBootApplication
public class App {
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
@Bean
@Profile({"jdbc", "jpa"})
@ConditionalOnBean(DataSource.class)
public DataSource datasource(DataSourceProperties dataSourceProperties) {
HikariDataSource dataSource = dataSourceProperties.initializeDataSourceBuilder().type(HikariDataSource.class).build();
dataSource.setMaximumPoolSize(Runtime.getRuntime().availableProcessors() * 2);
return dataSource;
}
} Update 3: These are the hints I'm using for the code.
[
["org.springframework.data.mongodb.core.mapping.Document", "org.springframework.core.annotation.SynthesizedAnnotation"],
["org.springframework.data.mongodb.core.mapping.Field", "org.springframework.core.annotation.SynthesizedAnnotation"],
["org.hibernate.Session","org.springframework.orm.jpa.EntityManagerProxy"],
["org.hibernate.SessionFactory","org.springframework.orm.jpa.EntityManagerFactoryInfo"]
]
|
I have a reproducer here: https://github.com/mhalbritter/spring-native-reproducers/tree/main/gh-1599 I got it to work with these hints:
Can you give this a try? |
It worked, Thanks! I using The funny thing is that I ran my application with agent support to catch all these "odd" configurations and despite it generating a large Here are my final hint files. Note that my app uses either mongo or postgresql that is the reason of having some mongo specific proxies.
[
{
"name":"com.zaxxer.hikari.HikariDataSource",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"name":"org.hibernate.dialect.PostgreSQLDialect",
"allDeclaredMethods" : true,
"allDeclaredFields" : true,
"allDeclaredConstructors" : true
},
{
"name":"java.sql.Statement[]"
}
]
[
["org.springframework.data.mongodb.core.mapping.Document", "org.springframework.core.annotation.SynthesizedAnnotation"],
["org.springframework.data.mongodb.core.mapping.Field", "org.springframework.core.annotation.SynthesizedAnnotation"],
["org.hibernate.Session","org.springframework.orm.jpa.EntityManagerProxy"],
["org.hibernate.SessionFactory","org.springframework.orm.jpa.EntityManagerFactoryInfo"]
]
|
@mhalbritter I tentatively move it to |
com.zaxxer.hikari.HikariDataSource
Hint for myself: Enable |
For our batch sample to work with SB 3 I had to add {
"name": "com.zaxxer.hikari.util.ConcurrentBag$IConcurrentBagEntry[]"
} |
com.zaxxer.hikari.HikariDataSource
com.zaxxer.hikari.HikariDataSource
com.zaxxer.hikari.HikariDataSource
Project build pass, image start failed!
Step to reproduce:
clone project
git clone https://github.com/LilPoppy/cobnet.git
Optional:
Docker:
mvn -Dredis-host=redis -Ddb-host=db clean install -Pdocker -Ddocker-target=native
Native:
mvn clean package -Pnative
The text was updated successfully, but these errors were encountered: