Spring Hibernate HSQLDB - unexpected end of statement

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Spring Hibernate HSQLDB - unexpected end of statement

wenjun
Hello

I am using version 2.2.1 and it is working great for MySQL and h2.  But I am having issues with HSQLDB.  

It is able to create table from hbm2ddl and load data from sample-data.xml,  but it keeps getting "unexpected end of statement" on userManager.reindexAll(false) (in StartupListener).  

Here is the hsqldb config

        <profile>
            <id>hsqldb</id>
            <properties>
                <dbunit.dataTypeFactoryName>org.dbunit.ext.hsqldb.HsqldbDataTypeFactory</dbunit.dataTypeFactoryName>
                <hibernate.dialect>org.hibernate.dialect.HSQLDialect</hibernate.dialect>
                <jdbc.groupId>org.hsqldb</jdbc.groupId>
                <jdbc.artifactId>hsqldb</jdbc.artifactId>
                <jdbc.version>2.2.9</jdbc.version>
                <jdbc.driverClassName>org.hsqldb.jdbcDriver</jdbc.driverClassName>
                <jdbc.url>jdbc:hsqldb:/tmp/${db.name};shutdown=true;</jdbc.url>
                <jdbc.username>sa</jdbc.username>
                <jdbc.password />
            </properties>
        </profile>


Stack trace:

        at org.springframework.orm.hibernate4.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:440)
        at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:371)
        at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:334)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:105)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
        at com.sun.proxy.$Proxy117.reindexAll(Unknown Source)
        at com.openfin.webapp.listener.StartupListener.doReindexing(StartupListener.java:106)
        at com.openfin.webapp.listener.StartupListener.setupContext(StartupListener.java:101)
        at com.openfin.webapp.listener.StartupListener.contextInitialized(StartupListener.java:83)


Thanks

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Spring Hibernate HSQLDB - unexpected end of statement

predicador37
Same problem here with version 3.5...

Did you get this fixed? It's a little weird that two years later the same error still persists..
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Spring Hibernate HSQLDB - unexpected end of statement

mraible
Administrator
Can you please provide the steps to reproduce this issue?

On Wed, Mar 18, 2015 at 2:53 PM predicador37 <[hidden email]> wrote:
Same problem here with version 3.5...

Did you get this fixed? It's a little weird that two years later the same
error still persists..



--
View this message in context: http://appfuse.547863.n4.nabble.com/Spring-Hibernate-HSQLDB-unexpected-end-of-statement-tp4656699p4657757.html
Sent from the AppFuse - User mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Spring Hibernate HSQLDB - unexpected end of statement

predicador37
Sure, Matt!

I've provided them in another post, but basically:

1. Get a basic appfuse struts2 project:

mvn archetype:generate -B -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-basic-spring-archetype -DarchetypeVersion=3.5.0 -DgroupId=com.mycompany -DartifactId=myproject -DarchetypeRepository=https://oss.sonatype.org/content/repositories/appfuse

BUILD SUCCESS with this.

2. Test HSQLDB:

mvn test -Phsqldb

And then, the error:

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 10.246 sec <<< FAILUR     E! - in com.mycompany.webapp.listener.StartupListenerTest
 212 testContextInitialized(com.mycompany.webapp.listener.StartupListenerTest)  Time elaps     ed: 9.991 sec  <<< ERROR!
 213 org.springframework.transaction.CannotCreateTransactionException: Could not open Hibe     rnate Session for transaction; nested exception is org.hibernate.exception.GenericJDB     CException: Could not open connection
...
Caused by: java.sql.SQLSyntaxErrorException: unexpected end of statement
 305     at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source) ~[hsqldb-2.3.2.jar:2.3.2     ]

Also, modifying HSQLDB validaton query by "SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS" results in the test not crashing but freezing at:

With this I manage to get the tests frozen at:

 DEBUG [main] UserDaoHibernate.saveUser(53) | user's id: null
221 Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 14.927 sec - in com.mycompany.webapp.controller.S    ignupControllerTest
222 Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 17.246 sec - in com.mycompany.webapp.controller.P    asswordHintControllerTest
223 WARN [main] UserFormController.showForm(191) | User 'user' is trying to edit user with id 'null'

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Spring Hibernate HSQLDB - unexpected end of statement

mraible
Administrator
Thanks for the detailed steps. If I try them, and run "mvn clean test -Phsqldb -X" (after adding <jdbc.validationQuery> in my pom.xml), I see the following error.

Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Database lock acquisition failure: lockFile: org.hsqldb.persist.LockFile@23670711[file =/private/tmp/myproject.lck, exists=true, locked=false, valid=false, ] method: checkHeartbeat read: 2015-03-18 23:15:50 heartbeat - read: -7055 ms.)

I thought this might be caused by running tests in parallels, so I tried modifying the plugin to only run one at a time.

            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <forkCount>0</forkCount>
                </configuration>
            </plugin>

Unfortunately, this doesn't seem to solve anything. It still hangs on the UserFormControllerTest.

Tests run: 8, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.887 sec - in com.mycompany.webapp.controller.UpdatePasswordControllerTest
Running com.mycompany.webapp.controller.UserControllerTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.208 sec - in com.mycompany.webapp.controller.UserControllerTest
Running com.mycompany.webapp.controller.UserFormControllerTest
WARN [main] UserFormController.showForm(191) | User 'user' is trying to edit user with id 'null'

I tried removing @Transactional from UserFormControllerTest and that gets me a bit further, but not quite there.

Results :

Failed tests:
  UserFormControllerTest.testEditProfile:142 Model attribute 'user'
Expected: hasProperty("fullName", is "Tomcat User")
     but: property 'fullName' was "Tomcat Updated Last Name"

I tried just adding @Transactional on the testSave() method, but that still causes the hang. So I added @Ignore to the method to ignore the test. This gets past all the tests, but then fails when trying to run dbunit again. 

Results :

Tests run: 28, Failures: 0, Errors: 0, Skipped: 1

[INFO]
[INFO] --- dbunit-maven-plugin:1.0-beta-3:operation (test) @ myproject ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 21.785 s
[INFO] Finished at: 2015-03-18T17:29:42-06:00
[INFO] Final Memory: 73M/954M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:dbunit-maven-plugin:1.0-beta-3:operation (test) on project myproject: Error executing database operation: CLEAN_INSERT: Database lock acquisition failure: lockFile: org.hsqldb.persist.LockFile@23670711[file =/private/tmp/myproject.lck, exists=true, locked=false, valid=false, ] method: checkHeartbeat read: 2015-03-18 23:29:41 heartbeat - read: -3318 ms. -> [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:

It doesn't seem like HSQLDB supports transactions or multiple threads very well. FWIW, I didn't have much better luck with H2.




On Wed, Mar 18, 2015 at 4:45 PM predicador37 <[hidden email]> wrote:
Sure, Matt!

I've provided them in another post, but basically:

1. Get a basic appfuse struts2 project:

mvn archetype:generate -B -DarchetypeGroupId=org.appfuse.archetypes
-DarchetypeArtifactId=appfuse-basic-spring-archetype
-DarchetypeVersion=3.5.0 -DgroupId=com.mycompany -DartifactId=myproject
-DarchetypeRepository=https://oss.sonatype.org/content/repositories/appfuse

BUILD SUCCESS with this.

2. Test HSQLDB:

mvn test -Phsqldb

And then, the error:

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 10.246 sec
<<< FAILUR     E! - in com.mycompany.webapp.listener.StartupListenerTest
 212
testContextInitialized(com.mycompany.webapp.listener.StartupListenerTest)
Time elaps     ed: 9.991 sec  <<< ERROR!
 213 org.springframework.transaction.CannotCreateTransactionException: Could
not open Hibe     rnate Session for transaction; nested exception is
org.hibernate.exception.GenericJDB     CException: Could not open connection
...
Caused by: java.sql.SQLSyntaxErrorException: unexpected end of statement
 305     at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
~[hsqldb-2.3.2.jar:2.3.2     ]

Also, modifying HSQLDB validaton query by "SELECT 1 FROM
INFORMATION_SCHEMA.SYSTEM_USERS" results in the test not crashing but
freezing at:

With this I manage to get the tests frozen at:

 DEBUG [main] UserDaoHibernate.saveUser(53) | user's id: null
221 Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 14.927
sec - in com.mycompany.webapp.controller.S    ignupControllerTest
222 Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 17.246
sec - in com.mycompany.webapp.controller.P    asswordHintControllerTest
223 WARN [main] UserFormController.showForm(191) | User 'user' is trying to
edit user with id 'null'





--
View this message in context: http://appfuse.547863.n4.nabble.com/Spring-Hibernate-HSQLDB-unexpected-end-of-statement-tp4656699p4657759.html
Sent from the AppFuse - User mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Spring Hibernate HSQLDB - unexpected end of statement

predicador37
Mmmm I had problems with H2 too.

Perhaps problems with pararell transactions in HSQLDB could be avoided some way:

1. Use hsqldb.lock_file=false

https://developer.jboss.org/wiki/HowToUseHSQLDatabaseWithJBossToolsRightWay

or 2. Running HSQLDB in server mode (similar to MySQL).

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Spring Hibernate HSQLDB - unexpected end of statement

predicador37
In reply to this post by mraible
I've tried using sessionVariables=FOREIGN_KEY_CHECKS=0 in the JDBC URL, but had no success.

All I get is a ConstraintViolationException: could not execute statement

I'm almost giving up :(
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Spring Hibernate HSQLDB - unexpected end of statement

mraible
Administrator
Is it possible to use another database? I'm sorry I don't know how to solve this issue.

You might try posting a question on Stack Overflow.
On Mon, Mar 23, 2015 at 17:31 predicador37 <[hidden email]> wrote:
I've tried using sessionVariables=FOREIGN_KEY_CHECKS=0 in the JDBC URL, but
had no success.

All I get is a ConstraintViolationException: could not execute statement

I'm almost giving up :(



--
View this message in context: http://appfuse.547863.n4.nabble.com/Spring-Hibernate-HSQLDB-unexpected-end-of-statement-tp4656699p4657762.html
Sent from the AppFuse - User mailing list archive at Nabble.com.
Loading...