I have a jax-ws service, but when I run my hibernate transaction in it, I get the following exception:
Caused by: java.sql.SQLException: DSRA9350E: Operation Connection.commit is not allowed during a global transaction.
at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.commit(WSJdbcConnection.java:1104)
at org.hibernate.transaction.JDBCTransaction.commitAndResetAutoCommit(JDBCTransaction.java:170)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:146)
... 47 more
I'm not using an XA data source, the client is a junit that is not connecting to any database. I did not do anything I know of to this web service to cause it to think I want a global transaction. I did not set any policy sets in websphere, and indeed when I look at the admin console, I see none set.
My hibernate transaction uses @Transactional. My web service is annotated thusly:
@WebService(targetNamespace = "http://my.domain.enote")
public interface IQueueWS {
@WebMethod(operationName="enqueueCandidate")
public List<String> enqueueCandidate(Candidate candidate);
@WebMethod(operationName="enqueueCandidates")
public List<String> enqueueCandidates(List<Candidate> candidates);
}
At the top of my implementation class:
@Stateless
@WebService(
portName = "QueueWSPort",
serviceName = "QueueWSService",
targetNamespace = "http://gov.usdoj.afms.enote",
endpointInterface = "gov.usdoj.afms.enote.webservices.queue.IQueueWS")
public class QueueWS {
and then in the client:
Service client = Service.create(
new URL("http://localhost:9080/eNotesApp/QueueWSService?wsdl"),
new QName("http://gov.usdoj.afms.enote", "QueueWSService"));
IQueueWS queue = client.getPort(IQueueWS.class);
Candidate c = new Candidate();
//blah blah, deleted for brevity
List<String> errors = queue.enqueueCandidate(c);
I used to use eclipse's wsgen wizards to generate services, so this is the first I've tried to use just the annotations...and they work to the extent that control gets where it needs to with the right parameters. It's just this transactional thing that is holding us back.
I think the reason your @WebService
is transactional is because of the @Stateless
annotation. In EJB 3.0, the default transaction attribute for all EJB 3.0 applications is REQUIRED.
If you don't want this, you can add an annotation to your stateless session bean class with:
@Stateless
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
@WebService(
...
I think this will let you perform your transactional logic in a lower level of your application as you describe, and a global transaction will not be initiated.