o.s.boot.SpringApplication: Application run failed - jhipster

I get this error after creating entity. Here is my log:
2021-01-12 11:56:39.828 DEBUG 9424 --- [ restartedMain] c.e.c.E.domain.User.authorities : Close successful.
2021-01-12 11:56:39.875 ERROR 9424 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: jdk11.domain.Libro.scritto in jdk11.domain.Scritto.libros
Caused by: org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: jdk11.domain.Libro.scritto in jdk11.domain.Scritto.libros
How can i solve? I have already checked the entity names.

Related

Issue while connecting to Cassandra running in docker from Spring boot application

**application.properties: **
spring.data.cassandra.local-datacenter=datacenter1
spring.data.cassandra.keyspace-name=oboe
spring.data.cassandra.contact-points=cassandra
spring.data.cassandra.port=9042
spring.data.cassandra.username=cassandra
spring.data.cassandra.password=cassandra
spring.data.cassandra.schema-action=create_if_not_exists
spring.data.cassandra.entity-base-package=com.example.cassandra.connectivity
**Error while starting Spring applciation: **
2022-10-06 23:55:34.844 WARN 3284 --- [ s0-admin-1] c.d.o.d.i.c.control.ControlConnection : [s0] Error connecting to Node(endPoint=cassandra/<unresolved>:9042, hostId=null, hashCode=68e4631), trying next node (UnknownHostException: No such host is known (cassandra))
2022-10-06 23:55:36.980 WARN 3284 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'scanLocationDataController': Unsatisfied dependency expressed through field 'service'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'scanLocationDataService': Unsatisfied dependency expressed through field 'repo'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scanLocationDataRepo' defined in org.gcs.cassandra.repo.ScanLocationDataRepo defined in #EnableCassandraRepositories declared on CassandraRepositoriesRegistrar.EnableCassandraRepositoriesConfiguration: Cannot resolve reference to bean 'cassandraTemplate' while setting bean property 'cassandraTemplate'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cassandraTemplate' defined in class path resource [org/gcs/cassandra/config/CassandraConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.cassandra.core.CassandraAdminTemplate]: Factory method 'cassandraTemplate' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cassandraSessionFactory' defined in class path resource [org/gcs/cassandra/config/CassandraConfig.class]: Unsatisfied dependency expressed through method 'cassandraSessionFactory' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cassandraSession' defined in class path resource [org/gcs/cassandra/config/CassandraConfig.class]: Invocation of init method failed; nested exception is com.datastax.oss.driver.api.core.AllNodesFailedException: Could not reach any contact point, make sure you've provided valid addresses (showing first 1 nodes, use getAllErrors() for more): Node(endPoint=cassandra/<unresolved>:9042, hostId=null, hashCode=68e4631): [java.net.UnknownHostException: No such host is known (cassandra)]
**Docker Container logs: **
cassandra 21:35:51.97 INFO ==> ** Starting Cassandra setup **
cassandra 21:35:51.98 WARN ==> CASSANDRA_HOST not set, defaulting to system hostname
cassandra 21:35:51.98 INFO ==> Validating settings in CASSANDRA_* env vars..
cassandra 21:35:51.99 WARN ==> You've not provided a password. Default password "cassandra" will be used. For safety reasons, please provide a secure password in a production environment.
cassandra 21:35:51.99 WARN ==> You set the environment variable CASSANDRA_PASSWORD=cassandra. This is the default value when bootstrapping Cassandra and should not be used in production environments.
cassandra 21:35:52.01 INFO ==> Initializing Cassandra database...
cassandra 21:35:52.21 INFO ==> Deploying Cassandra from scratch
cassandra 21:35:52.22 INFO ==> Starting Cassandra
cassandra 21:35:52.22 INFO ==> Checking that it started up correctly
cassandra 21:36:57.30 INFO ==> Found CQL startup log line
cassandra 21:36:58.74 INFO ==> Nodetool reported the successful startup of Cassandra
cassandra 21:36:58.75 INFO ==> Non-seeder node. Waiting for synchronization
cassandra 21:36:58.75 INFO ==> Trying to access CQL server # ccff4fe7e189
cassandra 21:37:11.24 INFO ==> Accessed CQL server successfully
cassandra 21:37:11.25 INFO ==> ** Cassandra setup finished! **

JHipster with Okta Application Failed to Start due to UnsatisfiedDependencyException

Getting the following error when starting JHipster Gateway application after adding OKTA configuration:
$ cd saathratrigateway
$ ./mvnw
...
2020-11-13 22:31:16.278 WARN 80043 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'authorizationHeaderUtil' defined in file [/Users/amar/workspace/saathratri-app-holder/saathratrigateway/target/classes/com/saathratri/security/oauth2/AuthorizationHeaderUtil.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.security.oauth2.client.OAuth2AuthorizedClientService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
2020-11-13 22:31:16.280 DEBUG 80043 --- [ restartedMain] c.e.c.E.saathratri.domain.Authority : Close successful.
2020-11-13 22:31:16.281 DEBUG 80043 --- [ restartedMain] c.e.c.E.saathratri.domain.User : Close successful.
2020-11-13 22:31:16.281 DEBUG 80043 --- [ restartedMain] c.e.c.E.s.domain.User.authorities : Close successful.
2020-11-13 22:31:16.282 DEBUG 80043 --- [ restartedMain] c.ehcache.core.Ehcache-usersByEmail : Close successful.
2020-11-13 22:31:16.282 DEBUG 80043 --- [ restartedMain] c.ehcache.core.Ehcache-usersByLogin : Close successful.
2020-11-13 22:31:16.479 ERROR 80043 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of constructor in com.saathratri.security.oauth2.AuthorizationHeaderUtil required a bean of type 'org.springframework.security.oauth2.client.OAuth2AuthorizedClientService' that could not be found.
The following candidates were found but could not be injected:
- Bean method 'authorizedClientService' in 'OAuth2WebSecurityConfiguration' not loaded because #ConditionalOnBean (types: org.springframework.security.oauth2.client.registration.ClientRegistrationRepository; SearchStrategy: all) did not find any beans of type org.springframework.security.oauth2.client.registration.ClientRegistrationRepository
Action:
Consider revisiting the entries above or defining a bean of type 'org.springframework.security.oauth2.client.OAuth2AuthorizedClientService' in your configuration.
Any advise would be appreciated greatly.
Okay - figured it out. I had to create ~/.okta.env and then run source ~/.okta.env. See below....
$ vi ~/.okta.env
---
export SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_OIDC_ISSUER_URI="https://dev-XXXXXXX.okta.com/oauth2/default"
export SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_OIDC_CLIENT_ID="XXXXXXXXXXXXXXXXXXXX"
export SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_OIDC_CLIENT_SECRET="XXXXXX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
export OKTA_OAUTH2_ISSUER="https://dev-XXXXXXX.okta.com/oauth2/default"
export OKTA_OAUTH2_CLIENT_ID_WEB="XXXXXXXXXXXXXXXXXXXX"
export OKTA_OAUTH2_CLIENT_SECRET_WEB="XXXXXX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
---
$ source ~/.okta.env
$ cd saathratrigateway
$ ./mvnw
I was following instructions from https://developer.okta.com/blog/2018/03/01/develop-microservices-jhipster-oauth.
Thank you Matt Raible!
Happy Diwali.

jhipster cannot run on docker and local computer

I followed all the steps here: https://www.jhipster.tech/installation/
for the local configuration, the jhipster was successfully built but didn't run on port 8080. This is the error:
2020-05-06 08:11:56.212 WARN 521 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'servletEndpointRegistrar' defined in class path resource [org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfiguration$WebMvcServletEndpointManagementContextConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar]: Factory method 'servletEndpointRegistrar' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'healthEndpoint' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Unsatisfied dependency expressed through method 'healthEndpoint' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'healthContributorRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthContributorRegistry]: Factory method 'healthContributorRegistry' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'JHipsterHealthIndicatorConfiguration' defined in file [/home/jhipster/app/target/classes/com/kschain/app/config/metrics/JHipsterHealthIndicatorConfiguration.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cassandraConfiguration': Invocation of init method failed; nested exception is com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: localhost/127.0.0.1:9042 (com.datastax.driver.core.exceptions.TransportException: [localhost/127.0.0.1:9042] Cannot connect))
2020-05-06 08:11:58.253 ERROR 521 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed
and this is what I got after all the steps are done
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 06:27 min
[INFO] Finished at: 2020-05-06T08:11:58Z
[INFO] ------------------------------------------------------------------------
2. The same problem occurred with the docker image
`2020-05-06 08:16:58.253 ERROR 521 --- [ restartedMain]
o.s.boot.SpringApplication: Application run failed`
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 06:27 min
[INFO] Finished at: 2020-05-06T08:18:58Z
[INFO] ------------------------------------------------------------------------
root#e8220a295cf8:/home/jhipster/app#
what's wrong?
The explanation is in the logs:
Error creating bean with name 'cassandraConfiguration': Invocation of init method failed; nested exception is com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: localhost/127.0.0.1:9042
You probably forgot to start Cassandra as explained in your project's generated README.md:
docker-compose -f src/main/docker/cassandra.yml up -d

Exception occurred while calling driver.quit(): Unable to load configuration from class 'class GebConfig' (with environment: )

I am running Groovy automation script, but i am getting the following error,
Exception occurred while calling driver.quit(): Unable to load configuration from class 'class GebConfig' (with environment: )

Trouble using Spring Config Server in jhipster-registry

I created a microservice architecture using JHipster. I am using the jhipster-registry v2.8.0. I renamed the 'dev' profile to 'devdmi' because I will have many 'dev' profiles. It is working OK using the "dev,native" profiles for the jhipster-registry and each microservice including it's application-devdmi.yml / boostrap-devdmi.yml files.
I tried to convert this configuration over to using a Git repo. I built my Git repo with .yml files, but I'm not exactly sure of the configuration to use. At the moment I've got:
MyConfig/app1/MyApp1-devdmi.yml
MyConfig/app2/MyApp2-devdmi.yml
I also tried using:
MyConfig/MyApp1-devdmi.yml
MyConfig/MyApp2-devdmi.yml
In MyApp1, I renamed src/main/resources/config/application-devdmi.yml to application-devdmi.yml.bak hoping it would pick up the config from the jhipster-registry acting as a Spring Cloud Config Server.
In MyApp1, I have a bootstrap-devdmi.yml with:
spring:
application:
name: my-app-1
cloud:
config:
fail-fast: true
uri: http://admin:${jhipster.registry.password}#my.host.com:8761/config
name: MyApp1
profile: devdmi
label: master
The jhipster-registry starts up and shows it is connected to the Git repo by looking at the Configuration webpage.
MyApps1 doesn't start and throws an error about Liquibase not knowing which database to connect to:
2017-05-23 13:09:52.669 WARN 60704 --- [ main] o.s.boot.SpringApplication : Error handling failed (Error creating bean with name 'delegatingApplicationListener' defined in class path resource [org/springframework/security/config/annotation /web/configuration/WebSecurityConfiguration.class]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.config.internalTransactionAdvisor' defined in class path resource [org/springframework/transaction/annotation/ProxyTransactionManagementConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor]: Factory method 'transactionAdvisor' threw exception; nested exception is java.lang.NullPointerException)
2017-05-23 13:09:52.683 ERROR 60704 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Cannot determine embedded database driver class for database type NONE
Any ideas?

Resources