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.53k stars 4.02k forks source link

ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [tech.jhipster.config.JHipsterProperties$Security] #26432

Closed thelafarge closed 4 months ago

thelafarge commented 4 months ago

Overview of the issue

I generated a jhipster project but i have the following error :

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

Description:

Failed to bind properties under 'jhipster.security' to tech.jhipster.config.JHipsterProperties$Security:

    Reason: org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [tech.jhipster.config.JHipsterProperties$Security]

Action:

Update your application's configuration

Reproduce the error

Generate a jhipster project

Generate a jhipster project with the jhipster command. Here is the result of jhipster info

<details>
<summary>.yo-rc.json file</summary>
<pre>
{
  "generator-jhipster": {
    "applicationType": "monolith",
    "authenticationType": "jwt",
    "baseName": "jhipster",
    "buildTool": "maven",
    "cacheProvider": "no",
    "clientFramework": "no",
    "clientTestFrameworks": null,
    "clientTheme": null,
    "creationTimestamp": 1718375226087,
    "databaseType": "sql",
    "devDatabaseType": "postgresql",
    "enableHibernateCache": false,
    "enableSwaggerCodegen": true,
    "enableTranslation": false,
    "entities": [],
    "feignClient": null,
    "jhipsterVersion": "8.5.0",
    "messageBroker": false,
    "microfrontend": null,
    "microfrontends": [],
    "nativeLanguage": "fr",
    "packageName": "com.mycompany.myapp",
    "prodDatabaseType": "postgresql",
    "reactive": false,
    "searchEngine": false,
    "serverPort": null,
    "serverSideOptions": [
      "enableSwaggerCodegen:true"
    ],
    "serviceDiscoveryType": false,
    "skipClient": true,
    "syncUserWithIdp": null,
    "testFrameworks": ["cypress"],
    "websocket": false,
    "withAdminUi": null
  }
}
</pre>
</details>

##### **Environment and Tools**

openjdk version "21.0.3" 2024-04-16 LTS
OpenJDK Runtime Environment Temurin-21.0.3+9 (build 21.0.3+9-LTS)
OpenJDK 64-Bit Server VM Temurin-21.0.3+9 (build 21.0.3+9-LTS, mixed mode)

git version 2.37.3

node: v18.18.2
npm: 9.8.1

Docker version 25.0.2, build 29cf629

##### **JDL for the Entity configuration(s) `entityName.json` files generated in the `.jhipster` directory**

<details>
<summary>JDL entity definitions</summary>

<pre>

</pre>
</details>

Start the database

Start the postgres container with the command

docker compose -f src/main/docker/postgresql.yml up -d

Start the application

Start the application with the command `./mvnw'

This is where I experience the APPLICATION FAILED TO START 🥺

mshima commented 4 months ago

Please add jhipster info output at issue description.

thelafarge commented 4 months ago

I updated the description to add the output of the jhipster info command. Note that i'm now in a monolith but I still have this issue.

I discovered something else.

I tried a new generation from the command line, started my postgres container and then, started the app with ./mvnw. It seemed to work fine with the following output :

----------------------------------------------------------
    Application 'jhipster' is running! Access URLs:
    Local:      http://localhost:8080/
    External:   http://192.168.1.18:8080/
    Profile(s):     [dev, api-docs]
----------------------------------------------------------

But as soon I open in vscode, the following output append to the terminal :

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/

 :: Spring Boot ::                (v3.3.0)

2024-06-14T16:42:12.363+02:00  INFO 13758 --- [jhipster] [  restartedMain] com.mycompany.myapp.JhipsterApp          : Starting JhipsterApp using Java 21.0.3 with PID 13758 (/Users/tle/Documents/code/poc/jhipster/target/classes started by tle in /Users/tle/Documents/code/poc/jhipster)
2024-06-14T16:42:12.363+02:00  INFO 13758 --- [jhipster] [  restartedMain] com.mycompany.myapp.JhipsterApp          : No active profile set, falling back to 1 default profile: "dev"
2024-06-14T16:42:12.370+02:00  WARN 13758 --- [jhipster] [  restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: I/O failure while processing configuration class [null]
2024-06-14T16:42:12.392+02:00 ERROR 13758 --- [jhipster] [  restartedMain] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanDefinitionStoreException: I/O failure while processing configuration class [null]
    at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:251) ~[spring-context-6.1.8.jar:6.1.8]
    at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:197) ~[spring-context-6.1.8.jar:6.1.8]
    at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:165) ~[spring-context-6.1.8.jar:6.1.8]
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:417) ~[spring-context-6.1.8.jar:6.1.8]
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:290) ~[spring-context-6.1.8.jar:6.1.8]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:349) ~[spring-context-6.1.8.jar:6.1.8]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:118) ~[spring-context-6.1.8.jar:6.1.8]
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:788) ~[spring-context-6.1.8.jar:6.1.8]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:606) ~[spring-context-6.1.8.jar:6.1.8]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.3.0.jar:3.3.0]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) ~[spring-boot-3.3.0.jar:3.3.0]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456) ~[spring-boot-3.3.0.jar:3.3.0]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:335) ~[spring-boot-3.3.0.jar:3.3.0]
    at com.mycompany.myapp.JhipsterApp.main(JhipsterApp.java:70) ~[classes/:na]
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[na:na]
    at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:50) ~[spring-boot-devtools-3.3.0.jar:3.3.0]
Caused by: java.io.FileNotFoundException: class path resource [com/mycompany/myapp/JhipsterApp.class] cannot be opened because it does not exist
    at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:215) ~[spring-core-6.1.8.jar:6.1.8]
    at org.springframework.core.type.classreading.SimpleMetadataReader.getClassReader(SimpleMetadataReader.java:54) ~[spring-core-6.1.8.jar:6.1.8]
    at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:48) ~[spring-core-6.1.8.jar:6.1.8]
    at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:103) ~[spring-core-6.1.8.jar:6.1.8]
    at org.springframework.boot.type.classreading.ConcurrentReferenceCachingMetadataReaderFactory.createMetadataReader(ConcurrentReferenceCachingMetadataReaderFactory.java:86) ~[spring-boot-3.3.0.jar:3.3.0]
    at org.springframework.boot.type.classreading.ConcurrentReferenceCachingMetadataReaderFactory.getMetadataReader(ConcurrentReferenceCachingMetadataReaderFactory.java:73) ~[spring-boot-3.3.0.jar:3.3.0]
    at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:81) ~[spring-core-6.1.8.jar:6.1.8]
    at org.springframework.context.annotation.ConfigurationClassParser.asSourceClass(ConfigurationClassParser.java:630) ~[spring-context-6.1.8.jar:6.1.8]
    at org.springframework.context.annotation.ConfigurationClassParser.asSourceClass(ConfigurationClassParser.java:599) ~[spring-context-6.1.8.jar:6.1.8]
    at org.springframework.context.annotation.ConfigurationClassParser.asSourceClass(ConfigurationClassParser.java:577) ~[spring-context-6.1.8.jar:6.1.8]
    at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:244) ~[spring-context-6.1.8.jar:6.1.8]
    ... 16 common frames omitted

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/

 :: Spring Boot ::                (v3.3.0)

2024-06-14T16:42:15.269+02:00  INFO 13758 --- [jhipster] [  restartedMain] com.mycompany.myapp.JhipsterApp          : Starting JhipsterApp using Java 21.0.3 with PID 13758 (/Users/tle/Documents/code/poc/jhipster/target/classes started by tle in /Users/tle/Documents/code/poc/jhipster)
2024-06-14T16:42:15.270+02:00  INFO 13758 --- [jhipster] [  restartedMain] com.mycompany.myapp.JhipsterApp          : No active profile set, falling back to 1 default profile: "dev"
2024-06-14T16:42:15.465+02:00  INFO 13758 --- [jhipster] [  restartedMain] o.s.c.i.support.PropertySourceProcessor  : Properties location [classpath:META-INF/build-info.properties] not resolvable: class path resource [META-INF/build-info.properties] cannot be opened because it does not exist
2024-06-14T16:42:15.477+02:00  INFO 13758 --- [jhipster] [  restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2024-06-14T16:42:15.485+02:00  INFO 13758 --- [jhipster] [  restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 8 ms. Found 2 JPA repository interfaces.
2024-06-14T16:42:15.989+02:00  WARN 13758 --- [jhipster] [  restartedMain] io.undertow.websockets.jsr               : UT026010: Buffer pool was not set on WebSocketDeploymentInfo, the default pool will be used
2024-06-14T16:42:15.993+02:00  INFO 13758 --- [jhipster] [  restartedMain] io.undertow.servlet                      : Initializing Spring embedded WebApplicationContext
2024-06-14T16:42:15.993+02:00  INFO 13758 --- [jhipster] [  restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 722 ms
2024-06-14T16:42:16.255+02:00  INFO 13758 --- [jhipster] [  restartedMain] c.mycompany.myapp.config.WebConfigurer   : Web application fully configured
2024-06-14T16:42:16.307+02:00  WARN 13758 --- [jhipster] [  restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Failed to initialize dependency 'liquibase' of LoadTimeWeaverAware bean 'entityManagerFactory': Error creating bean with name 'liquibase' defined in class path resource [com/mycompany/myapp/config/LiquibaseConfiguration.class]: Failed to instantiate [liquibase.integration.spring.SpringLiquibase]: Factory method 'liquibase' threw exception with message: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception with message: Failed to determine a suitable driver class
2024-06-14T16:42:16.319+02:00  INFO 13758 --- [jhipster] [  restartedMain] .s.b.a.l.ConditionEvaluationReportLogger :

Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2024-06-14T16:42:16.323+02:00 ERROR 13758 --- [jhipster] [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   :

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

Description:

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

Reason: Failed to determine a suitable driver class

Action:

Consider the following:
    If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
    If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).

        ██╗ ██╗   ██╗ ████████╗ ███████╗   ██████╗ ████████╗ ████████╗ ███████╗
        ██║ ██║   ██║ ╚══██╔══╝ ██╔═══██╗ ██╔════╝ ╚══██╔══╝ ██╔═════╝ ██╔═══██╗
        ██║ ████████║    ██║    ███████╔╝ ╚█████╗     ██║    ██████╗   ███████╔╝
  ██╗   ██║ ██╔═══██║    ██║    ██╔════╝   ╚═══██╗    ██║    ██╔═══╝   ██╔══██║
  ╚██████╔╝ ██║   ██║ ████████╗ ██║       ██████╔╝    ██║    ████████╗ ██║  ╚██╗
   ╚═════╝  ╚═╝   ╚═╝ ╚═══════╝ ╚═╝       ╚═════╝     ╚═╝    ╚═══════╝ ╚═╝   ╚═╝

:: JHipster 🤓  :: Running Spring Boot 3.3.0 :: Startup profile(s) @spring.profiles.active@ ::
:: https://www.jhipster.tech ::

2024-06-14T16:42:20.811+02:00  INFO 13758 --- [  restartedMain] com.mycompany.myapp.JhipsterApp          : Starting JhipsterApp using Java 21.0.3 with PID 13758 (/Users/tle/Documents/code/poc/jhipster/target/classes started by tle in /Users/tle/Documents/code/poc/jhipster)
2024-06-14T16:42:20.811+02:00  INFO 13758 --- [  restartedMain] com.mycompany.myapp.JhipsterApp          : The following 1 profile is active: "@spring.profiles.active@"
2024-06-14T16:42:21.302+02:00  WARN 13758 --- [  restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server
2024-06-14T16:42:21.307+02:00  INFO 13758 --- [  restartedMain] .s.b.a.l.ConditionEvaluationReportLogger :

Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2024-06-14T16:42:21.309+02:00 ERROR 13758 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   :

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

Description:

Failed to bind properties under 'jhipster.security' to tech.jhipster.config.JHipsterProperties$Security:

    Reason: org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [tech.jhipster.config.JHipsterProperties$Security]

Action:

Update your application's configuration
github-actions[bot] commented 4 months ago

JHipster has completed the sample check .yo-rc.json: valid Entities JDL: blank Application: successfully generated Frontend check: success Backend check: success E2E check: success

This check uses jhipster info output from the issue description to generate the sample. Bug report that does not contain this information will be marked as invalid.

thelafarge commented 4 months ago

I switched spring.profiles.active from '@spring.profiles.active@' to dev in resources/config/application.yml and it's working now

mshima commented 4 months ago

I switched spring.profiles.active from '@spring.profiles.active@' to dev in resources/config/application.yml and it's working now

If the issue is fixed with the above step, this is duplicated of https://github.com/jhipster/generator-jhipster/issues/26333. And fixed by https://github.com/jhipster/generator-jhipster/commit/d89f7c1475c92e1d3ed67d93bb91373944325897.

mshima commented 4 months ago

Seems to be resolved, closing.