App does not connect to database after deploying - heroku

I built an app using JHipster, which works fine locally. Then i deployed the app to heroku using the command JHipster Heroku. The app stops startup with following log entry:
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to bind properties under '' to com.zaxxer.hikari.HikariDataSource:
Property: driverclassname
Value: com.mysql.jdbc.Driver
Origin: "driverClassName" from property source "source"
Reason: Failed to load driver class com.mysql.jdbc.Driver in either of HikariConfig class loader or Thread context classloader
Action:
Update your application's configuration
Obviously the app does not connect to the database, but how can i fix that?

Related

Spring boot applications sometimes fails to "bind properties" on high load

So every morning we're starting around ~30 spring-boot microservices.
Sometimes one of them is failing to start up.
Running Spring boot 2.1.5.
Today it was with the following error:
2021-11-15 02:18:32.269 INFO 12258023 --- [main] dk.yx.oiltanks.OilTanksApplication : The following profiles are active: prod
2021-11-15 02:19:49.406 ERROR 12258023 --- [main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to bind properties under 'spring.mvc.servlet' to org.springframework.boot.autoconfigure.web.servlet.WebMvcProperties$Servlet:
Reason: Failed to bind properties under 'spring.mvc.servlet' to org.springframework.boot.autoconfigure.web.servlet.WebMvcProperties$Servlet
Action:
Update your application's configuration
Is there any configuration parameters to increase "bind properties" time ?
All we did to get this application running again was starting it with the normal command.
Configuration file:
endpoints.cors.allowed-methods=GET
endpoints.cors.allowed-origins=*
eureka.client.serviceUrl.defaultZone=**HOSTNAME**:13499/eureka/
eureka.instance.healthCheckUrl=https\://${eureka.hostname}\:${server.port}/actuator/health
eureka.instance.homePageUrl=https\://${eureka.hostname}\:${server.port}/
eureka.instance.hostname=**HOSTNAME**
eureka.instance.nonSecurePortEnabled=false
eureka.instance.securePort=${server.port}
eureka.instance.securePortEnabled=true
eureka.instance.statusPageUrl=https\://${eureka.hostname}\:${server.port}/actuator/info
feign.client.config.default.connectTimeout=1600000
feign.client.config.default.readTimeout=1600000
logging.file.max-history=50
logging.file.max-size=100MB
logging.file=application.log
logging.level.dk.yx.yxdb=INFO
logging.level.dk.yx=INFO
logging.level.org.hibernate.SQL=INFO
logging.level.org.hibernate.type.descriptor.sql=INFO
logging.level.org.springframework.web.filter.CommonsRequestLoggingFilter=INFO
logging.level.org.springframework.web=INFO
management.endpoints.web.cors.allowed-methods=GET
management.endpoints.web.cors.allowed-origins=*
multipart.maxFileSize=-1
multipart.maxRequestSize=-1
pring.mvc.async.request-timeout=300000
server.connection-timeout=999999
server.http.port=3517
server.port=13517
server.ssl.key-alias=yx_dk
server.ssl.key-store-password=**PASSWORD**
server.ssl.key-store-type=PKCS12
server.ssl.key-store=/QOpenSys/etc/ssl/wildcard_yx_dk.p12
spring.application.name=OIL_TANK_SERVICE
spring.datasource.driver-class-name=com.ibm.as400.access.AS400JDBCDriver
spring.datasource.hibernate.default_schema=NHODATA
spring.datasource.hikari.connectionTimeout=90000
spring.datasource.hikari.idleTimeout=120000
spring.datasource.hikari.minimumIdle=3
spring.datasource.password=unreadable
spring.datasource.url=jdbc\:as400\:bmw/;naming\=system;libraries\=NHODATA,QTEMP,YXDTA24,ICEBREAK,NHOPRG,SYSAFD,QGPL,QIDU,OTCONLINE,SMS,YXDB,YXAPP,SMSDB;date format\=eur;time format\=eur;
spring.datasource.username=sqlread
spring.http.multipart.enabled=true
spring.http.multipart.maxFileSize=-1
spring.http.multipart.maxRequestSize=-1
spring.jpa.database-platform=org.hibernate.dialect.DB2Dialect
spring.jpa.hibernate.ddl-auto=none
spring.jpa.show-sql=false
spring.mvc.async.request-timeout=999999
spring.output.ansi.enabled=DETECT
spring.profiles.active=prod
spring.servlet.multipart.max-file-size=-1
spring.servlet.multipart.max-request-size=-1
yx.nps.ip=**IP**
yx.nps.username=**password**
yx.project.description=Service for handling all oiltank related stuff.

Why does Test Connection fail in Wildfly 20 Using SQL Anywhere sajdbc4 driver?

I had Wildfly 10 running previously and have just upgraded to Wildfly 20 (under Ubuntu 20). My configuration from Wildfly 10 no longer works when it comes to getting the Sybase SQL Anywhere 17 sajdbc4 driver working. When I "Test Connection" it fails. I am using the same configuration and testing against the exact same (SQL Anywhere High Availability) database server.
"Test Connection" on the following Datasource triggers an "Invalid ODBC handle" error:
<datasource jndi-name="java:jboss/datasources/TestDB" pool-name="TestDB" spy="true" tracking="true" enlistment-trace="true">
<connection-url>jdbc:sqlanywhere:Host=192.168.1.45:19000,192.168.1.45:19001;ServerName=TestDB</connection-url>
<driver>sajdbc4.jar</driver>
<security>
<user-name>...</user-name>
<password>...</password>
</security>
</datasource>
Connection is not valid
Caused by: java.sql.SQLException: Invalid ODBC handle
at deployment.sajdbc4.jar//sap.jdbc4.sqlanywhere.IDriver.makeODBCConnection(Native Method)
at deployment.sajdbc4.jar//sap.jdbc4.sqlanywhere.IDriver.connect(IDriver.java:809)
at org.jboss.ironjacamar.jdbcadapters#1.4.22.Final//org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createLocalManagedConnection(LocalManagedConnectionFactory.java:321)
... 35 more
How I set this up:
I used the console to Deploy the sajdbc4.jar and that appears to work fine. I see no errors and sajdbc4 shows up as Deployed in the console and it also shows up as a JDBC Driver in the Subsystems. Here is what was created in standalone.xml after using the console:
deployment name="sajdbc4.jar" runtime-name="sajdbc4.jar">
content sha1="b690ff7a8ba1a3c2e8dd5079138b7970d969c2b9"/>
/deployment>
(I had to drop the leading angle brackets to get the previous lines to show - even when marked as Code!)
Next I had to ensure that the java.library.path and classpath included the path to the sajdbc4.jar and its support files so Wildfly can find them. To do so I added the "HACK" to the following in standalone.conf:
if [ "x$JAVA_OPTS" = "x" ]; then
JAVA_OPTS="-Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true"
JAVA_OPTS="$JAVA_OPTS -Djboss.modules.system.pkgs=$JBOSS_MODULES_SYSTEM_PKGS -Djava.awt.headless=true"
# ADDED FOLLOWING HACK
JAVA_OPTS="$JAVA_OPTS -Djava.library.path=/opt/wildfly-20.0.1.Final/modules/system/layers/base/com/sybase/main -cp .:/opt/wildfly-20.0.1.Final/modules/system/layers/base/com/sybase/main/sajdbc4.jar"
echo "Java Properties Next:"
java -XshowSettings:properties -version
else
echo "JAVA_OPTS already set in environment; overriding default settings with values: $JAVA_OPTS"
fi
Finally, I added the datasource block shown at the top. After starting Wildfly TestDB shows up as a Datasource in the Datasources Subsystem but when I Test Connection I get the "Invalid ODBC handle" error.
I feel confident that the driver and all its support files are "working" because I have a very simple Java test app that just makes a connection to TestDB, fetches from a table and displays the rows. Note that it uses the exact same java.library.path and classpath as I set in standalone.conf:
cd $HOME/Desktop
export LD_LIBRARY_PATH=/opt/wildfly-20.0.1.Final/modules/system/layers/base/com/sybase/main
export CLASSPATH=.:/opt/wildfly-20.0.1.Final/modules/system/layers/base/com/sybase/main/sajdbc4.jar
java sajdbc4DriverTest.java
Note that server.log shows no errors and in fact shows lines like:
[org.jboss.as.server.deployment] (MSC service thread 1-3) WFLYSRV0027: Starting deployment of "sajdbc4.jar" (runtime-name: "sajdbc4.jar")
...
[org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-4) WFLYJCA0005: Deploying non-JDBC-compliant driver class sap.jdbc4.sqlanywhere.IDriver (version 4.0)
[org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-3) WFLYJCA0018: Started Driver service with driver-name = sajdbc4.jar
[org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-3) WFLYJCA0001: Bound data source [java:jboss/datasources/TestDB]
...
[org.jboss.as.server] (Controller Boot Thread) WFLYSRV0010: Deployed "sajdbc4.jar" (runtime-name : "sajdbc4.jar")
Note that my connection string is for connecting to a SQL Anywhere High Availability system (hence the two URLS). In Wildfly 20 I see that there is now a new "HA URL Separator" field in the console's Datasource definition page. I tried setting that to a comma and that just changed the Test Connection error to "Unable to create connection from URL":
2020-08-25 11:45:08,378 WARN [org.jboss.jca.core.connectionmanager.pool.strategy.OnePool] (External Management Request Threads -- 1) IJ000604: Throwable while attempting to get a new connection: null: javax.resource.ResourceException: IJ031085: Unable to create connection from URL: jdbc:sqlanywhere:Host=192.168.1.45:19000,192.168.1.45:19001;ServerName=TestDB
at org.jboss.ironjacamar.jdbcadapters#1.4.22.Final//org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.getHALocalManagedConnection(LocalManagedConnectionFactory.java:381)
How do I get "Test Connection" to work?
Thank you in advance.
The problem turned out to be related to the fact that I was running Wildfly as a service and apparently my efforts above to set the java.library.path is failing. I know the reason for the error but I do not know how to set the path when running as a service.

Jooq and Spring boot: Upgraded JOOQ via starter: failed to bind spring.jooq.sql-dialect' to org.jooq.SQLDialect

So i upgraded spring-boot-parent-starter to 2.2.8.RELEASE, which results in jooq 3.12.4 . Previously i had 3.11.5.
I am getting the following error
Failed to bind properties under 'spring.jooq.sql-dialect' to org.jooq.SQLDialect:
Property: spring.jooq.sqldialect
Value: MYSQL_5_7
Origin: "spring.jooq.SQLDialect" from property source "applicationConfig: [classpath:/config/application.yaml]"
Reason: failed to convert java.lang.String to org.jooq.SQLDialect
Here is what my application.yaml was before
spring:
jooq:
sql-dialect: mysql_5_7
If you read the whole error message you will see this:
Failed to bind properties under 'spring.jooq.sql-dialect' to org.jooq.SQLDialect:
Property: spring.jooq.sql-dialect
Value: MYSQL_5_7
Origin: class path resource [application.properties]:2:25
Reason: failed to convert java.lang.String to org.jooq.SQLDialect
Action:
Update your application's configuration. The following values are valid:
CUBRID
DEFAULT
DERBY
FIREBIRD
H2
HSQLDB
MARIADB
MYSQL
POSTGRES
SQL99
SQLITE
MYSQL_5_7 is not a value supported by jOOQ open source. It's only availble in the pro version
MYSQL_5_7
#Pro
public static final SQLDialect MYSQL_5_7
The MySQL 5.7 dialect.
This dialect is available in commercial jOOQ distributions, only.

Not able to deploy keyclock quickstart example war in wildfly

I can't reproduce the tutorial to deploy this application on wildfly.
I downloaded the wildfly and started wildfly-19.1.0.Final/bin/standalone.sh
And when I execute from project directory mvn clean wildfly:deploy I get this error
15:12:55,016 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC000001: Failed to start service jboss.module.service."deployment.app-authz-jee-vanilla.war".main: org.jboss.msc.service.StartException in service jboss.module.service."deployment.app-authz-jee-vanilla.war".main: WFLYSRV0179: Failed to load module: deployment.app-authz-jee-vanilla.war
at org.jboss.as.server#11.1.1.Final//org.jboss.as.server.moduleservice.ModuleLoadService.start(ModuleLoadService.java:116)
at org.jboss.msc#1.4.11.Final//org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1739)
at org.jboss.msc#1.4.11.Final//org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1701)
at org.jboss.msc#1.4.11.Final//org.jboss.msc.service.ServiceControllerImpl$ControllerTask.run(ServiceControllerImpl.java:1559)
at org.jboss.threads#2.3.3.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads#2.3.3.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1982)
at org.jboss.threads#2.3.3.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
at org.jboss.threads#2.3.3.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: org.jboss.modules.ModuleNotFoundException: org.keycloak.keycloak-authz-client
at org.jboss.modules.Module.addPaths(Module.java:1266)
at org.jboss.modules.Module.link(Module.java:1622)
at org.jboss.modules.Module.relinkIfNecessary(Module.java:1650)
at org.jboss.modules.ModuleLoader.loadModule(ModuleLoader.java:299)
at org.jboss.modules.ModuleLoader.loadModule(ModuleLoader.java:283)
at org.jboss.as.server#11.1.1.Final//org.jboss.as.server.moduleservice.ModuleLoadService.start(ModuleLoadService.java:93)
... 8 more
15:12:55,021 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 1) WFLYCTL0013: Operation ("add") failed - address: ([("deployment" => "app-authz-jee-vanilla.war")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.module.service.\"deployment.app-authz-jee-vanilla.war\".main" => "WFLYSRV0179: Failed to load module: deployment.app-authz-jee-vanilla.war
Caused by: org.jboss.modules.ModuleNotFoundException: org.keycloak.keycloak-authz-client"}}
15:12:55,022 ERROR [org.jboss.as.server] (management-handler-thread - 1) WFLYSRV0021: Deploy of deployment "app-authz-jee-vanilla.war" was rolled back with the following failure message:
{"WFLYCTL0080: Failed services" => {"jboss.module.service.\"deployment.app-authz-jee-vanilla.war\".main" => "WFLYSRV0179: Failed to load module: deployment.app-authz-jee-vanilla.war
Caused by: org.jboss.modules.ModuleNotFoundException: org.keycloak.keycloak-authz-client"}}
15:12:55,034 INFO [org.jboss.as.server.deployment] (MSC service thread 1-3) WFLYSRV0028: Stopped deployment app-authz-jee-vanilla.war (runtime-name: app-authz-jee-vanilla.war) in 11ms
I tried running on docker wildfly and other example applications and worked. I don't have any experience in java. What can I do to have this app up and running?
With the command wildfly-19.1.0.Final/bin/standalone.sh, you are running keycloak on Wildfly.
Please use a different Wildfly server to host your servlet application. To communicate with the Keycloak running on the other server, you need "Keycloak OpenID Connect Client Adapter" installed into your Wildfly server which runs the servlet application.
You may use this guide to install the keycloak adapter into the wildly server. After you install this adapter into the new Wildfly, org.keycloak.keycloak-authz-client module will be available on this Wildfly.
However still there is a blocker for the latest java version [above java 11].
In my case, the WildFly not started 100% successfully. In the 'standalone.xml' file's end, there are some ports which maybe not available to you. Check for the logs, disable/move conflicting ports.

Error starting jHipster Microservices with consul

I'm trying to build sample microservice app using this tutorial.
Jhipster version is 4.0.6
So i've created gateway, service and started consul using this command:
docker-compose -f src/main/docker/consul.yml up
from my gateway directory.
But the error occur on Spring Boot startup, here is the log:
2017-02-22 11:52:25.679 ERROR 3168 --- [ restartedMain] o.s.c.c.c.ConsulPropertySourceLocator : Fail fast is set and there was an error reading configuration from consul.
2017-02-22 11:52:32.491 WARN 3168 --- [ restartedMain] o.s.boot.SpringApplication : Error handling failed (ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#2a5b2096: startup date [Thu Jan 01 03:00:00 AST 1970]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext#5108df79)
com.ecwid.consul.transport.TransportException: java.net.ConnectException: Connection refused: connect
Could you please assist with this issue?
UPDATE:
I've found that app tries to make GET request to URL on staptup:
http://localhost:8500/v1/kv/config/armory,dev/?recurse&token=
But the only data stored in Consul K/V storage is:
KEY: config/application/data
VALUE:
configserver:
name: Docker Consul Service
status: Connected to Consul Server running in Docker
jhipster:
security:
authentication:
jwt:
secret: my-secret-token-to-change-in-production
You must copy your application yaml configurations into your consul instance as explained in the doc into central-server-config directory if consul is running in dev profile or in its git repo if consul is running in prod profile.
So assuming your app is named "armory" you should copy your src/main/resources/config/application.yml to armory.yml and for each profiles (e.g. application-dev.yml to armory-dev.yml)

Resources