jhipster cannot run on docker and local computer - jhipster

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

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! **

Getting User Creation Exception With the Jhipster Application

I have successfully generated the application using Jhipster (Angular, MySQL). As an admin, I have logged in and trying to create a new user but I am getting the below error.
2021-05-10 21:55:14.218 ERROR 29756 --- [ XNIO-1 task-2] com.kc.bsadhana.service.UserService : Exception in createUser() with cause = 'java.lang.RuntimeException: Connection refused' and exception = 'Connection refused; nested exception is java.lang.RuntimeException: Connection refused'
org.springframework.dao.DataAccessResourceFailureException: Connection refused; nested exception is java.lang.RuntimeException: Connection refused
at org.springframework.data.elasticsearch.core.ElasticsearchExceptionTranslator.translateExceptionIfPossible(ElasticsearchExceptionTranslator.java:75)
at org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate.translateException(ElasticsearchRestTemplate.java:362)
at org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate.execute(ElasticsearchRestTemplate.java:345)
at org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate.doIndex(ElasticsearchRestTemplate.java:143)
...
Caused by: java.lang.RuntimeException: Connection refused
at org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate.translateException(ElasticsearchRestTemplate.java:360)
... 198 common frames omitted
Caused by: java.net.ConnectException: Connection refused
at org.elasticsearch.client.RestClient.extractAndWrapCause(RestClient.java:849)
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:259)
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:246)
at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1613)
at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1583)
at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:1553)
at org.elasticsearch.client.RestHighLevelClient.index(RestHighLevelClient.java:970)
at org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate.lambda$doIndex$0(ElasticsearchRestTemplate.java:143)
at org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate.execute(ElasticsearchRestTemplate.java:343)
... 197 common frames omitted
Caused by: java.net.ConnectException: Connection refused
at java.base/sun.nio.ch.Net.pollConnect(Native Method)
at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:589)
at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:839)
at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvent(DefaultConnectingIOReactor.java:174)
at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvents(DefaultConnectingIOReactor.java:148)
at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.execute(AbstractMultiworkerIOReactor.java:351)
at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.execute(PoolingNHttpClientConnectionManager.java:221)
at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase$1.run(CloseableHttpAsyncClientBase.java:64)
... 1 common frames omitted
2021-05-10 21:55:14.238 ERROR 29756 --- [ XNIO-1 task-2] com.kc.bsadhana.web.rest.UserResource : Exception in createUser() with cause = 'java.lang.RuntimeException: Connection refused' and exception = 'Connection refused; nested exception is java.lang.RuntimeException: Connection refused'
org.springframework.dao.DataAccessResourceFailureException: Connection refused; nested exception is java.lang.RuntimeException: Connection refused
In application-dev.yml file I have entered the database credentials :
datasource:
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:mysql://localhost:3306/bsadhana?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC&createDatabaseIfNotExist=true
username: root
password: rxxxx!
hikari:
Even the jhipster related tables were created in my database. But when I am trying to create a new user it is throwing the above-reported error. is there anywhere else I need to enter these credentials?
The error says your app cannot connect to your Elasticsearch instance, you should make sure you started it with following command as explained in the doc:
docker-compose -f src/main/docker/elasticsearch.yml up

o.s.boot.SpringApplication: Application run failed

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.

Failure to operate liquibase checksum - server time - with Jhipster project

I want to operate basic liquibase operations with maven in a Jhipster project. I'm using nvm 10.16.1 and Jhipster 6.2.0. I get a message error.
I checked the if the precognized line for server time error was in my app-dev and yes it is.
url: jdbc:mysql://localhost:3306/project?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC
Here is the message error:
INFO] Starting Liquibase at lun., 12 août 2019 10:54:40 CEST (version 3.6.3 built at 2019-01-29 11:34:48)
[INFO] Settings
----------------------------
[INFO] driver: com.mysql.cj.jdbc.Driver
[INFO] url: jdbc:mysql://localhost:3306/project
[INFO] username: root
[INFO] password: *****
[INFO] use empty password: false
[INFO] properties file: null
[INFO] properties file will override? false
[INFO] prompt on non-local database? true
[INFO] clear checksums? false
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.394 s
[INFO] Finished at: 2019-08-12T10:54:41+02:00
[INFO] Final Memory: 31M/353M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.liquibase:liquibase-maven- plugin:3.6.3:clearCheckSums (default-cli) on project project: Error setting up or running Liquibase: liquibase.exception.DatabaseException: java.sql.SQLException: The server time zone value 'Paris, Madrid (heure d��t�)' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Process finished with exit code 1
TRY 2 : put the url in pom xml
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>${liquibase.version}</version>
<configuration>
<changeLogFile>${project.basedir}/src/main/resources/config/liquibase/master.xml</changeLogFile>
<diffChangeLogFile>${project.basedir}/src/main/resources/config/liquibase/changelog/${maven.build.timestamp}_changelog.xml</diffChangeLogFile>
<driver>com.mysql.cj.jdbc.Driver</driver>
<url>jdbc:mysql://localhost:3306/project?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC</url>
<defaultSchemaName>project</defaultSchemaName>
<username>root</username>
<password>*******</password>
<referenceUrl>hibernate:spring:fr.project.domain?dialect=org.hibernate.dialect.MySQL5InnoDBDialect&hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy</referenceUrl>
<verbose>true</verbose>
<logging>debug</logging>
<contexts>!test</contexts>
</configuration>
The new error is:
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-parseable POM
C:\Users\clari\Documents\project\pom.xml: entity reference name can not
contain character =' (position: START_TAG seen
...mysql://localhost:3306/project?useUnicode=true&characterEncoding=...
#561:101) # line 561, column 101
#
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project
(C:\Users\clari\Documents\project\pom.xml) has 1 error
[ERROR] Non-parseable POM
C:\Users\clari\Documents\project\pom.xml: entity reference name can not contain character =' (position: START_TAG seen ...mysql://localhost:3306/project?useUnicode=true&characterEncoding=... #561:101) # line 561, column 101 -> [Help 2]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions,
please read the following articles:
[ERROR] [Help 1]
http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2]
http://cwiki.apache.org/confluence/display/MAVEN/ModelParseException
Process finished with exit code 1
Could you please help me?
Thanks :)
You trace shows that you use liquibase-maven-plugin to execute clearCheckSums goal, the JDBC URL in application-dev.yml is read only by your java application not by maven liquibase plugin.
You must configure it also in pom.xml in the url property of liquibase-maven-plugin.
Warning, the & characters in the <url> should be encodes as XML entity &.
<url>jdbc:mysql://localhost:3306/project?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC</url>

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