Getting exception "Not using JDBC" while using quarkus-hibernate-reactive-panache with quarkus-reactive-mysql-client - (Quarkus 1.12.2.Final) - quarkus

Quarkus 1.12.2.Final
Getting the following exception while using reactive hibernate (quarkus-hibernate-reactive-panache) with reactive MySQL client (quarkus-reactive-mysql-client), kindly suggests what could be the issue.
2021-04-01 11:35:28,694 ERROR [org.hib.eng.jdb.spi.SqlExceptionHelper] (Quarkus Main Thread) Not using JDBC
2021-04-01 11:35:28,727 ERROR [io.qua.run.Application] (Quarkus Main Thread) Failed to start application (with profile dev): java.sql.SQLException: Not using JDBC
at org.hibernate.reactive.provider.service.NoJdbcConnectionProvider.getConnection(NoJdbcConnectionProvider.java:25)
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:180)
Some details
My application.properties
quarkus.datasource.jdbc=false
quarkus.datasource.db-kind=mysql
quarkus.datasource.username=root
quarkus.datasource.password=root
quarkus.datasource.reactive.url=mysql://localhost:3306/mydb
quarkus.datasource.reactive.max-size=20
My Repository Implementation
#ApplicationScoped public class EventRepository implements PanacheRepository<Event> {
}

Change your application.properties to
quarkus.datasource.db-kind=mysql
quarkus.datasource.username=root
quarkus.datasource.password=root
quarkus.datasource.reactive.url=vertx-reactive:mysql://localhost:3306/mydb
quarkus.datasource.reactive.max-size=20

Here is the cause of the problem -> I used property "quarkus.hibernate-orm.database.generation=update". It seems like the use of this property requires JDBC connection, removed it, and it's working fine.
Any of the below config sets can work.
quarkus.datasource.db-kind=mysql
quarkus.datasource.username=****
quarkus.datasource.password=****
quarkus.datasource.reactive.url=mysql://localhost:3306/db
or
quarkus.datasource.reactive.url=vertx-reactive:mysql://localhost:3306/db

"The latest version available of Hibernate Reactive doesn't support schema update and validation yet."
Relative issue here:
Not using JDBC problem met in native build · Issue #19918 · quarkusio/quarkus · GitHub

Can you try to add the following property to your settings?
quarkus.hibernate-orm.database.generation=update
You can write drop-and-create to re-create your db when you run your server as well. See details here.

Hmm. JDBC and Hibernate update should work in your case. Do you have a JDBC extension (dependency) in your project? If not, try to ad one.
In case of a postgres you can add extension this way:
./mvnw quarkus:add-extension -Dextensions="jdbc-postgresql
More info here
Add the agroal extension plus one of jdbc-db2, jdbc-derby, jdbc-h2, jdbc-mariadb, jdbc-mssql, jdbc-mysql, jdbc-oracle or jdbc-postgresql.
https://quarkus.io/guides/datasource

Add this dependency to your pom.xml file.
<!-- https://mvnrepository.com/artifact/io.quarkus/quarkus-jdbc-postgresql -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-postgresql</artifactId>
<version>2.9.2.Final</version>
</dependency>

Related

Weird behaviour with Quarkus + GraalVM + URLConnection

I am testing the Quarkus capabilities for Travel Applications and I found a weird behaviour when I try to establish an URLConnection running in a GraalVM application
based on Quarkus. If I run a Native application:
./target/getting-started-1.0.0-SNAPSHOT-runner
and I Call the REST endpoint:
curl 'http://localhost:8080/api/v1/covid-restrictions'
then I receive the following error:
2022-06-01 17:38:43,844 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (executor-thread-0) HTTP Request to /api/v1/covid-restrictions failed, error id: f6130b71-c9fb-4a67-a996-c58fba695117-1: com.amadeus.exceptions.NetworkException: [---]
But when I run the same application as a Jar, everything is fine.
java -jar target/quarkus-app/quarkus-run.jar
One example to see the error here:
https://github.com/jabrena/quarkus-amadeus-sdk-demo
Do I need to configure the Quarkus app in some way for GraalVM?
I share the whole StackTrace if it could help:
2022-06-01 17:38:43,844 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (executor-thread-0) HTTP Request to /api/v1/covid-restrictions failed, error id: f6130b71-c9fb-4a67-a996-c58fba695117-1: com.amadeus.exceptions.NetworkException: [---]
at com.amadeus.HTTPClient.fetch(HTTPClient.java:372)
at com.amadeus.HTTPClient.execute(HTTPClient.java:358)
at com.amadeus.HTTPClient.unauthenticatedRequest(HTTPClient.java:253)
at com.amadeus.client.AccessToken.fetchAccessToken(AccessToken.java:67)
at com.amadeus.client.AccessToken.updateAccessToken(AccessToken.java:53)
at com.amadeus.client.AccessToken.lazyUpdateAccessToken(AccessToken.java:47)
at com.amadeus.client.AccessToken.getBearerToken(AccessToken.java:39)
at com.amadeus.HTTPClient.request(HTTPClient.java:339)
at com.amadeus.HTTPClient.get(HTTPClient.java:67)
at com.amadeus.dutyOfCare.diseases.Covid19AreaReport.get(Covid19AreaReport.java:51)
at org.acme.CovidResource.hello(CovidResource.java:27)
at org.acme.CovidResource$quarkusrestinvoker$hello_a2fbfead069e804ef1bb0315d16c4dc5e7951978.invoke(Unknown Source)
at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:29)
at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:7)
at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:141)
at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:548)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:833)
at com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:704)
at com.oracle.svm.core.posix.thread.PosixPlatformThreads.pthreadStartRoutine(PosixPlatformThreads.java:202)
Many thanks in advance.
Juan Antonio
As most APIs nowadays are, the Amadeus library is HTTPS only.
For Quarkus in native mode, you need to explicitly enable SSL in src/main/resources/application.properties (except for certain extensions, see the link below).
quarkus.ssl.native=true
See https://quarkus.io/guides/native-and-ssl
After adding this property you will get a different runtime error:
2022-06-02 00:45:25,381 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (executor-thread-0) HTTP Request to /api/v1/covid-restrictions failed, error id: 6d821ce1-23fd-4d88-8f63-992b6453830a-1: com.oracle.svm.core.jdk.UnsupportedFeatureError: Code that was considered unreachable by closed-world analysis was reached.
Try to register the following reflection classes (DiseaseAreaReport and all inner classes) as Amadeus will use GSON and therefore also Java reflection to apply the JSON String data to the DiseaseAreaReport POJO.
https://quarkus.io/guides/writing-native-applications-tips#registering-for-reflection
package org.acme;
import io.quarkus.runtime.annotations.RegisterForReflection;
#RegisterForReflection(targets = {
com.amadeus.Amadeus.class,
com.amadeus.HTTPClient.class,
com.amadeus.Params.class,
com.amadeus.Response.class,
com.amadeus.client.AccessToken.class,
com.amadeus.dutyOfCare.diseases.Covid19AreaReport.class,
com.amadeus.exceptions.ResponseException.class,
// com.amadeus.resources.DiseaseAreaReport and all inner classes
com.amadeus.resources.DiseaseAreaReport.class,
com.amadeus.resources.DiseaseAreaReport.Area.class,
com.amadeus.resources.DiseaseAreaReport.AreaAccessRestriction.class,
com.amadeus.resources.DiseaseAreaReport.AreaPolicy.class,
com.amadeus.resources.DiseaseAreaReport.AreaRestriction.class,
com.amadeus.resources.DiseaseAreaReport.AreaVaccinated.class,
com.amadeus.resources.DiseaseAreaReport.Border.class,
com.amadeus.resources.DiseaseAreaReport.DatedInformation.class,
com.amadeus.resources.DiseaseAreaReport.DatedQuarantineRestriction.class,
com.amadeus.resources.DiseaseAreaReport.DatedTracingApplicationRestriction.class,
com.amadeus.resources.DiseaseAreaReport.DeclarationDocuments.class,
com.amadeus.resources.DiseaseAreaReport.DiseaseCase.class,
com.amadeus.resources.DiseaseAreaReport.DiseaseInfection.class,
com.amadeus.resources.DiseaseAreaReport.DiseaseTestingRestriction.class,
com.amadeus.resources.DiseaseAreaReport.DiseaseVaccination.class,
com.amadeus.resources.DiseaseAreaReport.EntryRestriction.class,
com.amadeus.resources.DiseaseAreaReport.ExitRestriction.class,
com.amadeus.resources.DiseaseAreaReport.GeoCode.class,
com.amadeus.resources.DiseaseAreaReport.Link.class,
com.amadeus.resources.DiseaseAreaReport.MaskRestriction.class,
com.amadeus.resources.DiseaseAreaReport.Sources.class,
com.amadeus.resources.DiseaseAreaReport.Transportation.class,
com.amadeus.resources.DiseaseAreaReport.ValidityPeriod.class,
com.amadeus.resources.Resource.class
})
public class AmadeusReflection {
}
I hope this fixes this issue, if not dig deeper which classes or inner classes are missing to be registered for reflection with a debugger or following the stack trace.
P.S. your test shows the following warnings:
[WARNING] [io.quarkus.resteasy.reactive.server.deployment.QuarkusServerEndpointIndexer] Quarkus detected the use of JSON in JAX-RS method 'org.acme.CovidResource#hello' but no JSON extension has been added. Consider adding 'quarkus-resteasy-reactive-jackson' or 'quarkus-resteasy-reactive-jsonb'.
[WARNING] [io.quarkus.resteasy.reactive.server.deployment.QuarkusServerEndpointIndexer] Quarkus detected the use of JSON in JAX-RS method 'org.acme.ConfigResource#hello' but no JSON extension has been added. Consider adding 'quarkus-resteasy-reactive-jackson' or 'quarkus-resteasy-reactive-jsonb'.
Consider to add the RESTEasy Reactive Jackson extension in the pom.xml:
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-reactive-jackson</artifactId>
</dependency>

java.Sql.SQLException, Cannot load class net.ucanaccess.jdbc.UcanaccessDriver

I tried to connect my MS Access Database in Mulesoft using Ucanaccess driver but it raises error Could not load class net.ucanaccess.jdbc.UcanaccessDriver. I have imported all the required JAR's and added the required dependencies in pom.xml also but still it gives same error. I have attached all nescessary details of the problem. Java version - 8, Ucanaccess driver version - 5.0.1 Any suggestion or guidance to proceed further would be helpful for me.
Error Stack Trace
org.mule.runtime.api.connection.ConnectionException: Could not obtain connection from data source
org.mule.runtime.api.connection.ConnectionException: Could not obtain connection from data source
Caused by: org.mule.extension.db.api.exception.connection.ConnectionCreationException: Could not obtain connection from data source
Caused by: java.sql.SQLException: Error trying to load driver: net.ucanaccess.jdbc.UcanaccessDriver : Cannot load class 'net.ucanaccess.jdbc.UcanaccessDriver': [
net.ucanaccess.jdbc.UcanaccessDriver,
Cannot load class 'net.ucanaccess.jdbc.UcanaccessDriver': [
Class 'net.ucanaccess.jdbc.UcanaccessDriver' has no package mapping for region 'domain/default/app/tooling-application-85e45b90-5bac-11eb-84c6-ccd9aca566c1'.,
Cannot load class 'net.ucanaccess.jdbc.UcanaccessDriver': [
Class 'net.ucanaccess.jdbc.UcanaccessDriver' has no package mapping for region '/domain/default'.
Database Config
Pom.xml Dependencies
External Jar
Looks like you need to add the JDBC driver libraries as shared libraries in the pom.xml.
See the documentation at https://docs.mulesoft.com/mule-runtime/4.3/mmp-concept#configure-shared-libraries on how to configure.
Example (you might need to add other libraries):
<sharedLibraries>
<sharedLibrary>
<groupId>net.sf.ucanaccess</groupId>
<artifactId>ucanaccess</artifactId>
</sharedLibrary>
</sharedLibraries>

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

org.apache.kylin.job.exception.ExecuteException: java.lang.NoClassDefFoundError: org/apache/hadoop/hive/serde2/typeinfo/TypeInfo

I find similar error on https://issues.apache.org/jira/browse/KYLIN-2511
env:
hadoop-2.7.1
hbase-1.3.2
apache-hive-2.1.1-bin
apache-kylin-1.6.0-hbase1.x-bin
I've tried copy all the hive libs to kylin, but get another ERROR.
org.apache.hadoop.mapred.YarnChild: Error running child : java.lang.NoClassDefFoundError: org/apache/hadoop/hive/serde2/typeinfo/TypeInfo
The missing class should be in hive-exec-.jar; Check and debug the "bin/find-hive-dependency.sh" to see why it wasn't able to locate this jar from your server. You can manually add it to the "hive_exec_path" variable.
BTW, Kylin 1.6 is quite old, try to upgrade to a 2.x version.
Why you just try the method mentioned in https://issues.apache.org/jira/browse/KYLIN-2511. You'd better prepare the env according to the document of v16. It is better for using the latest version of Kylin. It has more feature and fixes some bugs.

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