Spring Boot Actuator Liquibase endpoint fail - spring-boot

I'm trying to use Liquibase with Spring Boot.
Here is my application.properties file:
# ----------------------------------------
# DATA PROPERTIES
# ----------------------------------------
spring.datasource.url=jdbc:postgresql://xxxxxx:5432/dev
spring.datasource.schema=my_schema
spring.datasource.username=my_username
spring.datasource.password=my_password
# LIQUIBASE (LiquibaseProperties)
liquibase.default-schema=${spring.datasource.schema}
liquibase.user=${spring.datasource.username}
liquibase.password=${spring.datasource.password}
Change sets are well applied (table creation is ok).
The problem comes when I access /liquibase actuator's endpoint, I get a 500 error:
Unable to get Liquibase changelog
I also get the following log:
org.postgresql.util.PSQLException: ERROR: relation "public.databasechangelog" does not exist
If thing the problem is the schema prefix used to access changelog table: "public" versus "my_schema".
I thought spring.datasource.schema was the right parameter to set ?

Here is a working solution (come from this answer):
# ----------------------------------------
# DATA PROPERTIES
# ----------------------------------------
spring.datasource.url=jdbc:postgresql://xxxxxx:5432/dev?currentSchema=my_schema

Just a guess here - I think that the issue is that your 'real' schema is being set by the spring.datasource.schema but the liquibase tables are being stored in public and it may be that the Spring Boot actuator doesn't know that those can be separate.

Related

Spring Boot App using MYSQL not starting - url attribute is not specified

I was following some tutorials and docs on how to connect Spring Boot apps with MySQL database but it gives me a start up error all the time even tho I have the url specified in the app.properties file.
spring.datasource.url=jdbc:mysql://localhost:3306/cryptodb01
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
## Hibernate Properties
# The SQL dialect makes Hibernate generate better SQL for the chosen database
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect
spring.jackson.serialization.indent-output=true
I am getting this error everytime I try to run the app:
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
My dependencies are these

Liquibase in a Spring Application doesn't fail on unknown change type

We’ve recently ran into an issue where we had a typo in a Liquibase change type and nothing caught this issue. We used the addNonNullConstraint change type, which does not exist, instead of addNotNullConstraint.
The issue here is that we're using YAML format for the changeset file, which doesn't have any validation. With the XML format, we would at least get an error in the editor.
Executing the Liquibase CLI validate command finds the faulty change set:
➜ git: ✗ liquibase validate
Starting Liquibase at 13:46:47 (version 4.17.0 #4922 built at 2022-10-05 14:56+0000)
Liquibase Version: 4.17.0
Liquibase Community 4.17.0 by Liquibase
Unexpected error running Liquibase: Error parsing db/changelog.yaml
- Caused by: Error parsing /db/changes/0019_mark-column-non-null.yaml
- Caused by: Error parsing /db/changes/0019_mark-column-non-null.yaml: Unknown change type 'addNonNullConstraint'. Check for spelling or capitalization errors and missing extensions such as liquibase-commercial.
For more information, please use the --log-level flag
But when starting up the Spring Boot app, there’s no hint that something went wrong with one of the new changesets that need to be applied:
INFO Liquibase.database : Set default schema name to public
INFO liquibase.lockservice : Successfully acquired change log lock
INFO liquibase.changelog : Reading from public.databasechangelog
Running Changeset: /db/changes/0019_mark-column-non-null.yaml::Mark column as non-null::Dev
INFO liquibase.changelog : ChangeSet /db/changes/0019_mark-column-non-null.yaml::Mark column as non-null::Dev ran successfully in 0ms
Ideally, the Spring Boot app would validate the change sets before applying them, and fail if the change type is unknown. But I could not find out how to run the Liquibase validate command in the context of the Spring integration.

Why doesn't h2-console default db name match the db name defined in application.properties file?

I am new to spring boot and taking a beginner course on udemy developing a project.
Below is my application.properties file -
application.properties
#logging
logging.level.com.vega.springit=DEBUG
info.application.name=Springit
info.application.description=Reddit clone using spring boot 2
info.application.version=0.0.1
management.endpoints.web.exposure.include=*
management.endpoint.health.show-details=always
#h2
spring.h2.console.enabled=true
#datasource (default to testdb)
spring.datasource.name=springit
The default database on the h2-console is still testdb
And this is what I see on the console -
2020-11-29 01:19:29.315 INFO 28396 --- [ restartedMain] o.s.b.a.h2.H2ConsoleAutoConfiguration : H2 console available at '/h2-console'. Database available at 'jdbc:h2:mem:358023a0-911e-4064-b2ec-e7046556c517'
My questions are -
Why doesn't h2-console display the database name that is set in the app.properties file?
Why does the console say database available at 'jdbc:hs:mem:xxx'?
When I try to connect to testdb or springit (as set in the file), I get following error -
Database "C:/Users/zankh/test" not found, either pre-create it or allow remote database creation (not recommended in secure environments) [90149-200] 90149/90149 (Help)
Also tried, connecting to 'jdbc:h2:mem:springit', but still get the same error.
I can connect to 'jdbc:hs:mem:xxx' but that's not how it works for the instructor in the course. What am I doing wrong here?
TIA
I fixed the problem by adding spring.datasource.url to the app.properties file
application.properties
#logging
logging.level.com.vega.springit=DEBUG
info.application.name=Springit
info.application.description=Reddit clone using spring boot 2
info.application.version=0.0.1
management.endpoints.web.exposure.include=*
management.endpoint.health.show-details=always
#h2
spring.h2.console.enabled=true
#datasource (default to testdb)
spring.datasource.name=springit
spring.datasource.url=jdbc:h2:mem:springit

Migration From Quarkus 1.3.2.FInal to 1.4.2.Final affected Vault Access

In my old setup for Quarkus 1.3.2.Final
I have this in my property file
quarkus.vault.url=${vault_path}
quarkus.vault.tls.use-kubernetes-ca-cert=true
quarkus.vault.authentication.kubernetes.role=${someVaultRole}
quarkus.vault.tls.ca-cert=${someTlsCertLocation}
quarkus.vault.kv-secret-engine-mount-path=${someSecretEngingPath}
when i tried to access the secrets using VaultKVSecretEngine.readSecret(path), it gives me the secrets for that path
But when I try to migrate to Quarkus 1.4.2.Final, I got this error
"io.quarkus.vault.runtime.client.VaultClientException code=403 body={\"errors\":[\"1 error occurred:\\n\\t* permission denied\\n\\n\"]}\
when i tried to call VaultKVSecretEngine.readSecret(path) with my old setup.
Question is, what are the configs in my application.properties that i missed for quarkus 1.4.2.final vault access?
since by default, quarkus 1.4.2.Final uses kv-secret-engine-version 2, it is needed to specify the kv-secret-engine-version to version 1 when migrating from quarkus 1.3.2.Final to 1.4.2.Final since 1.3.2.Final uses kv-secret-engine-version 1

Hibernate seems not to resolve alias correctly

since some days I'm facing the following problem:
I am using Hibernate to do the following Restriction on a criteria:
...
criteria.add(Restrictions.sqlRestriction("1=1 CONNECT BY PRIOR {ProcessEntityworkflowProject}.ID = {ProcessEntityworkflowProject}.PARENT_ID"))
Where "ProcessEntityworkflowProject" is the alias which should be resolved by hibernate.
This alias is set in code properly. I also debugged the code and inspected criteria:
There I could see that a subcriteria in subcriterialist of criteria has this correct alias bound to the association path.
But in SQL logs I see that it is not resolved:
... and this_.EXTERNAL_KEY is not null and 1=1 CONNECT BY PRIOR {ProcessEntityworkflowProject}.ID = {ProcessEntityworkflowProject}.PARENT_ID and processent4_.TYPE_ID=? ...
... or is this output correct and it is resolved later internally?
And in tomcat.log I see that there is a NPE:
java.lang.NullPointerException
at oracle.jdbc.driver.T4C8Oall.getNumRows(T4C8Oall.java:876)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:831)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1039)
at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:850)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1134)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3339)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3384)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:92)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
at org.hibernate.loader.Loader.doQuery(Loader.java:662)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2145)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1533)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:295)
I already found out that this NPE is cause because Oracle JDBC driver can not parse the brackets "{" "}". So I guess that the alias was not resolved properly.
Does anyone of you have an idea what could be wrong or how I could investigate deeper?
Some additional info:
I am using Hibernate 3.2.0 (CR1 afaik), tomcat 5.5, ojdbc14.jar.
Running on RHEL 6.4 and Oracle 11g
Many thx in advance if some of you have an idea ;)
Cheers
Sascha

Resources