Quarkus H2 gives me SQLGrammarException - h2

I just updated my Quarkus to version 2.13. Final and now a test which uses H2 gives me a strange error:
Syntax error in SQL statement ......between ? and ? limit ? [42000-214]
2022-10-06 08:58:40,484 ERROR javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not prepare statement
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:154)
at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1626)
at org.hibernate.query.Query.getResultList(Query.java:165)
This my dependency:
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-orm</artifactId>
</dependency>
I thought this property could solve the problem in my case as well, but did not work:
hibernate.dialect=org.hibernate.dialect.H2Dialect
reference: Hibernate setMaxResults() with H2 SqlGrammarException

A more appropriate solution the worked for me , is moving to the latest version of H2 this day and add to jdbc url the peroperty
;NON_KEYWORDS=limit

Related

After upgrading Spring Boot version to 2.7 Flowable engine not able create table

I have updated spring-boot-starter-parent dependency version to 2.7.1 and flowable-engine to 6.8.0
then after when I am running JUnit test cases then I am getting below error
> nested exception is org.flowable.common.engine.api.FlowableException: couldn’t create db schema: create table ACT_HI_TSK_LOG (column names .....)
..
..
..
Caused by: org.h2.jdbc.JdbcSqlNonTransmissionException: Unknown data type: "IDENTITY"; SQL Statement: create table ACT_HI_TSK_LOG (ID_ identity, TYPE_ varchar(64), TASK_ID_ varchar(64) not null, .....)
Getting same error for creating ACT_EVT_LOG table
I don't have defined or written this tables and I think this is coming from the flowable-engine dependency.
Dependencies which I have used :
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-engine</artifactId>
<version>6.8.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.1</version>
<type>pom</type>
</dependency>
Can someone help me on this please.
If I am using Spring 2.6.x version then it's working fine and all JUnit test cases are getting passed
GETTING BELOW ERROR AFTER UPGRADING THE SPRING-BOOT-STARTER-PARENT v2.7.7
H2 is on v1.4.200 And flowable-engine v6.8.0
Error creating bean with name 'processEngine': FactoryBean threw the exception on object creation; nested exception is java.lang.RuntimeException: Exception while initializing Database connection at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:660) .........
................
ommitted caused by: java.lang.RuntimeException: Exception while initializing Database connection at
...................
......................
org.flowable.spring/SpringProcessEngineConfiguration.buildProcessEngine(SpringProcessEngineConfiguration.java:76) at org.flowable.spring.ProcessEngineFactoryBean.getObject(ProcessEngineFactoryBean.java:59) at
org.flowable.spring.ProcessEngineFactoryBean.getObject(ProcessEngineFactoryBean.java:32) at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:169) ... 65 common frames omitted Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The drive could not establish a secure connection to SQL Server by using Secure Socket Layer (SSL) exception. Error: "PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target". ClientConnectionId:a31221-r15-erer-gdf45451 at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:3680) at
com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:2047) at
com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:3204) at
com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:2833) at
com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:2671) at

Are spring-boot-starter-data-jpa and Liquibase incompatible?

I tried to setup a new Spring Boot 2.4.3 project and I want to include Liquibase as well as Spring Data JPA.
To achieve this I use the following dependencies in my POM:
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>${liquibase.version}</version>
</dependency>
or...
<dependency>
<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-hibernate5</artifactId>
<version>${liquibase.version}</version>
</dependency>
...respectively and
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
with
<kotlin.version>1.4.31</kotlin.version>
<liquibase.version>4.3.1</liquibase.version>
<hibernate.version>5.4.29.Final</hibernate.version>
Yet, in the beginning, I don't have any DB setup so far and in application.yaml you can find:
server:
port: 8080
spring:
liquibase:
change-log: classpath:db/changelog/db.changelog.yml
wherbey db.changelog.yml is empty.
A Maven install using the spring-boot-starter-data-jpa dependency results in:
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquibase' defined in class path resource [org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration$LiquibaseConfiguration.class]: Invocation of init method failed; nested exception is
liquibase.exception.ChangeLogParseException: Empty file classpath:db/changelog/db.changelog.yml
Caused by: liquibase.exception.ChangeLogParseException: Empty file classpath:db/changelog/db.changelog.yml
while when commenting out this dependency the build succeeds.
I found out that the empty db.changelog.yml file must contain at least:
databaseChangeLog:
- changeset:
although on https://docs.liquibase.com/concepts/basic/changelog.html an example is given that an empty changelog.yaml file needs to look like:
databaseChangeLog:
, but this results in a BeanCreationException:
Caused by: liquibase.exception.ChangeLogParseException: Could not find databaseChangeLog node

Spring Boot application breaks after upgrade to Apache Derby 10.15 -- why?

During a round of SOUP upgrades in a Spring Boot application, I bumped Apache Derby from 10.14.1.0 to 10.15.1.3. Now the tests fail with this beauty (snipped, full stacktrace here):
Failed to load ApplicationContext
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration':
Unsatisfied dependency expressed through constructor parameter 0
Caused by: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'dataSource':
Invocation of init method failed
Caused by: java.lang.IllegalStateException:
Failed to replace DataSource with an embedded database for tests.
If you want an embedded database please put a supported one on the
classpath or tune the replace attribute of #AutoConfigureTestDatabase.
What is going here? Do I need to change any configuration?
Apache Derby requires Java 9 from 10.15.x on which Spring Boot does currently not support.
See also spring-boot#16433.
I just want to answer with what it took me to get Derby 15.2.0 to work with Spring Boot 2.4.4 with derby in embedded mode, on top of Java 11. Spring Boot 2.4.4 works out of the box with Derby 14, although you will get some warning as spring boot starts. Upgrading apache derby to 15.2.0 fixed that for me.
In pom, both derby and derbytools dependencies defined:
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.15.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbytools</artifactId>
<version>10.15.2.0</version>
</dependency>
Then in your apps properties file:
spring.datasource.driver-class-name=org.apache.derby.iapi.jdbc.AutoloadedDriver
Instead of:
spring.datasource.driver-class-name=org.apache.derby.jdbc.EmbeddedDriver
After that, I now get a good startup of Spring Boot with no warnings or anything that raises concerns.

Configuring embedded Derby in Spring Boot app

Could you please help me set up connection to the embedded Derby database in Spring Boot application?
I searched the web but can only find solutions for server-type Derby, not for embedded Derby.
spring.jpa.database = ?
spring.jpa.hibernate.ddl-auto = create-drop
Derby as an in-memory database
If you want to Configure in-memory Derby database with spring boot, the minimal thing you need is to mention the runtime dependency (along with spring-boot-starter-data-jpa) as
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<scope>runtime</scope>
</dependency>
This bare minimum configuration should work for any embedded datasource in Spring Boot. But as of current Spring Boot version (2.0.4.RELEASE) this lead to an error only for Derby
org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing
DDL via JDBC Statement
Caused by: java.sql.SQLSyntaxErrorException: Schema 'SA' does not exist
This happens because of default configuration ofspring.jpa.hibernate.ddl-auto=create-drop see this spring-boot issue for details.
So you need to override that property in your application.properties as
spring.jpa.hibernate.ddl-auto=update
Derby as a persistent database
If you want to use Derby as your persistent database. Add these application properties
spring.datasource.url=jdbc:derby:mydb;create=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.DerbyTenSevenDialect
spring.jpa.hibernate.ddl-auto=update
You don't need connection properties if you are using Spring Boot. Just add these to your POM:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
</dependency>
Then add the usual controller, service, and repository classes.

Cannot load JDBC Driver class in Birt 4.6.0-20160607

i am having a Java EE project in which i include the Birt runtime as a maven dependency:
<dependency>
<groupId>org.eclipse.birt.runtime</groupId>
<artifactId>org.eclipse.birt.runtime</artifactId>
<version>4.6.0-20160607</version>
<exclusions>
<exclusion>
<groupId>org.eclipse.birt.runtime</groupId>
<artifactId>org.apache.xerces</artifactId>
</exclusion>
<exclusion>
<artifactId>org.apache.poi</artifactId>
<groupId>org.eclipse.birt.runtime</groupId>
</exclusion>
</exclusions>
</dependency>
The engine seems to be created (i hope at least) . In my report i have defined the datasource settings.
<data-sources>
<oda-data-source extensionID="org.eclipse.birt.report.data.oda.jdbc" name="somename" id="43">
<list-property name="privateDriverProperties">
<ex-property>
<name>contentBidiFormatStr</name>
<value>ILYNN</value>
</ex-property>
<ex-property>
<name>metadataBidiFormatStr</name>
<value>ILYNN</value>
</ex-property>
</list-property>
<property name="odaDriverClass">oracle.jdbc.driver.OracleDriver</property>
<property name="odaURL">jdbc:oracle:thin:#host...</property>
<property name="odaUser">username</property>
<encrypted-property name="odaPassword" encryptionID="base64">password</encrypted-property>
</oda-data-source>
</data-sources>
Unfortunately it seems that Birt cannot find the ojdbc driver (Note, we use an oracle database) and we get the following error:
SEVERE [org.eclipse.birt.data.engine.odaconsumer] (default task-20)
Unable to open connection.:
org.eclipse.birt.report.data.oda.jdbc.JDBCException: Cannot load JDBC
Driver class: oracle.jdbc.driver.OracleDriver.
I have included in my Web module under WEB-INF/lib the following jar org.eclipse.birt.report.data.oda.jdbc_4.6.0.v201606072122.jar but i am still getting the same error.
Is there any way to solve this by adding the ojdbc as a maven dependency or is there any other workaround ?
Update: I have tried to also to add the also the org.eclipse.birt.report.data.oda.jdbc_4.6.0.v201606072122.jar as a maven dependency.
<!-- Oracle JDBC driver -->
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.4.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>ojdbc</artifactId>
<scope>system</scope>
<version>1.0</version>
<systemPath>${basedir}\src\main\resources\lib\org.eclipse.birt.report.data.oda.jdbc_4.6.0.v201606072122.jar</systemPath>
</dependency>
I am getting the same error. Bellow some part of the stacktrace:
2017-01-05 13:07:11,990 SEVERE
[org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager] (default
task-45) DriverClassLoader failed to load class:
oracle.jdbc.driver.OracleDriver: java.lang.ClassNotFoundException:
oracle.jdbc.driver.OracleDriver
at org.eclipse.birt.core.framework.URLClassLoader.findClass1(URLClassLoader.java:188)
......
......
2017-01-05 13:07:12,020 SEVERE
[org.eclipse.birt.data.engine.odaconsumer] (default task-45) Unable to
open connection.: org.eclipse.birt.report.data.oda.jdbc.JDBCException:
Cannot load JDBC Driver class: oracle.jdbc.driver.OracleDriver.
at org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager.findDriver(JDBCDriverManager.java:881)
Update 2: I made further changes but still without success. I added the org.eclipse.birt.report.data.oda.jdbc_4.6.0.v201606072122.jar library in all my modules under WEB-INF and MEtA-INF
\src\main\webapp\WEB-INF\lib\org.eclipse.birt.report.data.oda.jdbc_4.6.0.v201606072122.jar
The results are quite the same:
2017-01-05 15:40:49,927 SEVERE
[org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager] (default
task-19) DriverClassLoader failed to load class:
org.eclipse.birt.report.data.oda.jdbc:
java.lang.ClassNotFoundException:
org.eclipse.birt.report.data.oda.jdbc
I would also like to note here something. For our persistence in the application, we use a datasource on our wildfly in which we use the ojdbc driver as a module in Wildfly 10 .
I am slowly running out of ideas with Birt + ojdbc
Finally solved the problem. I had to install the oda jdbc driver in my local manen repository and add it as a dependency in my ejb module.
<dependency>
<groupId>org.eclipse.birt.ojdbc</groupId>
<artifactId>odajdbc</artifactId>
<version>4.6.0-201606072122</version>
</dependency>
Furthermore, for some reason which i cannot yet explain, Birt required also the ojdbc6 driver in my web module. I honestly cannot understand why, since the entire birt implementation and runtime is in the ejb module.
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.4.0</version>
</dependency>
That solved the problem and now the reports are getting generated.
I am now facing two new problems which i have to solve.
1) java.lang.OutOfMemoryError: Java heap space : I found in Eclipse bugzilla that this problem can be solved with the ojdbc7 driver. The reports are not generated unless i push my servers -Xmx above 1400mb
2) [org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager] (default task-20) DriverClassLoader failed to load class: oracle.jdbc.driver.OracleDriver: java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver: For some reason i get this error only one time when i want to generate a report. The report is generated without problems and the exception never appears again.
At least the reports are working now and can continue solving the other issues.

Resources