Websphere + Spring: javax.transaction.Transactional - java

Using Spring within Websphere, when using the javax.transaction.Transactional. Running the code locally or within Tomcat works as intended but while running within Websphere, it appears that the javax.transaction.Transactional annotation is not resulting in a Transaction that includes the JPA-EntityManager. Replacing the javax.transaction.Transactional annotation with the Spring version of Transactional solves this issue.
We would like to know what is required to fix this issue. I found this Stackoverflow-issue: spring-jta-transaction-with-jpa-and-jndi-datasource-for-websphere which links to the Article: 0609_alcott-pdf.pdf
The advise given is to configure Spring to use the WebSphereUowTransactionManager as transaction manager.
The stackoverflow answer is from 2012. But since we are running a farely old WebSphere 7 version, it might sill be relevant to us.
Does anyone experienced the similar or a related problem?
Update
The following dependencies are used:
spring-core: 4.3.9
hibernate.core: 4.2.15.Final
spring-boot starter: 1.5.4.RELEASE

Related

Spring Boot 2.6.12 compatibility with Spring Cloud (Config) 2021.0.4

I'm trying to update my project Spring Boot version from 2.4.13 to 2.6.12
We were using Spring Cloud 2020.0.0-M6 and I also wanted to bump the version to 2021.0.4
Now my application won't load its remote configuration even though I can see in the logs that it finds the service and the configuration!!
In the above picture you can see my app does find the config-service once deployed to our Development environment.
And after that, it throws me an error because it's trying to use its local configuration where I'm using Environment Variables set from my IDE, using the following syntax ${var}, to replace the value depending on the Run/Debug Configuration.
In the meantime, I'm trying to use Spring Boot 2.6.11 with Spring Cloud 2021.0.4. If I can't get it to work I will have to downgrade it to the last working version until I find the problem.
Any help is appreciated!
Thanks

Spring #Transactional not working in ApplicationServer

We have a Spring-Boot application exposing some REST endpoints. We allow for this application to be operated standalone (as executable jar) or as a war to be deployed in a wildfly-11 application-server.
The class defining the REST-endpoints is marked #RestController #Transactional(REQUIRES_NEW) (both on class level, obviously). When running standalone, everything works as expected but when deployed in wildfly, the rollback on exceptions does not work. We established this by sending the exact same REST-message while operating on the exact same database.
We have confirmed via debugging that the final frames of the stacktrace is identical in both cases and especially in both cases we see a transactional-proxy around our REST-controller bean.
One difference would be, that within wildfly the application will use a jndi-datasource, prepared by wildfly while standalone the spring-boot will manage the database-connections.
Any idea what is wrong here?
Edit
I just tried explicitly invoking setRollbackOnly on the JtaTransactionmanager from within my code. The transaction will still commit. This sort of looks like a bug in Spring Boot to me.
Edit 2
Debugging further reveals that the transaction seems to be set to autocommit - every statement is immediately written to the database. This seems to be in violation to the annotation #Transactional and also to the fact that Spring creates a transactional proxy around my bean.
It's not a full answer - just a reasoning. JNDI is usally used at the app server layer whereas JDBC - at the application layer. At the App server layer are used global transaction settins that are overriding app settings. Follow the spring doc to get more
For reasons beyond my understanding the default transactional behaviour when deploying a spring-boot webapp to an application-server is auto-commit.
The solution to this problem is to enrich your application-configuration with the property spring.datasource.tomcat.default-auto-commit=false

make a bean run on application start. EJB3/websphere6.1/Java1.5

I am a little new to J2EE. I have a EJB3 project and I want to run a class on application start-up, how can I do that?
I know in EJB3.1 I can use #startup and #singleton unfortunately that is not a option and I have to use EJb3 and java 5. I have done some research and there were a few solutions but I have been unable to make it work.
WebSphere Application Server version 6.1 does not support EJB3 with a standard installation. You also need to have a feature pack for EJB 3.0 installed.
See this information on the IBM site.
If this is not your issue you should update your question with more detail of what goes wrong.
Your only options prior to WebSphere 8 (with EJB 3.1 support) are:
WebSphere startup beans. These are a programming model extension
Package a WAR with the application, and use a ServletContextListener to initialize state used by the EJBs.

Using spring core functionalities in tomcat based jersey application

I want to use spring's dependency injection for now(other core functionalites later maybe) in tomcat application.
I want to set up spring 2.5.5 in tomcat7, But don't have clarity on how to do this.
Specifically I am confused because I don't know whether to use Spring MVC or use just spring in tomcat.
I found this question helpful: Tomcat with Spring, But still didn't get the whole scenario on how to setup tomcat with spring.
You can do either, using just core spring with tomcat is fine. MVC provides additional functionality.
Take a look at the spring source examples on github, and read their docs.
(BTW I thouroughy spring-MVC component - it really saves time developing webapps)

Seam + hibernate + jsf on weblogic

I'm making a little project with Seam, Hibernate and JSF. This project run on JBoss 5.1.
My boss wants to deploy this project on WebLogic. I read on the seam documentation that seam and WebLogic don't work fine together.
I would like to know if I can use Hibernate (with JPA) and JSF on WebLogic and what framework (struts, spring?) I can use to replace Seam.
Edit: I read in the seam documentation (chapter 39, weblogic integration) and I find that:
For several releases of Weblogic there has been an issue with how Weblogic generates stubs and compiles EJB's that use variable arguments in their methods. This is confirmed in the Weblogic 9.X and 10.0.MP1 versions. Unfortunately the 10.3 version only partially addresses the issue as detailed below. So, I want to know if other problems like this exist.
Edit 2: I use Weblogic 10.3
What do you mean by "don't work fine together"? I've already seen Seam applications on WebLogic and the Seam documentation provides detailed instruction to run Seam on WebLogic without mentioning any blocking issue.
If you have something specific in mind, please clarify. But in the current state of the question, my advice would be to stick to Seam and to deploy your application on WLS.

Categories

Resources