jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christophe Lombart" <christophe.lomb...@gmail.com>
Subject Re: [OCM] XAException when updating binary content
Date Thu, 21 Feb 2008 08:25:09 GMT
ok thanks for the feedback

Christophe


On Thu, Feb 21, 2008 at 9:15 AM, Xavier Coulon <xcoulon@gmail.com> wrote:

> Hello Christophe,
>
> Ohoh ! I just upgraded the jackrabbit-core package to the version
> 1.4.1released yesterday and the problem is fixed ;-)
>
>
> If you're still interested in the stacktrace, here it is when using the
> jackrabbit-core-1.4 :
>
> org.springframework.transaction.TransactionSystemException: Could not
> commit
> JCR transaction; nested exception is javax.transaction.RollbackException:
> javax.transaction.xa.XAException
>     at org.springmodules.jcr.jackrabbit.LocalTransactionManager.doCommit(
> LocalTransactionManager.java:195)
>    at
>
> org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit
> (AbstractPlatformTransactionManager.java:709)
>    at
>
> org.springframework.transaction.support.AbstractPlatformTransactionManager.commit
> (AbstractPlatformTransactionManager.java:678)
>    at
>
> org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning
> (TransactionAspectSupport.java:319)
>    at
> org.springframework.transaction.interceptor.TransactionInterceptor.invoke(
> TransactionInterceptor.java:116)
>    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed
> (
> ReflectiveMethodInvocation.java:171)
>    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(
> JdkDynamicAopProxy.java:204)
>    at $Proxy16.store(Unknown Source)
>    at
> sample.service.ContentServiceTestCase.testSaveAndRetrieve2ContentWithData(
> ContentServiceTestCase.java:122)
>    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>    at sun.reflect.NativeMethodAccessorImpl.invoke(
> NativeMethodAccessorImpl.java:39)
>    at sun.reflect.DelegatingMethodAccessorImpl.invoke(
> DelegatingMethodAccessorImpl.java:25)
>    at java.lang.reflect.Method.invoke(Method.java:597)
>    at org.springframework.test.context.junit4.SpringTestMethod.invoke(
> SpringTestMethod.java:198)
>    at
> org.springframework.test.context.junit4.SpringMethodRoadie.runTestMethod(
> SpringMethodRoadie.java:274)
>    at org.springframework.test.context.junit4.SpringMethodRoadie$2.run(
> SpringMethodRoadie.java:207)
>    at
>
> org.springframework.test.context.junit4.SpringMethodRoadie.runBeforesThenTestThenAfters
> (SpringMethodRoadie.java:254)
>    at
>
> org.springframework.test.context.junit4.SpringMethodRoadie.runWithRepetitions
> (SpringMethodRoadie.java:234)
>    at org.springframework.test.context.junit4.SpringMethodRoadie.runTest(
> SpringMethodRoadie.java:204)
>    at org.springframework.test.context.junit4.SpringMethodRoadie.run(
> SpringMethodRoadie.java:146)
>    at
>
> org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod
> (SpringJUnit4ClassRunner.java:151)
>    at org.junit.internal.runners.JUnit4ClassRunner.runMethods(
> JUnit4ClassRunner.java:51)
>    at org.junit.internal.runners.JUnit4ClassRunner$1.run(
> JUnit4ClassRunner.java:44)
>    at org.junit.internal.runners.ClassRoadie.runUnprotected(
> ClassRoadie.java:27)
>    at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java
> :37)
>    at org.junit.internal.runners.JUnit4ClassRunner.run(
> JUnit4ClassRunner.java:42)
>    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(
> JUnit4TestReference.java:38)
>    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(
> TestExecution.java:38)
>    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
> RemoteTestRunner.java:460)
>    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
> RemoteTestRunner.java:673)
>    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(
> RemoteTestRunner.java:386)
>    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(
> RemoteTestRunner.java:196)
> Caused by: javax.transaction.RollbackException:
> javax.transaction.xa.XAException
>    at
> org.springmodules.jcr.jackrabbit.support.JackRabbitUserTransaction.commit(
> JackRabbitUserTransaction.java:110)
>    at org.springmodules.jcr.jackrabbit.LocalTransactionManager.doCommit(
> LocalTransactionManager.java:192)
>    ... 31 more
>
>
> Regards,
> Xavier
>
> On Wed, Feb 20, 2008 at 8:46 PM, Christophe Lombart <
> christophe.lombart@gmail.com> wrote:
>
> > Hi Xavier,
> >
> > Do you have the stack trace ?
> >
> > Christophe
> >
> >
> > On Wed, Feb 20, 2008 at 7:06 PM, Xavier <xcoulon@gmail.com> wrote:
> >
> > >
> > > Hello,
> > >
> > > I'm starting with Jackrabbit 1.4 w/ OCM + Spring 2.5 + SpringModules
> > > When I want to update an existing node that contains binary data
> > (byte[]),
> > > I
> > > get the following error message in my test case :
> > >
> > > org.springframework.transaction.TransactionSystemException: Could not
> > > commit
> > > JCR transaction; nested exception is
> javax.transaction.RollbackException
> > :
> > > javax.transaction.xa.XAException
> > >
> > >
> > >
> > > JUnit Test case :
> > > This test insert a new node then updates the node and checks the
> > retrieved
> > > content is correct
> > >        @Test
> > >        public void testSaveAndRetrieve2ContentWithData() {
> > >                // store content
> > >                Content originalVersion = new Content(
> > >                                "/testSaveAndRetrieveStringContent", "a
> > new
> > > content", data1,
> > >                                mimeType1);
> > >                imageService.store(originalVersion);
> > >                Content anotherVersion = new Content(
> > >                                "/testSaveAndRetrieveStringContent",
> "an
> > > even newer content",
> > >                                data2, mimeType2);
> > >                imageService.store(anotherVersion);
> > >                Content retrievedVersion = imageService
> > >
> > >  .findByPath("/testSaveAndRetrieveStringContent");
> > >                Assert.assertEquals("Contents should be equal",
> > > anotherVersion
> > >                                .getTitle(), retrievedVersion.getTitle
> > ());
> > >        }
> > >
> > > Domain Model:
> > >
> > > @Node(jcrType="nt:unstructured",
> > >                jcrMixinTypes =
> > > "mix:versionable,mix:referenceable,mix:lockable")
> > > public class Content {
> > >
> > >        /** Node path in the CR */
> > >        @Field(path=true)
> > >        private String path;
> > >
> > >        @Field(uuid=true)
> > >        private String uuid;
> > >
> > >        @Field(jcrName = "test:lastModified")
> > >        private Calendar lastModified;
> > >
> > >        /** content title */
> > >        @Field(jcrName = "test:title")
> > >        private String title = null;
> > >
> > >        @Field(jcrName = "test:mimeType")
> > >        private String mimeType;
> > >
> > >        @Field(jcrName = "test:data")
> > >        private byte[] data;
> > >
> > >
> > > ServiceImpl:
> > >
> > >       public void store(Content content) {
> > >                // check no node with the same path already exists,
> > >                // otherwise, create a new version of the same node
> > >                content.setLastModified(new GregorianCalendar());
> > >                if(findByPath(content.getPath()) == null) {
> > >                        LOG.warn("Inserting the new content with path "
> +
> > > content.getPath());
> > >                        jcrMappingTemplate.insert(content);
> > >                        jcrMappingTemplate.save();
> > >                } else {
> > >                        LOG.warn("Updating the content with path " +
> > > content.getPath());
> > >                        // find previous version in repository
> > >                        Content original =
> > > (Content)jcrMappingTemplate.getObject(content.getPath());
> > >                        // copy all properties
> > >                        original.setData(content.getData());
> > >                        original.setLastModified(
> content.getLastModified
> > > ());
> > >                        original.setMimeType(content.getMimeType());
> > >                        original.setTitle(content.getTitle());
> > >                        // perform update
> > >                        jcrMappingTemplate.checkout(original.getPath
> ());
> > >                        jcrMappingTemplate.update(original);
> > >                        jcrMappingTemplate.save();
> > >                        jcrMappingTemplate.checkin(original.getPath());
> > >                }
> > >        }
> > >
> > > Spring Config:
> > > <!-- annotation-config activation is triggered by component-scan -->
> > >  <context:component-scan base-package="sample" />
> > >
> > >  <context:property-placeholder location="classpath:
> repository.properties
> > "
> > > />
> > >
> > >  <!-- enable the configuration of transactional behavior based on
> > > annotations -->
> > >  <tx:annotation-driven transaction-manager="jcrTransactionManager" />
> > >
> > >  <bean id="jcrTransactionManager"
> > >    class="org.springmodules.jcr.jackrabbit.LocalTransactionManager">
> > >    <property name="sessionFactory" ref="jcrSessionFactory" />
> > >  </bean>
> > >
> > >  <bean id="jcrRepository"
> > > class="org.springmodules.jcr.jackrabbit.RepositoryFactoryBean">
> > >    <!-- normal factory beans params -->
> > >    <property name="configuration" value="classpath:jackrabbit-repo.xml
> "
> > />
> > >    <property name="homeDir" value="file:D:/tmp/repository" />
> > >  </bean>
> > >
> > >  <bean id="jcrSessionFactory"
> > >    class="
> org.springmodules.jcr.jackrabbit.ocm.JackrabbitSessionFactory
> > ">
> > >    <property name="repository" ref="jcrRepository" />
> > >    <property name="credentials" ref="jcrCredentials" />
> > >    <property name="nodeTypes2Import"
> > > value="classpath:nodetypes/custom_nodetypes.xml" />
> > >    <property name="namespaces">
> > >      <util:properties>
> > >        <prop key="ocm">http://jackrabbit.apache.org/ocm</prop>
> > >        <prop key="test">http://test</prop>
> > >      </util:properties>
> > >    </property>
> > >    <property name="sessionHolderProviderManager"
> > > ref="sessionHolderProviderManager" />
> > >  </bean>
> > >
> > >  <bean name="sessionHolderProviderManager"
> > >    class="
> org.springmodules.jcr.support.ListSessionHolderProviderManager
> > ">
> > >    <property name="providers">
> > >      <list>
> > >        <bean
> > > class="
> > >
> org.springmodules.jcr.jackrabbit.support.JackRabbitSessionHolderProvider
> > "
> > > />
> > >      </list>
> > >    </property>
> > >  </bean>
> > >
> > >  <!-- JCR Credentials -->
> > >  <bean id="jcrCredentials" class="javax.jcr.SimpleCredentials">
> > >    <constructor-arg index="0" value="${jcr.connection.username}" />
> > >    <constructor-arg index="1">
> > >      <bean factory-bean="jcrCredentialsPassword"
> > > factory-method="toCharArray" />
> > >    </constructor-arg>
> > >  </bean>
> > >  <bean id="jcrCredentialsPassword" class="java.lang.String">
> > >    <constructor-arg index="0" value="${jcr.connection.password}" />
> > >  </bean>
> > >
> > >  <bean id="mapper"
> > > class="org.springmodules.jcr.jackrabbit.ocm.JcrMapperFactoryBean">
> > >    <property name="classes">
> > >      <list>
> > >        <value>sample.domain.Content</value>
> > >      </list>
> > >    </property>
> > >  </bean>
> > >
> > >  <bean id="jcrMappingTemplate"
> > > class="org.springmodules.jcr.jackrabbit.ocm.JcrMappingTemplate">
> > >    <property name="sessionFactory" ref="jcrSessionFactory" />
> > >    <property name="mapper" ref="mapper" />
> > >    <property name="allowCreate" value="true" />
> > >  </bean>
> > >
> > >
> > >
> > > Can you tell what's wrong with this ?
> > > Thank you in advance
> > > Xavier
> > >
> > > --
> > > View this message in context:
> > >
> >
> http://www.nabble.com/-OCM--XAException-when-updating-binary-content-tp15595036p15595036.html
> > > Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
> > >
> > >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message