I have a project based in Spring Web model-view-controller (MVC) framework. The version of the Spring Web model-view-controller (MVC) framework is 3.2.8 deployed on a WebLogic Server Version: 12.1.2.0.0
I have this error in 1 query
Caused By: java.lang.RuntimeException: java.sql.SQLException:
The transaction is no longer active - status: 'Marked rollback. [Reason=weblogic.transaction.internal.TimedOutException: Transaction timed out after 31 seconds
BEA1-000D9470C1367F28EDB9]'.
No further JDBC access is allowed within this transaction., criteria [ com.tdk.books.domain.ProductSearchCriteria#c5f15d5c ], sql [ select PRODUCT_ID from V_BOOKS where category_id = ? ]
even I put a timeout of 10000 in the service method
#Transactional(timeout=10000, propagation = Propagation.REQUIRES_NEW)
Root Cause from Oracle Community:
Usuallly this happens when a transaction is finished, but this fact is
ignored and an app tries to continue processing and to issue JDBC
statements that happen outside of the TX. The source of this problem
could be a Connection object that is passed around through a sequence
of methods that use the connection. One of such methods commits the TX
thus invalidating the connection.
Resource Link: https://community.oracle.com/thread/734370
Some suggestions are found to solve the issue.
First Suggestion:
Please try changing your weblogic datasource settings from Non - XA to
XA. You should get rid of this exception.
Resource Link: The transaction is no longer active - status: 'Committed'
Second Suggestion:
Uncheck the Supports Global Transactions restart the server.
Resource Link: In PRPC ERROR: The transaction is no longer active - status: 'Committed'
Third Suggestion:
The real solution of this problem is asynchronous processing. But it
might be possible that it's not suitable in your case.
First one If you are making any jdbc call to Oracle, then you can set
the query time out whn you execute the query on database. And after
query timeout, Oracle will give you an exception that you can handle
it. So basically in this case you are not cancelling your EJB request
actually. But it might solve your problem.
Resource Link: https://coderanch.com/t/68079/transaction-rollback-commit
Related
I Managed to find an error (Bug) in
https://github.com/spring-projects/spring-session
Due to the fact that the project is poorly configured.
I set up that all sessions are saved in the database through the config: #EnableJdbcHttpSession in Mysql (MariaDB).
The trouble is that the filter is one for all and any request to the front ... for example, give the statics (picture, css, etc.) - it has its own session key and also climbs into the database.
Everyone getting the picture.
Any request from the front in which there is a session and the cuckolds goes to the Mysql.
Requests that do not need to go to the database go there.
This is a large number of SELECT .... UPDATE ... table calls
SPRING_SESSION
SPRING_SESSION_ATTRIBUTES
How would this error be described to the developers?
How to configured spring session with EnableJdbcHttpSession and filter ?
Only business request went to the database ?
My springboot microservice depends on AS400 DB2 which may be down when the service starts up.
The service has a configuration bean which has autowired JpaRepository based repositories.
During startup, when DB2 is down I get following message:
"org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set"
So the services fails to start up and remains dead till forcefully rebooted.
If I set JVM parameter "-Dhibernate.dialect=org.hibernate.dialect.DB2400Dialect", the service starts up and I can make requests to the service when DB2 comes up. It feels like a hack, so I wonder if there is the right way to deal with this issue for springboot services?
I saw this thread, but it doesn't answer my question.
Basically what I am looking for is somehow start the microservice with those autowired repositories even if DB is down at the moment so that later, when the actual request comes, the connection to the DB could be restored and request serviced.
Have you tried to specify Hibernate dialect for your DBMS flavour in src/main/resources/application.properties like:
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.DB2400Dialect
?
Spring Boot autodetects dialect on startup if database is up but there is nothing inappropriate to specify your dialect explicitly in source code.
I'm using eclipselink 2.4 in a JAX-RS (Jersey) application.
In my base controller, I connect to my database, but since the entity manager only really connects when a query is executed, an exception is thrown.
Is there a way I could determine if I can connect to a database after I get the EntityManager object so that I can handle the exception myself (and fail over manually to another database).
EDIT: assume I cannot change the underlying DBMS at all.
You could create a ServletContextListener and run a query on startup for your application. However if it fails you are out of luck for the error handling I guess.
You should really get a clustered HA database.
What would be the best way to setup/design or simply configure an Hibernate based Java web application to support being started (i.e. sessionfactory initialization) up if the database connectivity is not yet available, but will be, albeit at a much later time.
In other words, is there an easy way to handle out of order initialization between an Hibernate server application and its database?
As far as i know . If you use external connection pool and hibernate is no responsible to making the connections and in additional hbm2ddl is set to none than hibernate should not connect to the database untill you open a session.
Any way if it will failed to open session because there is no connection it will success to open new session as soon as there is databas connectivity.
I am working on a project that has Spring based Web Services and Spring Jdbc based persistence.
I have configured a DataSourceTransactionManager to manage the transactions and applied this to the service layer using a Pointcut.
Transaction propagation level is set REQUIRED.
The queries are issued through Spring provided JdbcTemplate.
The problem is that in case of multiple concurrent request to a service i get a MySQLTransactionRollbackException("Deadlock found when trying to get lock; try restarting transaction").
Apparently one of the transactions has obtained a lock which makes the second one fail.
My question is - How should configure Spring to delay the execution of the service until a lock is obtainable, instead of just giving up and throwing an exception?
I can't even catch the exception and try to re-execute the query because I've applied transaction on service layer as an advice keeping my DAOs clean.
I'm hoping to get a declarative solution only (since I am an AOP fanatic & crusader against boilerplate code :-) ). But even programmatic solutions are welcome.
Thanks for your suggestions.
Update -
#ninjalj Yes it was actually a real deadlock. Turns out I was writing my test case incorrectly. Silly me :-(
If I'm not mistaken, that indicates a real deadlock, so you should really retry the transaction. IIRC, a timeout waiting for a lock has "timeout" in the exception message.