How to config #RetryTransaction in Spring? - spring

I get this error :
Getting “Deadlock found when trying to get lock; try restarting transaction”
I'm trying to resolve it using annotation RetryTransaction with #Transactionnal.
But the annotation cannot be resolved to a type.
What is the config to set in spring-config.xml to make it work ? or maybe supplementary dependecies to install ?

Googling a bit reveals that the annotation you mentioned is not from spring, but someone else produced it.
You can get the maven artefact that contains it from here http://mvnrepository.com/artifact/org.dellroad/dellroad-stuff/1.0.659

Related

Can't cope with running Spring: trouble with candidate component class for jdbc

I have set a task for myself. So far it is just to start Spring.
Repository: https://github.com/Kifsif/reusable
Trace back: https://dpaste.com/CA9YZ4Q3M
The error seems to be localized in the phrase "candidate component class" for jdbc. But I don't seem to have mentioned any database so far. And I'm making my project's structure along the lines of pom.xml generated by Spring Boot initializr.
This is warning in output log:
** WARNING ** : Your ApplicationContext is unlikely to start due to a #ComponentScan of the default package.
Your MainApplication.java is in the default package (src/main/java/MainApplication).
Please create a new package (for example: scr/main/java/example and move your MainApplication into that package, then it works.

spring-boot-starter-data-mongodb don't include GridFSBucket bin as autoconfigured

GridFSBucket is not auto configured in Spring boot parent in 2.1.3.REALEASE, so cant be autowired. But GridFsTemplate is autowire as it is autoconfigured. how to get gridFSBucket from gridFsTemplate. Actually i want to use 'downloadToStream' method to write to a file. If that is possible by GridFSFile then not required.
I had the same issue while migrating, trying to load a PDF stored in MongoDB, causing the file to be corrupted (startxref not found)
Following this answer helped me: https://stackoverflow.com/a/50732308/590374
GridFSFile file = gridFsTemplate.findOne(Query.query(Criteria.where("_id").is(fileId)));
GridFsResource resource = gridFsTemplate.getResource(file);
return resource.getInputStream();

NullPointerException com.liferay.portal.spring.util.SpringFactoryImpl.setBeanDefinitions

I'm using springFramework and I try to setBeanDefinitions, the problem is that this methode need a Map beanDefinition as a param... could U tell me plz how I could instantiate this param?
NullPointerException at com.liferay.portal.spring.util.SpringFactoryImpl.setBeanDefinitions(SpringFactoryImpl.java:56)
additional information:
I try to deploy a liferay project without using liferay configuration files (only springFramework libraries), I created my own sessionFactory, my own dataSource ... etc!!
when I run the program, I'm able to create dataBase Schema basing on portlet-hbm.xml information... well now I try to instantiate beans for portal-spring.xml.. (which are xxxxpersistance.java)! those latters told me that they use 'com.liferay.portal.kernel.dao.orm.SessionFactory' as a required type and it can not convert property value of type 'org.hibernate.impl.SessionFactoryImpl'!! so I tried to use the liferay libraries only for those beans and I try to instanciate them manually... but I wasn't able to setBeanDefinitions cause I need a Map beanDefinition as a param... I don't know if there is a way to get them using sessionFactory or not!!
Thanks again
You only mention junit in the tags to your question. I'd recommend to write unit tests without relying on the whole Liferay infrastructure. That will tremendously lower your required setup efforts and simplify your life a lot.

Spring - Error using "JDBCTemplate": The method "X" refers to the missing type DataAccessException

I´m developing in STS and when I´m going to use JDBC Template I´ve got several errors :S...
I´ve got my DAOImplementation and I want to redefine the JDBCTemplate, but all the methods I´m redefining returns errors like:
The type org.springframework.dao.DataAccessException cannot be resolved. It is indirectly referenced from required .class files
The method query(String, RowMapper) from the type JdbcTemplate refers to the missing type DataAccessException
Concretly, the methods are:
Update.
QueryForString.
Query.
I have imported all dependencies for Maven, I don´t know what is happening...
I hope you could help me, thanks for all :).
Juandi.
In spring 3 the whole jar structure has been re-organized. There is no all-in-one spring.jar as before. You have to pick what you need.
DataAccessException is in org.springframework.transaction-3.0.0.RELEASE.jar
include this jar in class path.
i had same problem add the spring-tx-XXX.jar to you project xxx means version
In spring framework 4.1, "org.springframework.transaction.xxx.jar" is to be imported instead of spring-tx-xxx.jar
Adding
org.springframework.transaction-3.0.1.RELEASE-A.jar
solve my problem
Same on my case, I used Spring-mvc 4.3.0 and have a spring-tx.4.3.0 and DataAccessException in there.
But I haved an error like your case.
Solution : I just deleted Spring-tx Folder dependency in maven repo (.m2/repository/) and update dependency again. It was solved to me.

spring 3.x issue of no such method error

Hi i am using spring framework and while executing annotationbased test case i am getting error can any one have idea about which jar dependancy(maven artifact) file do i need to add in my pom.xml ?
org.springframework.transaction.interceptor.TransactionAttribute.getQualifier() no such method error
Looks like you have two incompatible jars.
Check that: spring-tx and spring-test is of the same version (3.0.x).
If this does not help. Place a break point at TransactionalTestExecutionListener and check that the concreate class that implements TransactionAttribute is of correct version too.

Resources