Read-Write transaction started within read-only transaction

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Member II

Read-Write transaction started within read-only transaction

Hi all,

I'm new to this forum, I hope to find help for my issue...

I'm developing an REPO amp with alfresco 5.1.2 and sdk 2.2.0

During a transation I obtain this stacktrace:

2017-01-27 14:27:28,282  ERROR [management.subsystems.AbstractPropertyBackedBean] [main] Error auto-starting subsystem
 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'imapServiceBootstrap' defined in URL [jar:file:/D:/Data/Dev/.m2/org/alfresco/alfresco-repository/5.1.2/alfresco-repository-5.1.2.jar!/alfresco/subsystems/imap/default/imap-server-context.xml]: Cannot resolve reference to bean 'imapService' while setting bean property 'service'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'imapService' defined in URL [jar:file:/D:/Data/Dev/.m2/org/alfresco/alfresco-repository/5.1.2/alfresco-repository-5.1.2.jar!/alfresco/subsystems/imap/default/imap-server-context.xml]: Cannot resolve reference to bean 'attachmentsExtractor' while setting bean property 'attachmentsExtractor'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'attachmentsExtractor' defined in URL [jar:file:/D:/Data/Dev/.m2/org/alfresco/alfresco-repository/5.1.2/alfresco-repository-5.1.2.jar!/alfresco/subsystems/imap/default/imap-server-context.xml]: Invocation of init method failed; nested exception is org.alfresco.error.AlfrescoRuntimeException: 00270002 Read-Write transaction started within read-only transaction
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:334)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1419)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1160)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:191)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:636)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:934)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
    at org.alfresco.repo.management.subsystems.ChildApplicationContextFactory$ApplicationContextState.start(ChildApplicationContextFactory.java:821)
    at org.alfresco.repo.management.subsystems.AbstractPropertyBackedBean.start(AbstractPropertyBackedBean.java:1093)
    at org.alfresco.repo.management.subsystems.AbstractPropertyBackedBean.onApplicationEvent(AbstractPropertyBackedBean.java:632)
    at org.alfresco.repo.management.SafeApplicationEventMulticaster.multicastEventInternal(SafeApplicationEventMulticaster.java:214)
    at org.alfresco.repo.management.SafeApplicationEventMulticaster.multicastEvent(SafeApplicationEventMulticaster.java:185)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:334)
    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:950)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
    at org.alfresco.util.BaseApplicationContextHelper.getApplicationContext(BaseApplicationContextHelper.java:78)
    at org.alfresco.util.ApplicationContextHelper.getApplicationContext(ApplicationContextHelper.java:67)
    at org.alfresco.repo.web.scripts.TestWebScriptRepoServer.getTestServer(TestWebScriptRepoServer.java:173)
    at org.alfresco.repo.web.scripts.TestWebScriptRepoServer.getTestServer(TestWebScriptRepoServer.java:119)
    at org.alfresco.repo.web.scripts.BaseWebScriptTest.getServer(BaseWebScriptTest.java:269)
    at org.alfresco.repo.web.scripts.BaseWebScriptTest.sendLocalRequest(BaseWebScriptTest.java:422)
    at org.alfresco.repo.web.scripts.BaseWebScriptTest.sendRequest(BaseWebScriptTest.java:342)
    at org.alfresco.repo.web.scripts.BaseWebScriptTest.sendRequest(BaseWebScriptTest.java:318)
    at com.amadeus.acm.gui.webscript.AmadeusformSaveWebScriptTest.access$800(AmadeusformSaveWebScriptTest.java:53)
    at com.amadeus.acm.gui.webscript.AmadeusformSaveWebScriptTest$10.execute(AmadeusformSaveWebScriptTest.java:341)
    at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:464)
    at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:352)
    at com.amadeus.acm.gui.webscript.AmadeusformSaveWebScriptTest.testMultimedia(AmadeusformSaveWebScriptTest.java:335)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
    at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
    at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:88)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
    at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
    at org.junit.runners.Suite.runChild(Suite.java:128)
    at org.junit.runners.Suite.runChild(Suite.java:24)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:136)
    at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.createRequestAndRun(JUnitCoreWrapper.java:108)
    at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.executeEager(JUnitCoreWrapper.java:78)
    at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.execute(JUnitCoreWrapper.java:54)
    at org.apache.maven.surefire.junitcore.JUnitCoreProvider.invoke(JUnitCoreProvider.java:144)
    at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'imapService' defined in URL [jar:file:/D:/Data/Dev/.m2/org/alfresco/alfresco-repository/5.1.2/alfresco-repository-5.1.2.jar!/alfresco/subsystems/imap/default/imap-server-context.xml]: Cannot resolve reference to bean 'attachmentsExtractor' while setting bean property 'attachmentsExtractor'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'attachmentsExtractor' defined in URL [jar:file:/D:/Data/Dev/.m2/org/alfresco/alfresco-repository/5.1.2/alfresco-repository-5.1.2.jar!/alfresco/subsystems/imap/default/imap-server-context.xml]: Invocation of init method failed; nested exception is org.alfresco.error.AlfrescoRuntimeException: 00270002 Read-Write transaction started within read-only transaction
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:334)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1419)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1160)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:191)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
    ... 74 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'attachmentsExtractor' defined in URL [jar:file:/D:/Data/Dev/.m2/org/alfresco/alfresco-repository/5.1.2/alfresco-repository-5.1.2.jar!/alfresco/subsystems/imap/default/imap-server-context.xml]: Invocation of init method failed; nested exception is org.alfresco.error.AlfrescoRuntimeException: 00270002 Read-Write transaction started within read-only transaction
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1514)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:191)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
    ... 84 more
Caused by: org.alfresco.error.AlfrescoRuntimeException: 00270002 Read-Write transaction started within read-only transaction
    at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:383)
    at org.alfresco.repo.imap.AttachmentsExtractor$1.doWork(AttachmentsExtractor.java:149)
    at org.alfresco.repo.imap.AttachmentsExtractor$1.doWork(AttachmentsExtractor.java:1)
    at org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(AuthenticationUtil.java:555)
    at org.alfresco.repo.imap.AttachmentsExtractor.init(AttachmentsExtractor.java:131)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1640)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1581)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1511)
    ... 91 more

I try to configure Imap service to my Alfresco global properties with no results.

this is the code that raiseup this exeption:

RetryingTransactionHelper txHelper = AcmTestUtils.getAcmSupport ().getTransactionService ().getRetryingTransactionHelper ();
        txHelper.doInTransaction (new RetryingTransactionCallback<Object> ()
        {
            public Object execute () throws Exception
            {
                JSONObject reqParam = getMultimediaRequestParam(theNodeRef);    
                PostRequest aPostReq1 = new PostRequest (WEBSCRIPT_BASE_URI, reqParam.toString (), "application/json");
                Response resp1 = sendRequest (aPostReq1, 200); // <---- Here the exeptions!!!!

                /* some stuffs */

return null;

}, false);

/* other stuffs */

I'm completely stuck with this problem, I hope you can help me.

bye

Titto

3 Replies
Highlighted
Master

Re: Read-Write transaction started within read-only transaction

You do not need to use the retryingTransactionHelper when you are using the unit test framework to call a web script. By doing so you are creating a read-only transaction and the web script then tries to create a nested write-transaction, which is not supported unless it is forced. You test should behave like any remote client and not try to deal with transaction handling.

Highlighted
Member II

Re: Read-Write transaction started within read-only transaction

Thank you so much for your response.

I move this code outside the transaction and I obtain this error:

org.alfresco.repo.security.authentication.AuthenticationException: 00310039 Unable to validate ticket

but the webscript dont require authentication! what's happen?

here the code of the webscript:

<webscript>
    <shortname>Save content from amadeus from textul and multimedia</shortname>
    <description>Save content from amadeus from textul and multimedia</description>
    <url>/acm/amadeusform-save</url>
    <authentication>none</authentication>
    <format default="json">argument</format>
    <transaction allow="readwrite" buffersize="0">required</transaction>
</webscript>

I've also add "ticket=......" to my URI but cannot validate the ticket

thank you

Highlighted
Master

Re: Read-Write transaction started within read-only transaction

You should not add the ticket to the URL if the web script does not require authentication. If you provide it, Alfresco will preemptively validate it. The definition on the web script only states that it does not require an authentication, but if an authentication is presented it will still use it - as long as it is valid.