Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add native-image support for Quartz #31536

Closed
mhalbritter opened this issue Jun 27, 2022 · 3 comments
Closed

Add native-image support for Quartz #31536

mhalbritter opened this issue Jun 27, 2022 · 3 comments
Labels
for: external-project For an external project and not something we can fix

Comments

@mhalbritter
Copy link
Contributor

Running the quartz sample from spring-native, the native image fails with:

org.springframework.beans.factory.BeanCreationException: Unable to instantiate bean using public org.springframework.boot.autoconfigure.quartz.QuartzDataSourceScriptDatabaseInitializer org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration$JdbcStoreTypeConfiguration.quartzDataSourceScriptDatabaseInitializer(javax.sql.DataSource,org.springframework.beans.factory.ObjectProvider,org.springframework.boot.autoconfigure.quartz.QuartzProperties)
        at org.springframework.beans.factory.aot.AutowiredInstantiationArgumentsResolver.instantiate(AutowiredInstantiationArgumentsResolver.java:336) ~[na:na]
        at org.springframework.beans.factory.aot.AutowiredInstantiationArgumentsResolver.resolveAndInstantiate(AutowiredInstantiationArgumentsResolver.java:195) ~[na:na]
        at org.springframework.beans.factory.aot.AutowiredInstantiationArgumentsResolver.resolveAndInstantiate(AutowiredInstantiationArgumentsResolver.java:177) ~[na:na]
        at org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration_JdbcStoreTypeConfiguration__BeanDefinitions.getQuartzDataSourceScriptDatabaseInitializerInstance(QuartzAutoConfiguration_JdbcStoreTypeConfiguration__BeanDefinitions.java:72) ~[na:na]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainInstanceFromSupplier(AbstractAutowireCapableBeanFactory.java:1223) ~[quartz:6.0.0-SNAPSHOT]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1209) ~[quartz:6.0.0-SNAPSHOT]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1156) ~[quartz:6.0.0-SNAPSHOT]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:566) ~[quartz:6.0.0-SNAPSHOT]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:526) ~[quartz:6.0.0-SNAPSHOT]
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[quartz:6.0.0-SNAPSHOT]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[quartz:6.0.0-SNAPSHOT]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[quartz:6.0.0-SNAPSHOT]
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[quartz:6.0.0-SNAPSHOT]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:313) ~[quartz:6.0.0-SNAPSHOT]
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[quartz:6.0.0-SNAPSHOT]
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:930) ~[quartz:6.0.0-SNAPSHOT]
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:926) ~[quartz:6.0.0-SNAPSHOT]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:592) ~[quartz:6.0.0-SNAPSHOT]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:729) ~[quartz:3.0.0-SNAPSHOT]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:428) ~[quartz:3.0.0-SNAPSHOT]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:310) ~[quartz:3.0.0-SNAPSHOT]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301) ~[quartz:3.0.0-SNAPSHOT]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1290) ~[quartz:3.0.0-SNAPSHOT]
        at com.example.quartznative.QuartzNativeApplication.main(QuartzNativeApplication.java:35) ~[quartz:0.0.1-SNAPSHOT]
Caused by: java.lang.IllegalStateException: Unable to detect database type
        at org.springframework.util.Assert.state(Assert.java:76) ~[na:na]
        at org.springframework.boot.jdbc.init.PlatformPlaceholderDatabaseDriverResolver.determinePlatform(PlatformPlaceholderDatabaseDriverResolver.java:132) ~[na:na]
        at org.springframework.boot.jdbc.init.PlatformPlaceholderDatabaseDriverResolver.lambda$resolveAll$0(PlatformPlaceholderDatabaseDriverResolver.java:96) ~[na:na]
        at org.springframework.boot.jdbc.init.PlatformPlaceholderDatabaseDriverResolver.resolveAll(PlatformPlaceholderDatabaseDriverResolver.java:121) ~[na:na]
        at org.springframework.boot.jdbc.init.PlatformPlaceholderDatabaseDriverResolver.resolveAll(PlatformPlaceholderDatabaseDriverResolver.java:96) ~[na:na]
        at org.springframework.boot.autoconfigure.quartz.QuartzDataSourceScriptDatabaseInitializer.resolveSchemaLocations(QuartzDataSourceScriptDatabaseInitializer.java:105) ~[quartz:3.0.0-SNAPSHOT]
        at org.springframework.boot.autoconfigure.quartz.QuartzDataSourceScriptDatabaseInitializer.getSettings(QuartzDataSourceScriptDatabaseInitializer.java:89) ~[quartz:3.0.0-SNAPSHOT]
        at org.springframework.boot.autoconfigure.quartz.QuartzDataSourceScriptDatabaseInitializer.<init>(QuartzDataSourceScriptDatabaseInitializer.java:51) ~[quartz:3.0.0-SNAPSHOT]
        at org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration$JdbcStoreTypeConfiguration.quartzDataSourceScriptDatabaseInitializer(QuartzAutoConfiguration.java:141) ~[quartz:3.0.0-SNAPSHOT]
        at java.lang.reflect.Method.invoke(Method.java:568) ~[quartz:na]
        at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:281) ~[na:na]
        at org.springframework.beans.factory.aot.AutowiredInstantiationArgumentsResolver.instantiate(AutowiredInstantiationArgumentsResolver.java:360) ~[na:na]
        at org.springframework.beans.factory.aot.AutowiredInstantiationArgumentsResolver.instantiate(AutowiredInstantiationArgumentsResolver.java:332) ~[na:na]
        ... 23 common frames omitted
@mhalbritter mhalbritter added type: bug A general bug theme: aot An issue related to Ahead-of-time processing labels Jun 27, 2022
@mhalbritter mhalbritter added this to the 3.0.x milestone Jun 27, 2022
@mhalbritter mhalbritter changed the title Quarz in native-image: Unable to detect database type Add native-image support to PlatformPlaceholderDatabaseDriverResolver Jun 28, 2022
@mhalbritter mhalbritter added type: enhancement A general enhancement and removed type: bug A general bug labels Jun 28, 2022
@mhalbritter
Copy link
Contributor Author

@mhalbritter mhalbritter changed the title Add native-image support to PlatformPlaceholderDatabaseDriverResolver Add native-image support for Quartz Aug 1, 2022
@mhalbritter
Copy link
Contributor Author

mhalbritter commented Aug 1, 2022

This is a side effect of missing Hikari hints. After the hints for Hikari are included, it now fails with:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'quartzDataSourceScriptDatabaseInitializer': No schema scripts found at location 'classpath:org/quartz/impl/jdbcjobstore/tables_h2.sql'
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1753) ~[quartz:6.0.0-SNAPSHOT]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:604) ~[quartz:6.0.0-SNAPSHOT]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:526) ~[quartz:6.0.0-SNAPSHOT]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[quartz:6.0.0-SNAPSHOT]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[quartz:6.0.0-SNAPSHOT]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[quartz:6.0.0-SNAPSHOT]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[quartz:6.0.0-SNAPSHOT]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:313) ~[quartz:6.0.0-SNAPSHOT]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[quartz:6.0.0-SNAPSHOT]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:930) ~[quartz:6.0.0-SNAPSHOT]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:926) ~[quartz:6.0.0-SNAPSHOT]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:592) ~[quartz:6.0.0-SNAPSHOT]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:731) ~[quartz:3.0.0-SNAPSHOT]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:430) ~[quartz:3.0.0-SNAPSHOT]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) ~[quartz:3.0.0-SNAPSHOT]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303) ~[quartz:3.0.0-SNAPSHOT]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292) ~[quartz:3.0.0-SNAPSHOT]
	at com.example.quartz.QuartzApplication.main(QuartzApplication.java:13) ~[quartz:na]
Caused by: java.lang.IllegalStateException: No schema scripts found at location 'classpath:org/quartz/impl/jdbcjobstore/tables_h2.sql'
	at org.springframework.boot.sql.init.AbstractScriptDatabaseInitializer.getScripts(AbstractScriptDatabaseInitializer.java:128) ~[quartz:3.0.0-SNAPSHOT]
	at org.springframework.boot.sql.init.AbstractScriptDatabaseInitializer.applyScripts(AbstractScriptDatabaseInitializer.java:105) ~[quartz:3.0.0-SNAPSHOT]
	at org.springframework.boot.sql.init.AbstractScriptDatabaseInitializer.applySchemaScripts(AbstractScriptDatabaseInitializer.java:97) ~[quartz:3.0.0-SNAPSHOT]
	at org.springframework.boot.sql.init.AbstractScriptDatabaseInitializer.initializeDatabase(AbstractScriptDatabaseInitializer.java:75) ~[quartz:3.0.0-SNAPSHOT]
	at org.springframework.boot.sql.init.AbstractScriptDatabaseInitializer.afterPropertiesSet(AbstractScriptDatabaseInitializer.java:65) ~[quartz:3.0.0-SNAPSHOT]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1799) ~[quartz:6.0.0-SNAPSHOT]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1749) ~[quartz:6.0.0-SNAPSHOT]
	... 17 common frames omitted

because hints for these resources in QuartzDataSourceScriptDatabaseInitializer are missing.

As these files are located in the Quartz JAR, the hints for those resource files should be contributed to the GraalVM reachability metadata.

@mhalbritter
Copy link
Contributor Author

With the hints @sdeleuze provided to the graalvm-reachability-metadata, the quartz smoke test works.

@mhalbritter mhalbritter added for: external-project For an external project and not something we can fix and removed type: enhancement A general enhancement theme: aot An issue related to Ahead-of-time processing labels Aug 23, 2022
@mhalbritter mhalbritter removed this from the 3.0.x milestone Aug 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project For an external project and not something we can fix
Projects
None yet
Development

No branches or pull requests

1 participant