jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Norbert Dreisiebner" <norbert.dreisieb...@hms.org>
Subject AW: Transaction over multiple workspaces?
Date Wed, 07 Nov 2007 15:59:09 GMT
Hi,

I also have to work with multiple workspaces within a single - container managed - transaction,
and basically it works the way Jan described it. 


I tried the whole thing with the following code:

// 1. get jcr sessions
Session sWS1 = repository.login(credentials, "ws1");
Session sWS2 = repository.login(credentials, "ws2");

// 2. do something useful =)
sWS1.getRootNode().addNode("ws1_test_node", "nt:unstructured");
sWS2.getRootNode().addNode("ws2_test_node", "nt:unstructured");

// 3. save changes
sWS1.save();
sWS2.save();

// 4. close connections
sWS1.logout();
sWS2.logout();


When running this code the first time everything seems to run smoothly:

16:09:51,012 INFO  [jcr/local] Created session (org.apache.jackrabbit.core.XASessionImpl@395294)
16:09:51,028 INFO  [jcr/local] Created session (org.apache.jackrabbit.core.XASessionImpl@b58796)


However, every following invocation produces this warning:

16:10:07,610 WARN  [JBossManagedConnectionPool] Destroying connection that could not be successfully
matched: org.jboss.resource.connectionmanager.TxC
onnectionManager$TxConnectionEventListener@1d89cb4[state=NORMAL mc=org.apache.jackrabbit.jca.JCAManagedConnection@16020ed
handles=0 lastUse=1194448191
074 permit=false trackByTx=false mcp=org.jboss.resource.connectionmanager.JBossManagedConnectionPool$OnePool@11cc36
context=org.jboss.resource.connect
ionmanager.InternalManagedConnectionPool@762acf xaResource=org.jboss.resource.connectionmanager.xa.JcaXAResourceWrapper@181a7a
txSync=null]
16:10:07,625 INFO  [jcr/local] Created session (org.apache.jackrabbit.core.XASessionImpl@fe4dd2)


Maybe some of you can give me a hint what this warning means and how i should handle it =)


Following you may find my jcr-ds.xml:

<connection-factories> 
    <tx-connection-factory>
		<jndi-name>jcr/local</jndi-name> 
		<xa-transaction/>
		<rar-name>jackrabbit-jca-1.3.3.rar</rar-name>
		<connection-definition>javax.jcr.Repository</connection-definition>
		<config-property name="homeDir" type="java.lang.String">C:\temp\jackrabbit</config-property>
		<config-property name="configFile" type="java.lang.String">C:\temp\jackrabbit\repository.xml</config-property>
		<config-property name="bindSessionToTransaction" type="java.lang.Boolean">true</config-property>
    </tx-connection-factory>
</connection-factories>


Thank you,
Norbert

-----Urspr√ľngliche Nachricht-----
Von: Jan Grathwohl [mailto:jan.grathwohl@kontrast.de] 
Gesendet: Montag, 10. September 2007 17:02
An: Dominique Pfister
Cc: Jackrabbit Users List List
Betreff: Re: Transaction over multiple workspaces?

Hi Dominique,

I have removed the <track-connection-by-tx/> from my jcr-dsl.xml, and  
now I can run it without the exception, and everyting works  
correctly. It doesn't seem to cause any other problems either, so it  
looks I really don't need this option.

Thank you very much for your help.

Jan



Am 05.09.2007 um 11:18 schrieb Dominique Pfister:

> Hi Jan,
>
> I received your attachments, deployed them in a fresh JBoss server
> configuration and got the same "IllegalStateException" you've
> experienced. I then removed the following line inside the jcr-ds.xml:
>
> <track-connection-by-tx/>
>
> and set the config property "bindSessionToTransaction" to "true" and
> it works. Is there some reason for including "track-connection-by-tx",
> apart from working around JCR-1109? I still have to figure out what
> this setting changes in the way Jackrabbit's JCA is used by JBoss...
>
> Kind regards
> Dominique
>
> On 04/09/07, Jan Grathwohl <jan.grathwohl@kontrast.de> wrote:
>>
>> Hi Dominique,
>>
>> since it seems to be a problem with my setup, I have experimented  
>> with my
>> configuration, and removed all of my own customizations, but I  
>> always get
>> the Exception "Inactive logical session handle called" when I try  
>> to execute
>> the JSP.
>>
>> I can reproduce the error with the following steps:
>>
>> 1. Download a fresh copy of JBoss 4.0.5 GA (or 4.2.1) and extract the
>> archive
>>
>>  2. Download the Jackrabbit JCA adapter rar as a binary from
>> http://jackrabbit.apache.org/downloads.cgi
>>
>> 3. Put the rar, the jcr-ds.xml and the web app war with the test  
>> jsp in
>> server/default/deploy
>>
>> 4. Start JBoss
>>
>> 5. Calling http://localhost:8080/TransactionsTest/test.jsp
>> causes the exception
>>
>>
>> Am I missing something here? I have to admit that my knowledge of  
>> JBoss
>> configuration options is limited....
>>
>> The content of my jcr-dsl.xml is
>>
>> <connection-factories>
>>     <tx-connection-factory>
>>  <jndi-name>jcr/local</jndi-name>
>>  <xa-transaction/>
>>  <rar-name>jackrabbit-jca-1.3.1.rar</rar-name>
>>  <track-connection-by-tx/>
>>  <connection-definition>javax.jcr.Repository</connection-definition>
>>  <config-property name="homeDir"
>> type="java.lang.String">/temp/jackrabbit2</config-property>
>>  <config-property name="configFile"
>> type="java.lang.String">classpath:repository.xml</config-property>
>>  <config-property name="bindSessionToTransaction"
>> type="java.lang.Boolean">false</config-property>
>>     </tx-connection-factory>
>> </connection-factories>
>>
>> I can't send my test application because the Apache mailings list  
>> server
>> rejects it as spam, but it didn't really contain more than the jsp  
>> page
>> anyway.
>>
>>
>> Thank you very much for your support.
>>
>> Jan
>>
>>
>>
>>
>> Am 04.09.2007 um 13:53 schrieb Dominique Pfister:
>>
>>
>> Hi Jan,
>>
>> I have a JBoss 4.0.5.GA installation with Jackrabbit JCA 1.3.1
>> deployed in it. I created a small web application containing the
>> following JSP code:
>>
>> <%@page import="javax.jcr.*"%>
>> <%@page import="javax.naming.InitialContext"%>
>> <%@page import="javax.transaction.UserTransaction"%>
>> <%
>> InitialContext ctx = new InitialContext();
>>
>> UserTransaction utx =
>> (UserTransaction)ctx.lookup("java:comp/UserTransaction");
>> utx.begin();
>>
>> Repository repo = (Repository)ctx.lookup("java:jcr/local");
>> Session session1 = repo.login(new SimpleCredentials("admin",
>> "admin".toCharArray()), "workspace1");
>> Session session2 = repo.login(new SimpleCredentials("admin",
>> "admin".toCharArray()), "workspace2");
>>
>> Node rootNode1 = session1.getRootNode();
>> %>Workspace1: <%= rootNode1.getNodes().getSize() %> nodes<br>
>> <%
>> rootNode1.addNode("a");
>> Node rootNode2 = session2.getRootNode();
>> %>Workspace2: <%= rootNode2.getNodes().getSize() %> nodes<br>
>> <%
>> rootNode2.addNode("b");
>>
>> session1.save();
>> session2.save();
>>
>> utx.commit();
>> %>
>>
>> Works as expected, incrementing the root node's children count on
>> every request. Can you tell me how you access the resource adapter
>> from within your client code? Any relevant, customized configuration
>> (ra.xml, repository.xml and the like) might be helpful, too...
>>
>> Kind regards
>> Dominique
>>
>>
>> On 04/09/07, Jan Grathwohl <jan.grathwohl@kontrast.de> wrote:
>> Hi Dominique,
>>
>> the session that was opened first cannot be accessed at all, the
>> three lines
>>
>> Session session1 = repo.login(new SimpleCredentials("admin",
>> "admin".toCharArray()), "default");
>> Session session2 = repo.login(new SimpleCredentials("admin",
>> "admin".toCharArray()), "ws2");
>> Node rootNode1 = session1.getRootNode();
>>
>> already cause an error:
>>
>> 12:39:25,720 ERROR [STDERR] java.lang.IllegalStateException: Inactive
>> logical session handle called
>> 12:39:25,720 ERROR [STDERR]     at
>> org.apache.jackrabbit.jca.JCAManagedConnection.getSession
>> (JCAManagedConnection.java:227)
>> 12:39:25,720 ERROR [STDERR]     at
>> org.apache.jackrabbit.jca.JCASessionHandle.getSession
>> (JCASessionHandle.java:84)
>> 12:39:25,720 ERROR [STDERR]     at
>> org.apache.jackrabbit.jca.JCASessionHandle.getRootNode
>> (JCASessionHandle.java:135)
>> 12:39:25,720 ERROR [STDERR]     at jbosstest.Servlet6.doGet
>> (Servlet6.java:55)
>> 12:39:25,720 ERROR [STDERR]     at
>> javax.servlet.http.HttpServlet.service
>> (HttpServlet.java:690)
>> 12:39:25,720 ERROR [STDERR]     at
>> javax.servlet.http.HttpServlet.service
>> (HttpServlet.java:803)
>> 12:39:25,720 ERROR [STDERR]     at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
>> (ApplicationFilterChain.java:290)
>> 12:39:25,720 ERROR [STDERR]     at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter
>> (ApplicationFilterChain.java:206)
>> 12:39:25,720 ERROR [STDERR]     at
>> org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter
>> (ReplyHeaderFilter.java:96)
>> 12:39:25,721 ERROR [STDERR]     at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
>> (ApplicationFilterChain.java:235)
>> 12:39:25,721 ERROR [STDERR]     at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter
>> (ApplicationFilterChain.java:206)
>> 12:39:25,721 ERROR [STDERR]     at
>> org.apache.catalina.core.StandardWrapperValve.invoke
>> (StandardWrapperValve.java:230)
>> 12:39:25,721 ERROR [STDERR]     at
>> org.apache.catalina.core.StandardContextValve.invoke
>> (StandardContextValve.java:175)
>> 12:39:25,721 ERROR [STDERR]     at
>> org.jboss.web.tomcat.security.SecurityAssociationValve.invoke
>> (SecurityAssociationValve.java:179)
>> 12:39:25,721 ERROR [STDERR]     at
>> org.jboss.web.tomcat.security.JaccContextValve.invoke
>> (JaccContextValve.java:84)
>> 12:39:25,721 ERROR [STDERR]     at
>> org.apache.catalina.core.StandardHostValve.invoke
>> (StandardHostValve.java:128)
>> 12:39:25,721 ERROR [STDERR]     at
>> org.apache.catalina.valves.ErrorReportValve.invoke
>> (ErrorReportValve.java:104)
>> 12:39:25,721 ERROR [STDERR]     at
>> org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke
>> (CachedConnectionValve.java:157)
>> 12:39:25,721 ERROR [STDERR]     at
>> org.apache.catalina.core.StandardEngineValve.invoke
>> (StandardEngineValve.java:109)
>> 12:39:25,721 ERROR [STDERR]     at
>> org.apache.catalina.connector.CoyoteAdapter.service
>> (CoyoteAdapter.java:241)
>> 12:39:25,721 ERROR [STDERR]     at
>> org.apache.coyote.http11.Http11Processor.process 
>> (Http11Processor.java:
>> 844)
>> 12:39:25,721 ERROR [STDERR]     at
>> org.apache.coyote.http11.Http11Protocol
>> $Http11ConnectionHandler.process(Http11Protocol.java:580)
>> 12:39:25,721 ERROR [STDERR]     at
>> org.apache.tomcat.util.net.JIoEndpoint
>> $Worker.run(JIoEndpoint.java:447)
>>
>> The second session can still be accessed, but if I do
>>
>> Session session1 = repo.login(new SimpleCredentials("admin",
>> "admin".toCharArray()), "default");
>> Session session2 = repo.login(new SimpleCredentials("admin",
>> "admin".toCharArray()), "ws2");
>> session2.getRootNode().addNode(nodeName2);
>> session2.save();
>> utx.commit();
>>
>> it finishes quietly without any error message, but the new node is
>> not saved to the database for the workspace (MySQL with the Bundle
>> persistence manager). If I only comment out the first line that opens
>> session1, the new node is added to the database.
>>
>>
>> Jan
>>
>>
>>
>> Am 04.09.2007 um 11:47 schrieb Dominique Pfister:
>>
>>
>> Hi Jan,
>>
>> can you tell me, what happens when you commit your user transaction?
>> Is there an exception or a timeout or...
>>
>> Kind regards
>> Dominique
>>
>> On 04/09/07, Jan Grathwohl <jan.grathwohl@kontrast.de> wrote:
>> Hi,
>>
>> is it possible in Jackrabbit to have a transaction that spans
>> multiple workspaces? What I would like to do is to start a
>> UserTransaction, write changes to several Jackrabbit workspaces (all
>> from the same repository) and a Hibernate session, and then commit
>> all these changes together. My application modifies several
>> workspaces concurrently, and I would like to ensure that all these
>> changes are either commited or rolled back completely.
>>
>> I have set up a JCA deployment of Jackrabbit 1.3.1 in JBoss , and it
>> works fine as long as I only use one session per transaction. It
>> looks from my tests like it is not possible to open more than one
>> session within a transaction, and I also found a thread on the
>> mailing list that says something like that.
>>
>>
>>
>>
>>
>>
>>
>> But if I want to work in multiple workspaces, I have to open multiple
>> sessions, because session are always per-workspace, right?
>>
>> So my code to edit multiple workspaces within one transaction
>> would be
>>
>>                 InitialContext ctx = new InitialContext();
>>
>>                 UserTransaction utx = (UserTransaction)ctx.lookup
>> ("java:comp/
>> UserTransaction");
>>                 utx.begin();
>>
>>                 Repository repo =
>> (Repository)ctx.lookup("java:jcr/
>> local");
>>                 Session session1 = repo.login(new SimpleCredentials
>> ("admin",
>> "admin".toCharArray()), "workspace1");
>>                 Session session2 = repo.login(new SimpleCredentials
>> ("admin",
>> "admin".toCharArray()), "workspace2");
>>
>>                 // Use session1 to write changes to workspace1
>>
>>                 // Use session2 to write changes to workspace2
>>
>>                 session1.save();
>>                 session2.save();
>>
>>                 utx.commit();
>>
>> which doesn't work.
>>
>> Is there any way to include multiple workspaces within the scope of
>> one transaction?
>>
>>
>> Thank you.
>>
>> Jan
>>
>>
>>
>>
>>
>>
>>


No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.485 / Virus Database: 269.13.14/999 - Release Date: 10.09.2007 17:43
 

No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.503 / Virus Database: 269.15.23/1114 - Release Date: 06.11.2007 20:05
 

Mime
View raw message