jhipster / generator-jhipster

JHipster is a development platform to quickly generate, develop, & deploy modern web applications & microservice architectures.
https://www.jhipster.tech
Apache License 2.0
21.54k stars 4.02k forks source link

Add support for compiling to native images #22488

Closed mraible closed 1 year ago

mraible commented 1 year ago
Overview of the feature request

Now that we're using Spring Boot 3, it should be possible to compile to a native image. Unfortunately, we don't inherit from spring-boot-starter-parent, so I had to copy its native and nativeTest profiles into my pom.xml. I also added the following to build > plugins:

<plugin>
    <groupId>org.graalvm.buildtools</groupId>
    <artifactId>native-maven-plugin</artifactId>
</plugin>

When I try to build with mvn -Pnative native:compile, I get all kinds of errors from the modernizer plugin:

[INFO] --- modernizer:2.5.0:modernizer (modernizer) @ blog ---
[ERROR] /Users/mraible/Downloads/oauth/src/main/java/tech/jhipster/config/apidoc/JHipsterSpringDocGroupsConfiguration$$SpringCGLIB$$2.java:-1: Prefer java.lang.Integer.valueOf(int)
[ERROR] /Users/mraible/Downloads/oauth/src/main/java/tech/jhipster/config/apidoc/JHipsterSpringDocGroupsConfiguration$$SpringCGLIB$$1.java:-1: Prefer java.lang.Integer.valueOf(int)
[ERROR] /Users/mraible/Downloads/oauth/src/main/java/tech/jhipster/config/apidoc/JHipsterOpenApiEndpointConfiguration$$SpringCGLIB$$2.java:-1: Prefer java.lang.Integer.valueOf(int)
[ERROR] /Users/mraible/Downloads/oauth/src/main/java/tech/jhipster/config/apidoc/JHipsterOpenApiEndpointConfiguration$$SpringCGLIB$$1.java:-1: Prefer java.lang.Integer.valueOf(int)
[ERROR] /Users/mraible/Downloads/oauth/src/main/java/tech/jhipster/config/info/JHipsterInfoContributorConfiguration$$SpringCGLIB$$1.java:-1: Prefer java.lang.Integer.valueOf(int)
[ERROR] /Users/mraible/Downloads/oauth/src/main/java/tech/jhipster/config/info/JHipsterInfoContributorConfiguration$$SpringCGLIB$$2.java:-1: Prefer java.lang.Integer.valueOf(int)
[ERROR] /Users/mraible/Downloads/oauth/src/main/java/tech/jhipster/config/metric/JHipsterMetricsEndpointConfiguration$$SpringCGLIB$$1.java:-1: Prefer java.lang.Integer.valueOf(int)
[ERROR] /Users/mraible/Downloads/oauth/src/main/java/tech/jhipster/config/metric/JHipsterMetricsEndpointConfiguration$$SpringCGLIB$$2.java:-1: Prefer java.lang.Integer.valueOf(int)
[ERROR] /Users/mraible/Downloads/oauth/src/main/java/com/jhipster/demo/blog/config/JacksonConfiguration$$SpringCGLIB$$2.java:-1: Prefer java.lang.Integer.valueOf(int)
[ERROR] /Users/mraible/Downloads/oauth/src/main/java/com/jhipster/demo/blog/config/JacksonConfiguration$$SpringCGLIB$$1.java:-1: Prefer java.lang.Integer.valueOf(int)
[ERROR] /Users/mraible/Downloads/oauth/src/main/java/com/jhipster/demo/blog/config/LoggingAspectConfiguration$$SpringCGLIB$$1.java:-1: Prefer java.lang.Integer.valueOf(int)
[ERROR] /Users/mraible/Downloads/oauth/src/main/java/com/jhipster/demo/blog/config/LiquibaseConfiguration$$SpringCGLIB$$1.java:-1: Prefer java.lang.Integer.valueOf(int)
[ERROR] /Users/mraible/Downloads/oauth/src/main/java/com/jhipster/demo/blog/config/WebConfigurer$$SpringCGLIB$$2.java:-1: Prefer java.lang.Integer.valueOf(int)
[ERROR] /Users/mraible/Downloads/oauth/src/main/java/com/jhipster/demo/blog/config/AsyncConfiguration$$SpringCGLIB$$2.java:-1: Prefer java.lang.Integer.valueOf(int)
[ERROR] /Users/mraible/Downloads/oauth/src/main/java/com/jhipster/demo/blog/config/CacheConfiguration$$SpringCGLIB$$1.java:-1: Prefer java.lang.Integer.valueOf(int)
[ERROR] /Users/mraible/Downloads/oauth/src/main/java/com/jhipster/demo/blog/config/OAuth2Configuration$$SpringCGLIB$$2.java:-1: Prefer java.lang.Integer.valueOf(int)
[ERROR] /Users/mraible/Downloads/oauth/src/main/java/com/jhipster/demo/blog/config/SecurityConfiguration$$SpringCGLIB$$2.java:-1: Prefer java.lang.Integer.valueOf(int)
[ERROR] /Users/mraible/Downloads/oauth/src/main/java/com/jhipster/demo/blog/config/LocaleConfiguration$$SpringCGLIB$$1.java:-1: Prefer java.lang.Integer.valueOf(int)
[ERROR] /Users/mraible/Downloads/oauth/src/main/java/com/jhipster/demo/blog/config/DatabaseConfiguration$$SpringCGLIB$$2.java:-1: Prefer java.lang.Integer.valueOf(int)
[ERROR] /Users/mraible/Downloads/oauth/src/main/java/com/jhipster/demo/blog/config/LoggingAspectConfiguration$$SpringCGLIB$$2.java:-1: Prefer java.lang.Integer.valueOf(int)
[ERROR] /Users/mraible/Downloads/oauth/src/main/java/com/jhipster/demo/blog/config/AsyncConfiguration$$SpringCGLIB$$1.java:-1: Prefer java.lang.Integer.valueOf(int)
[ERROR] /Users/mraible/Downloads/oauth/src/main/java/com/jhipster/demo/blog/config/WebConfigurer$$SpringCGLIB$$1.java:-1: Prefer java.lang.Integer.valueOf(int)
[ERROR] /Users/mraible/Downloads/oauth/src/main/java/com/jhipster/demo/blog/config/CacheConfiguration$$SpringCGLIB$$2.java:-1: Prefer java.lang.Integer.valueOf(int)
[ERROR] /Users/mraible/Downloads/oauth/src/main/java/com/jhipster/demo/blog/config/LiquibaseConfiguration$$SpringCGLIB$$2.java:-1: Prefer java.lang.Integer.valueOf(int)
[ERROR] /Users/mraible/Downloads/oauth/src/main/java/com/jhipster/demo/blog/config/OAuth2Configuration$$SpringCGLIB$$1.java:-1: Prefer java.lang.Integer.valueOf(int)
[ERROR] /Users/mraible/Downloads/oauth/src/main/java/com/jhipster/demo/blog/config/LocaleConfiguration$$SpringCGLIB$$2.java:-1: Prefer java.lang.Integer.valueOf(int)
[ERROR] /Users/mraible/Downloads/oauth/src/main/java/com/jhipster/demo/blog/config/DatabaseConfiguration$$SpringCGLIB$$1.java:-1: Prefer java.lang.Integer.valueOf(int)
[ERROR] /Users/mraible/Downloads/oauth/src/main/java/com/jhipster/demo/blog/config/SecurityConfiguration$$SpringCGLIB$$1.java:-1: Prefer java.lang.Integer.valueOf(int)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------

If I remove the modernizer plugin, the TechnicalStructureTest test fails:

[ERROR] TechnicalStructureTest.respectsTechnicalArchitectureLayers -- Time elapsed: 1.870 s <<< FAILURE!
java.lang.AssertionError:
Architecture Violation [Priority: MEDIUM] - Rule 'Layered architecture considering all dependencies, consisting of
layer 'Config' ('..config..')
layer 'Web' ('..web..')
optional layer 'Service' ('..service..')
layer 'Security' ('..security..')
layer 'Persistence' ('..repository..')
layer 'Domain' ('..domain..')
where layer 'Config' may not be accessed by any layer
where layer 'Web' may only be accessed by layers ['Config']
where layer 'Service' may only be accessed by layers ['Web', 'Config']
where layer 'Security' may only be accessed by layers ['Config', 'Service', 'Web']
where layer 'Persistence' may only be accessed by layers ['Service', 'Security', 'Web', 'Config']
where layer 'Domain' may only be accessed by layers ['Persistence', 'Service', 'Security', 'Web', 'Config']' was violated (48 times):
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.config.ApplicationProperties__BeanDefinitions.getApplicationPropertiesBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:370)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.config.AsyncConfiguration__BeanDefinitions.getAsyncConfigurationBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:252)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.config.AsyncConfiguration__BeanDefinitions.getTaskExecutorBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:281)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.config.CacheConfiguration__BeanDefinitions.getCacheConfigurationBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:253)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.config.CacheConfiguration__BeanDefinitions.getCacheManagerCustomizerBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:291)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.config.CacheConfiguration__BeanDefinitions.getHibernatePropertiesCustomizerBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:290)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.config.CacheConfiguration__BeanDefinitions.getKeyGeneratorBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:292)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.config.DatabaseConfiguration__BeanDefinitions.getDatabaseConfigurationBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:254)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.config.DatabaseConfiguration__BeanDefinitions.getHTCPServerBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:299)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.config.DateTimeFormatConfiguration__BeanDefinitions.getDateTimeFormatConfigurationBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:255)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.config.JacksonConfiguration__BeanDefinitions.getHibernateModuleBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:330)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.config.JacksonConfiguration__BeanDefinitions.getJacksonConfigurationBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:256)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.config.JacksonConfiguration__BeanDefinitions.getJavaTimeModuleBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:328)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.config.JacksonConfiguration__BeanDefinitions.getJdkTimeModuleBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:329)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.config.LiquibaseConfiguration__BeanDefinitions.getLiquibaseBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:331)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.config.LiquibaseConfiguration__BeanDefinitions.getLiquibaseConfigurationBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:257)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.config.LocaleConfiguration__BeanDefinitions.getLocaleConfigurationBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:258)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.config.LocaleConfiguration__BeanDefinitions.getLocaleResolverBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:332)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.config.LoggingAspectConfiguration__BeanDefinitions.getLoggingAspectBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:333)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.config.LoggingAspectConfiguration__BeanDefinitions.getLoggingAspectConfigurationBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:259)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.config.LoggingConfiguration__BeanDefinitions.getLoggingConfigurationBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:260)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.config.OAuth2Configuration__BeanDefinitions.getAuthorizedClientManagerBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:334)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.config.OAuth2Configuration__BeanDefinitions.getOAuthConfigurationBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:261)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.config.SecurityConfiguration__BeanDefinitions.getFilterChainBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:361)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.config.SecurityConfiguration__BeanDefinitions.getJwtDecoderBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:363)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.config.SecurityConfiguration__BeanDefinitions.getSecurityConfigurationBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:262)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.config.SecurityConfiguration__BeanDefinitions.getUserAuthoritiesMapperBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:362)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.config.WebConfigurer__BeanDefinitions.getCorsFilterBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:364)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.config.WebConfigurer__BeanDefinitions.getWebConfigurerBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:263)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.repository.AuthorityRepository__BeanDefinitions.getAuthorityRepositoryBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:320)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.repository.BlogRepository__BeanDefinitions.getBlogRepositoryBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:309)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.repository.PostRepositoryWithBagRelationshipsImpl__BeanDefinitions.getPostRepositoryWithBagRelationshipsImplBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:311)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.repository.PostRepository__BeanDefinitions.getPostRepositoryBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:314)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.repository.TagRepository__BeanDefinitions.getTagRepositoryBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:323)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.repository.UserRepository__BeanDefinitions.getUserRepositoryBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:317)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.security.SpringSecurityAuditorAware__BeanDefinitions.getSpringSecurityAuditorAwareBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:264)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.security.oauth2.JwtGrantedAuthorityConverter__BeanDefinitions.getJwtGrantedAuthorityConverterBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:265)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.service.UserService__BeanDefinitions.getUserServiceBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:266)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.service.mapper.UserMapper__BeanDefinitions.getUserMapperBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:267)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.web.filter.OAuth2RefreshTokensWebFilter__BeanDefinitions.getOAuthRefreshTokensWebFilterBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:268)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.web.rest.AccountResource__BeanDefinitions.getAccountResourceBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:269)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.web.rest.AuthInfoResource__BeanDefinitions.getAuthInfoResourceBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:270)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.web.rest.BlogResource__BeanDefinitions.getBlogResourceBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:271)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.web.rest.LogoutResource__BeanDefinitions.getLogoutResourceBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:272)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.web.rest.PostResource__BeanDefinitions.getPostResourceBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:273)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.web.rest.PublicUserResource__BeanDefinitions.getPublicUserResourceBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:274)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.web.rest.TagResource__BeanDefinitions.getTagResourceBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:275)
Method <com.jhipster.demo.blog.BlogApp__BeanFactoryRegistrations.registerBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)> calls method <com.jhipster.demo.blog.web.rest.errors.ExceptionTranslator__BeanDefinitions.getExceptionTranslatorBeanDefinition()> in (BlogApp__BeanFactoryRegistrations.java:276)
    at com.tngtech.archunit.lang.ArchRule$Assertions.assertNoViolation(ArchRule.java:94)
    at com.tngtech.archunit.lang.ArchRule$Assertions.check(ArchRule.java:86)
    at com.tngtech.archunit.library.Architectures$LayeredArchitecture.check(Architectures.java:349)
    at com.tngtech.archunit.junit.internal.ArchUnitTestDescriptor$ArchUnitRuleDescriptor.execute(ArchUnitTestDescriptor.java:166)
    at com.tngtech.archunit.junit.internal.ArchUnitTestDescriptor$ArchUnitRuleDescriptor.execute(ArchUnitTestDescriptor.java:149)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:147)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:127)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:90)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:55)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:102)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:54)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
    at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
    at org.apache.maven.surefire.junitplatform.LazyLauncher.execute(LazyLauncher.java:56)
    at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.execute(JUnitPlatformProvider.java:184)
    at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invokeAllTests(JUnitPlatformProvider.java:148)
    at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:122)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:385)
    at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:162)
    at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:507)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:495)

If I skip tests with mvn -Pnative native:compile -DskipTests, it compiles successfully.

Finished generating 'blog' in 2m 33s.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  02:43 min
[INFO] Finished at: 2023-06-10T17:00:45-06:00
[INFO] ------------------------------------------------------------------------

However, it does not start successfully:

***************************
APPLICATION FAILED TO START
***************************

Description:

Binding to target [Bindable@6373256e type = tech.jhipster.config.JHipsterProperties, value = 'provided', annotations = array<Annotation>[@org.springframework.boot.context.properties.ConfigurationProperties(ignoreInvalidFields=false, ignoreUnknownFields=false, prefix="jhipster", value="jhipster")]] failed:

    Property: jhipster.cors.allow-credentials
    Value: "true"
    Origin: class path resource [config/application-dev.yml] - 76:24
    Reason: The elements [jhipster.cors.allow-credentials,jhipster.cors.allowed-headers,jhipster.cors.allowed-methods,jhipster.cors.allowed-origin-patterns,jhipster.cors.allowed-origins,jhipster.cors.exposed-headers,jhipster.cors.max-age] were left unbound.
    Property: jhipster.cors.allowed-headers
    Value: "*"
    Origin: class path resource [config/application-dev.yml] - 74:22
    Reason: The elements [jhipster.cors.allow-credentials,jhipster.cors.allowed-headers,jhipster.cors.allowed-methods,jhipster.cors.allowed-origin-patterns,jhipster.cors.allowed-origins,jhipster.cors.exposed-headers,jhipster.cors.max-age] were left unbound.
    Property: jhipster.cors.allowed-methods
    Value: "*"
    Origin: class path resource [config/application-dev.yml] - 73:22
    Reason: The elements [jhipster.cors.allow-credentials,jhipster.cors.allowed-headers,jhipster.cors.allowed-methods,jhipster.cors.allowed-origin-patterns,jhipster.cors.allowed-origins,jhipster.cors.exposed-headers,jhipster.cors.max-age] were left unbound.
    Property: jhipster.cors.allowed-origin-patterns
    Value: "https://*.githubpreview.dev"
    Origin: class path resource [config/application-dev.yml] - 72:30
    Reason: The elements [jhipster.cors.allow-credentials,jhipster.cors.allowed-headers,jhipster.cors.allowed-methods,jhipster.cors.allowed-origin-patterns,jhipster.cors.allowed-origins,jhipster.cors.exposed-headers,jhipster.cors.max-age] were left unbound.
    Property: jhipster.cors.allowed-origins
    Value: "http://localhost:8100,https://localhost:8100,http://localhost:9000,https://localhost:9000,http://localhost:4200,https://localhost:4200"
    Origin: class path resource [config/application-dev.yml] - 70:22
    Reason: The elements [jhipster.cors.allow-credentials,jhipster.cors.allowed-headers,jhipster.cors.allowed-methods,jhipster.cors.allowed-origin-patterns,jhipster.cors.allowed-origins,jhipster.cors.exposed-headers,jhipster.cors.max-age] were left unbound.
    Property: jhipster.cors.exposed-headers
    Value: "Authorization,Link,X-Total-Count,X-${jhipster.clientApp.name}-alert,X-${jhipster.clientApp.name}-error,X-${jhipster.clientApp.name}-params"
    Origin: class path resource [config/application-dev.yml] - 75:22
    Reason: The elements [jhipster.cors.allow-credentials,jhipster.cors.allowed-headers,jhipster.cors.allowed-methods,jhipster.cors.allowed-origin-patterns,jhipster.cors.allowed-origins,jhipster.cors.exposed-headers,jhipster.cors.max-age] were left unbound.
    Property: jhipster.cors.max-age
    Value: "1800"
    Origin: class path resource [config/application-dev.yml] - 77:14
    Reason: The elements [jhipster.cors.allow-credentials,jhipster.cors.allowed-headers,jhipster.cors.allowed-methods,jhipster.cors.allowed-origin-patterns,jhipster.cors.allowed-origins,jhipster.cors.exposed-headers,jhipster.cors.max-age] were left unbound.

Action:

Update your application's configuration

If I remove all the jhipster.* properties from application-dev.yml, I get a bit further, but it still doesn't start.

org.springframework.context.ApplicationContextException: Unable to start web server
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:164)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:578)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:310)
    at com.jhipster.demo.blog.BlogApp.main(BlogApp.java:70)
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: Failed to load and initialize org.h2.server.web.JakartaWebServlet
    at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:257)
    at org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory.createManager(UndertowServletWebServerFactory.java:329)
    at org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory.getWebServer(UndertowServletWebServerFactory.java:298)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:183)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:161)
    ... 6 common frames omitted
Caused by: java.lang.RuntimeException: Failed to load and initialize org.h2.server.web.JakartaWebServlet
    at tech.jhipster.config.h2.H2ConfigurationHelper.initH2Console(H2ConfigurationHelper.java:128)
    at com.jhipster.demo.blog.config.WebConfigurer.initH2Console(WebConfigurer.java:108)
    at com.jhipster.demo.blog.config.WebConfigurer.onStartup(WebConfigurer.java:50)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.selfInitialize(ServletWebServerApplicationContext.java:236)
    at org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory$Initializer.onStartup(UndertowServletWebServerFactory.java:507)
    at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:204)
    at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:187)
    at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)
    at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
    at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:255)
    ... 10 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.h2.server.web.JakartaWebServlet. This exception was synthesized during native image building from a call to java.lang.Class.forName(String, boolean, ClassLoader) with constant arguments.
    at tech.jhipster.config.h2.H2ConfigurationHelper.initH2Console(H2ConfigurationHelper.java:119)
    ... 19 common frames omitted
Motivation for or Use Case

We should support GraalVM Native Images by default.

JDL used
application {
  config {
    baseName blog,
    applicationType monolith
    authenticationType oauth2
    packageName com.jhipster.demo.blog
    prodDatabaseType mysql
    cacheProvider ehcache
    buildTool maven
    clientFramework angular
    testFrameworks [cypress]
  }
  entities *
}

entity Blog {
  name String required minlength(3)
  handle String required minlength(2)
}

entity Post {
  title String required
  content TextBlob required
  date Instant required
}

entity Tag {
  name String required minlength(2)
}

relationship ManyToOne {
  Blog{user(login)} to User with builtInEntity
  Post{blog(name)} to Blog
}

relationship ManyToMany {
  Post{tag(name)} to Tag{entry}
}

paginate Post, Tag with infinite-scroll
atomfrede commented 1 year ago

We should agree on a first configuration to get Native image compilation up and running otherwise it will be to cumbersome try to get native hints for all configurations right.

So maybe (monolith) SQL + jwt and oauth?

atomfrede commented 1 year ago

@mraible Can you create an example repo? I can start checking what needs to be done. Regarding modernizer and arch unit things I guess they are working on the ahead of time compiled class files, which seem to violate some package constraints and using auto(un)oxing or so. Maybe we can just exclude them when aot is in place.

JeroenAdam commented 1 year ago

FYI, 3 weeks ago, Josh Long sucessfully natively compiled these 3 projects https://github.com/spring-projects/spring-authorization-server/tree/main/samples/ No H2 in there, which seems to be blocking here.

mraible commented 1 year ago

@atomfrede I created a blog-oauth2-native project and added a pull request with the changes necessary to get things compiled with GraalVM.