Dear all,

in my EJB3 SLSB (exposed as a WebService) I'd like to contact a Jackrabbit XA 
datasource, operate on it, and commit changes.

The datasource is configured in server/default/deploy/jcr-ds.xml:

  |    <connection-factories>
  |        <tx-connection-factory>
  |            <jndi-name>jcr/local</jndi-name>
  |            <xa-transaction/>
  |            <rar-name>jackrabbit-jca-1.3.1.rar</rar-name>
  |            
<connection-definition>javax.jcr.Repository</connection-definition>
  |            <config-property name="homeDir" 
type="java.lang.String">${jboss.server.data.dir}${/}jackrabbit</config-property>
  |            <config-property name="configFile" 
type="java.lang.String">classpath:repository.xml</config-property>
  |            <config-property name="bindSessionToTransaction" 
type="java.lang.Boolean">true</config-property>
  |        </tx-connection-factory>
  |    </connection-factories> 
  | 

my SLSB looks like:
the field that contains the connection factory:

  |    @Resource(mappedName="java:jcr/local", type=javax.jcr.Repository.class, 
authenticationType=javax.annotation.Resource.AuthenticationType.CONTAINER) 
Repository repo;
  | 
the method (excerpt) where operations are executed on the XA connection:

  |            Credentials cred = new SimpleCredentials(path.getUsername(), 
path.getPassword());
  |            session = repo.login(cred, null);
  |            Node root = session.getRootNode();
  |            Node child = root.hasNode(path.getRelativePath()) ? 
root.getNode(path.getRelativePath()) : createFilePath(root, 
path.getPathParts(), path.getObjectName());
  |            FileTypeResolver ftr = FileTypeResolver.instantiate();
  |            child.setProperty("jcr:mimeType", ftr.getMIMEType(obj));
  |            child.setProperty("jcr:data", new FileInputStream(obj));
  |            Calendar rightNow = Calendar.getInstance();
  |            child.setProperty("jcr:lastModified", rightNow);
  |            session.save(); 
  | 
I annotated the method with:

  |    @TransactionAttribute(TransactionAttributeType.REQUIRED)
  | 
This should be the default setting AFAIK, but who knows ... 

Debugging my code I found out that everything works fine until and after 
session.save() - When the method returns however it seems that a commit takes 
place (calling XASessionImpl.end()) and this commit is not successful due to a 
missing transaction:

  | 143394 [http-0.0.0.0-8080-3] ERROR 
org.jboss.ws.core.jaxws.SOAPFaultHelperJAXWS  - SOAP request exception
  | java.lang.RuntimeException: org.jboss.tm.JBossRollbackException: Unable to 
commit, tx=TransactionImpl:XidImpl[FormatId=257,
  | GlobalId=dme018/14, BranchQual=, localId=14] status=STATUS_NO_TRANSACTION; 
- nested throwable: (javax.transaction.xa.XAExc
  | eption)
  |        at 
org.jboss.aspects.tx.TxPolicy.handleEndTransactionException(TxPolicy.java:198)
  |        at org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:180)
  |        at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:87)
  |        at 
org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
  |        at 
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  |        at 
org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
  |        at 
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  |        at 
org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
  |        at 
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  |        at 
org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
  |        at 
org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:102)
  |        at 
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  |        at 
org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
  |        at 
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  |        at 
org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
  |        at 
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  |        at 
org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:211)
  |        at 
org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:173)
  |        at 
org.jboss.ws.integration.jboss42.ServiceEndpointInvokerEJB3.invokeServiceEndpoint(ServiceEndpointInvokerEJB3.jav
  | a:114)
  |        at 
org.jboss.ws.core.server.AbstractServiceEndpointInvoker.invoke(AbstractServiceEndpointInvoker.java:173)
  |        at 
org.jboss.ws.core.server.ServiceEndpoint.handleRequest(ServiceEndpoint.java:204)
  |        at 
org.jboss.ws.core.server.ServiceEndpointManager.processSOAPRequest(ServiceEndpointManager.java:440)
  |        at 
org.jboss.ws.core.server.AbstractServiceEndpointServlet.doPost(AbstractServiceEndpointServlet.java:114)
  |        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  |        at 
org.jboss.ws.core.server.AbstractServiceEndpointServlet.service(AbstractServiceEndpointServlet.java:75)
  |        at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
  |        at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
  |        at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
  |        at 
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
  |        at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
  |        at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
  |        at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
  |        at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
  |        at 
org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
  |        at 
org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
  |        at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
  |        at 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
  |        at 
org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
  |        at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
  |        at 
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
  |        at 
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
  |        at 
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:66
  | 4)
  |        at 
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
  |        at 
org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
  |        at java.lang.Thread.run(Thread.java:595)
  | Caused by: org.jboss.tm.JBossRollbackException: Unable to commit, 
tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=dme018/
  | 14, BranchQual=, localId=14] status=STATUS_NO_TRANSACTION; - nested 
throwable: (javax.transaction.xa.XAException)
  |        at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:372)
  |        at org.jboss.tm.TxManager.commit(TxManager.java:240)
  |        at org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:175)
  |        ... 43 more
  | Caused by: javax.transaction.xa.XAException
  |        at 
org.apache.jackrabbit.core.XASessionImpl.end(XASessionImpl.java:279)
  |        at 
org.apache.jackrabbit.jca.TransactionBoundXAResource.end(TransactionBoundXAResource.java:46)
  |        at 
org.jboss.tm.TransactionImpl$Resource.endResource(TransactionImpl.java:2143)
  |        at 
org.jboss.tm.TransactionImpl$Resource.endResource(TransactionImpl.java:2118)
  |        at 
org.jboss.tm.TransactionImpl.endResources(TransactionImpl.java:1462)
  |        at 
org.jboss.tm.TransactionImpl.beforePrepare(TransactionImpl.java:1116)
  |        at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:324)
  |        ... 45 more 
  | 

This topic may fit into the JCA or Transactions Forums as well, but it seems 
that it is somehow closely related to EJB3, since the same code works well from 
within a JSP page.

Any help/guidance is highly appreciated.


kind regards,
Markus

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4073888#4073888

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4073888
_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to