Spring

 View Only

 Caused by: org.springframework.orm.jpa.JpaSystemException: Unable to commit against JDBC Connection; nested exception is org.hibernate.TransactionException: Unable to commit against JDBC Connection

Gary Shepard's profile image
Gary Shepard posted Mar 14, 2019 04:13 PM

 

Daniel Lynch's profile image
Broadcom Employee Daniel Lynch

Hi Gary,

Could you provide a bit more context regarding what steps you performed to observe this error and if you have verified the database is healthy? It looks like that error is saying it failed to commit a transaction in the database.

Gary Shepard's profile image
Gary Shepard

Sure, basically I created an application using yoeman generator / Jhipster, I selected MySQL as my database, the app runs fine in my local env, with MySQL, NOTE: local app uses admin/admin and authenticates with no issue.

 

I use Jhipster to build a manifest.yml, I use a my dev profile, again its a MySQL db

 

Deploy the app to PCF -

? Name to deploy as: MovieRental

? Which profile would you like to use? dev

? What is the name of your database service? cleardb

? What is the name of your database plan? spark

 

Creating Cloud Foundry deployment files

Checking for an existing Cloud Foundry hosting environment...

Creating your Cloud Foundry hosting environment, this may take a couple minutes...

Creating the database

Creating service instance movierental in org ea2sa / space uat as gary.shepard@capgemini.com...

OK --- looks ok to me :-)

 

The app stages and builds w/o issue:

In case you want to see it :-) : https://movierental.cfapps.io/#/

 

When I attempt to login : I fails to authenticate me, looking at the logs I saw that error:

I've included the ENV VARS just because:

 

That app not rocket science, I share that if you like as well:

Adding this line from the log also: 2019-03-15T10:40:47.868-07:00 [APP/PROC/WEB/0] [OUT] Caused by: java.sql.SQLException: Can't call commit when autocommit=true

 

Thank Dan for responded to this

 

 

Attachment  View in library
Daniel Lynch's profile image
Broadcom Employee Daniel Lynch

it sounds like you might be getting a stack trace similar to this

https://javabeat.net/java-sql-sqlexception-autocommittrue-exception/

 

you can disable auto commit by adding the option to your JDBC URL from "VCAP_SERVICES.cleardb[0].credentials.jdbcUrl"

 

some folks also suggest setting the relaxAutoCommit flag

 

https://stackoverflow.com/questions/5262327/jdbc-commit-failed-calling-commit-when-autocommit-true-multithreaded-hibernate

Patrick Crocker's profile image
Patrick Crocker

I've seen this problem when using the MySql driver that JHipster is pulling in to use with the `cleardb` PWS marketplace service.  To test, comment out the `mysql:mysql-connector-java` dependency in your `pom.xml` and then re-package and re-push your app.  In the absence of the mysql driver, the java buildpack will auto add in the mariadb-jdbc driver. You should see things working after that.

 

If that works, you might experiment with packaging the `org.mariadb.jdbc:mariadb-java-client` dependency in your app instead of the `mysql-connector-java` when targeting cleardb.