You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by kenclark <ke...@snet.net> on 2008/09/22 05:53:55 UTC

Problem with node.checkin() in same transaction node was created

I am trying to create a node (nt:file), save its parent folder, and then
checkin the node.  When I do this, I receive a transaction error (see
below).  The node does get created, but is corrupt -- it is missing the
jcr:mimeType child node, at least.

If I leave out the checkin, everything works fine.

Here is the code snippet:

        Node fileNode = folderNode.addNode (filename, "nt:file");
        fileNode.addMixin("mix:versionable");
        fileNode.addMixin("mix:referenceable");
        fileNode.addMixin("kk:authored");
        fileNode.setProperty("kk:authorid", userId);
        fileNode.setProperty("kk:filename", filename);

        //create the mandatory child node - jcr:content
        FileInputStream fis = null;
        
        try
        {
            fis = new FileInputStream (file);
            Node resNode = fileNode.addNode ("jcr:content", "nt:resource");
            resNode.setProperty ("jcr:mimeType", getMimeType(file));
            resNode.setProperty ("jcr:encoding", encoding);
            resNode.setProperty ("jcr:data", fis);
            Calendar lastModified = Calendar.getInstance ();
            lastModified.setTimeInMillis (file.lastModified ());
            resNode.setProperty ("jcr:lastModified", lastModified);

            folderNode.save();
            fileNode.checkin();

            return fileNode;
        }
        finally
        {
            if (fis != null) fis.close();
        }

and here is the error:

23:46:24,250 WARN  [loggerI18N]
[com.arjuna.ats.internal.jta.resources.arjunacore.commitxaerror]
[com.arjuna.ats.internal.jta.resources.arju
nacore.commitxaerror] XAResourceRecord.commit - xa error
XAException.XA_RBOTHER
23:46:24,265 ERROR [SeamPhaseListener] uncaught exception
java.lang.IllegalStateException: Could not commit transaction
        at
org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:602)
        at
org.jboss.seam.jsf.SeamPhaseListener.handleTransactionsAfterPhase(SeamPhaseListener.java:330)
        at
org.jboss.seam.jsf.SeamPhaseListener.afterServletPhase(SeamPhaseListener.java:231)
        at
org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:182)
        at
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:280)
...
Caused by: javax.transaction.HeuristicMixedException
        at
com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1395)
        at
com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:135)
        at
com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:87)
        at
org.jboss.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:140)
        at
org.jboss.seam.transaction.UTTransaction.commit(UTTransaction.java:52)
        at
org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:592)
        ... 60 more

Thanks,
ken clark
-- 
View this message in context: http://www.nabble.com/Problem-with-node.checkin%28%29-in-same-transaction-node-was-created-tp19601525p19601525.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Re: Problem with node.checkin() in same transaction node was created

Posted by Alexander Klimetschek <ak...@day.com>.
On Mon, Sep 22, 2008 at 6:19 AM, kenclark <ke...@snet.net> wrote:
>        <PersistenceManager
> class="org.apache.jackrabbit.core.state.xml.XMLPersistenceManager" />

Please note that the XMLPersistenceManager is not recommended: it is
slow, unefficient and not transactional (it's purpose is debugging,
because you can look at the persisted node data easily, since it is
stored as XML files). You should use a DB-based PM, with Derby being
the most simple one. See
http://wiki.apache.org/jackrabbit/PersistenceManagerFAQ

Please note that you will have to create the workspaces from scratch
if you change the PM. You could also change them in the workspace.xml,
but they workspaces will be empty then, since they no longer access
the data of the old PM.

Regards,
Alex

-- 
Alexander Klimetschek
alexander.klimetschek@day.com

Re: Problem with node.checkin() in same transaction node was created

Posted by kenclark <ke...@snet.net>.
By the way, I am using the RAR deployment.

My repository.xml:

<?xml version="1.0" encoding="ISO-8859-1"?>
<Repository>
    <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
        
    </FileSystem>
    <Security appName="Jackrabbit">
        <AccessManager
class="org.apache.jackrabbit.core.security.SimpleAccessManager"/>
    </Security>
    <Workspaces rootPath="${rep.home}/workspaces" defaultWorkspace="default"
/>
    <Workspace name="${wsp.name}">
        <FileSystem
class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
            
        </FileSystem>
        <PersistenceManager
class="org.apache.jackrabbit.core.state.xml.XMLPersistenceManager" />
        <SearchIndex
class="org.apache.jackrabbit.core.query.lucene.SearchIndex">          
            
        </SearchIndex>
    </Workspace>
    <Versioning rootPath="${rep.home}/versions">
        <FileSystem
class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
            
        </FileSystem>
        <PersistenceManager
class="org.apache.jackrabbit.core.state.xml.XMLPersistenceManager" />
    </Versioning>
</Repository>

and bootstrap.properties:

repository.config=e:/jackrabbit/repository.xml
repository.home=e:/jackrabbit
repository.name=jackrabbit.repository
rmi.enabled=true
rmi.port=6776
rmi.host=localhost
jndi.enabled=true
jndi.name=jackrabbit
java.naming.provider.url=http://www.apache.org/jackrabbit
java.naming.factory.initial=org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory


-- 
View this message in context: http://www.nabble.com/Problem-with-node.checkin%28%29-in-same-transaction-node-was-created-tp19601525p19601692.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Re: Problem with node.checkin() in same transaction node was created

Posted by kenclark <ke...@snet.net>.
Well, two things:

1) The heuristic exception only occurred when I had the checkin() call in
the code.  If I took it out, I did not get the initial version, but
everything worked fine (no heuristic exception)

2) I did convert to an OraclePersistenceManager, and now the checkin() works
fine -- no heuristic exception and the end result is as I expect.  I do have
various other new issues that have come up after this conversion that I have
to track down, but I am (thankfully) past the heuristic exception problem.

Thanks for your assistance.

ken

Alexander Klimetschek wrote:
> 
> On Mon, Sep 22, 2008 at 10:40 PM, kenclark <ke...@snet.net> wrote:
>>
>> From the first link (http://markmail.org/message/2alwjclh6kecpbdn), there
>> is
>> this statement:
>>
>> "When you first create a node that is versionable and set properties on
>> it,
>> you call save on the node. Then the base version of the node has that
>> property value. "
>>
>> However, this is not what I see from the root version.  The root version
>> does have a jcr:frozenNode child, but that child does not have the
>> property
>> on it that I set on the versioned Node.
>>
>> After the root version, the property does show up on the frozenNode
>> child.
>>
>> Also, this conflicts with (if I understand them correctly) what Brett and
>> Julian are saying about the root version, which is really just a starting
>> point.
>>
>> Thus, there really is no "first version" created upon save of the
>> mix:versionable node, at least if what is meant by first version is the
>> initial copy of the node.  There has to be a checkin().  Or am I still
>> being
>> dense?
> 
> Sorry, the mail link was actually not a complete description ;-) It's
> true that there has to be a checkin(), so your code is correct.
> 
> Regarding the exception you get: it is interesting to see that there
> is no exception from jackrabbit or any jackrabbit class in the
> stacktrace. Maybe you omitted the bottom part of the stacktrace? AFAIK
> the xml pm, as it does no transactioning at all, could also never
> throw an exception if something fails during a transaction. In other
> words, it would not rollback the transaction if a file system write
> access or similar occurred. So I guess the exception you get
> (javax.transaction.HeuristicMixedException, which sounds weird, but I
> am not an expert in JTA) might have a different cause.
> 
> Regards,
> Alex
> 
> -- 
> Alexander Klimetschek
> alexander.klimetschek@day.com
> 
> 

-- 
View this message in context: http://www.nabble.com/Problem-with-node.checkin%28%29-in-same-transaction-node-was-created-tp19601525p19627001.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Re: Problem with node.checkin() in same transaction node was created

Posted by Alexander Klimetschek <ak...@day.com>.
On Mon, Sep 22, 2008 at 10:40 PM, kenclark <ke...@snet.net> wrote:
>
> From the first link (http://markmail.org/message/2alwjclh6kecpbdn), there is
> this statement:
>
> "When you first create a node that is versionable and set properties on it,
> you call save on the node. Then the base version of the node has that
> property value. "
>
> However, this is not what I see from the root version.  The root version
> does have a jcr:frozenNode child, but that child does not have the property
> on it that I set on the versioned Node.
>
> After the root version, the property does show up on the frozenNode child.
>
> Also, this conflicts with (if I understand them correctly) what Brett and
> Julian are saying about the root version, which is really just a starting
> point.
>
> Thus, there really is no "first version" created upon save of the
> mix:versionable node, at least if what is meant by first version is the
> initial copy of the node.  There has to be a checkin().  Or am I still being
> dense?

Sorry, the mail link was actually not a complete description ;-) It's
true that there has to be a checkin(), so your code is correct.

Regarding the exception you get: it is interesting to see that there
is no exception from jackrabbit or any jackrabbit class in the
stacktrace. Maybe you omitted the bottom part of the stacktrace? AFAIK
the xml pm, as it does no transactioning at all, could also never
throw an exception if something fails during a transaction. In other
words, it would not rollback the transaction if a file system write
access or similar occurred. So I guess the exception you get
(javax.transaction.HeuristicMixedException, which sounds weird, but I
am not an expert in JTA) might have a different cause.

Regards,
Alex

-- 
Alexander Klimetschek
alexander.klimetschek@day.com

Re: Jackrabbit OCM DTD

Posted by Christophe Lombart <ch...@gmail.com>.
not yet for  OCM 1.5



On Tue, Sep 23, 2008 at 15:04, Boni Gopalan (BioImagene) <
Boni.G@bioimagene.com> wrote:

> Is there a dtd for the bean mapping files available?  I am facing issues
> with Sun Xerces parser crying over unparsable files because it cannot
> find the corresponding xsd or dtd.  I looked through the trunk but could
> not find the dtd.  I am working on 1.5-SNAPSHOT
>
> Thanks
> Boni
>

Jackrabbit OCM DTD

Posted by "Boni Gopalan (BioImagene)" <Bo...@bioimagene.com>.
Is there a dtd for the bean mapping files available?  I am facing issues
with Sun Xerces parser crying over unparsable files because it cannot
find the corresponding xsd or dtd.  I looked through the trunk but could
not find the dtd.  I am working on 1.5-SNAPSHOT

Thanks
Boni

Re: Problem with node.checkin() in same transaction node was created

Posted by kenclark <ke...@snet.net>.
>From the first link (http://markmail.org/message/2alwjclh6kecpbdn), there is
this statement:

"When you first create a node that is versionable and set properties on it,
you call save on the node. Then the base version of the node has that
property value. "

However, this is not what I see from the root version.  The root version
does have a jcr:frozenNode child, but that child does not have the property
on it that I set on the versioned Node.

After the root version, the property does show up on the frozenNode child.

Also, this conflicts with (if I understand them correctly) what Brett and
Julian are saying about the root version, which is really just a starting
point.  

Thus, there really is no "first version" created upon save of the
mix:versionable node, at least if what is meant by first version is the
initial copy of the node.  There has to be a checkin().  Or am I still being
dense?

Thanks,
ken


Alexander Klimetschek wrote:
> 
> see my links
> 
> On Mon, Sep 22, 2008 at 6:45 PM, kenclark <ke...@snet.net> wrote:
>>
>> So then the correct way to handle adding the initial state of the nt:file
>> node is to do a checkin() immediately after the save, as I have in my
>> original code snippet?  (Or should I do a checkout() first even though
>> this
>> is a new node?)
> 

-- 
View this message in context: http://www.nabble.com/Problem-with-node.checkin%28%29-in-same-transaction-node-was-created-tp19601525p19616042.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Re: Problem with node.checkin() in same transaction node was created

Posted by Alexander Klimetschek <ak...@day.com>.
see my links

On Mon, Sep 22, 2008 at 6:45 PM, kenclark <ke...@snet.net> wrote:
>
> So then the correct way to handle adding the initial state of the nt:file
> node is to do a checkin() immediately after the save, as I have in my
> original code snippet?  (Or should I do a checkout() first even though this
> is a new node?)
>
> Thanks,
> ken
>
>
> Julian Reschke wrote:
>>
>> kenclark wrote:
>>>
>>> I reread the spec, and it is still not clear to me what exactly happens
>>> with
>>> the root version.  My assumption was that it is, like you say, exactly
>>> like
>>> any other version -- it should be a copy of the versioned node as of the
>>> time the version was created (i.e. the initial save of the node).
>>> ...
>>
>> No, the root version is special; it only acts as root node for the
>> version history (it's the predecessor of the first "real" version).
>>
>> BR, Julian
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Problem-with-node.checkin%28%29-in-same-transaction-node-was-created-tp19601525p19611941.html
> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>
>



-- 
Alexander Klimetschek
alexander.klimetschek@day.com

RE: Problem with node.checkin() in same transaction node was created

Posted by kenclark <ke...@snet.net>.
As for the error I am getting, Alex pointed out that the
XMLPersistenceManager is not recommended, and is not transactional (which I
can verify).  That seems to be what I need to revisit first.

Thanks,
ken


Connor, Brett (LNG-TWY) wrote:
> 
> You need checkin() for the first one, after the save(), without any
> checkout(). I don't know why you have the error you're getting, your
> original code snippet looked ok at a quick glance. Perhaps there is some
> other resource involved in the tx that's causing the problem?
> 
> 

-- 
View this message in context: http://www.nabble.com/Problem-with-node.checkin%28%29-in-same-transaction-node-was-created-tp19601525p19616044.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


RE: Problem with node.checkin() in same transaction node was created

Posted by "Connor, Brett (LNG-TWY)" <Br...@lexisnexis.co.uk>.
-----Original Message-----
From: Julian Reschke [mailto:julian.reschke@gmx.de] 
Sent: 22 September 2008 18:22
To: users@jackrabbit.apache.org
Subject: Re: Problem with node.checkin() in same transaction node was
created

> Connor, Brett (LNG-TWY) wrote:
> > You need checkin() for the first one, after the save(), without any 
> > checkout(). I don't know why you have the error you're getting, your

> > original code snippet looked ok at a quick glance. Perhaps there is 
> > some other resource involved in the tx that's causing the problem?
> > 
> > WRT root version, if you look at the UUIDs you find that the UUID of

> > the root version is the same as the first version following the 
> > successors
> 
> That sounds like a serious bug to me.
> 

Go darn it you're right, I am mis-reading my dump - it's not ordered and
I'm the jcr:predecessors property. Muppet.

 
> > chain. The root version is just a "symbolic link" to the first node,

> > if that makes sense.
> 
> I think that's misleading.
> 
> For instance, consider a linear version history, such as
> 
>    root -> 1 -> 2
> 
> You could delete version 1, and the result would be
> 
>    root -> 2

Then 2 in effect becomes the first node, so doesn't this still hold? I
haven't tried this, our system doesn't delete versions, but this is how
I'd expect it to work. Am I wrong?

REED ELSEVIER (UK) LIMITED - Registered office - 1-3 STRAND, LONDON WC2N 5JR
Registered in England - Company No. 02746621


Re: Problem with node.checkin() in same transaction node was created

Posted by Julian Reschke <ju...@gmx.de>.
Connor, Brett (LNG-TWY) wrote:
> You need checkin() for the first one, after the save(), without any
> checkout(). I don't know why you have the error you're getting, your
> original code snippet looked ok at a quick glance. Perhaps there is some
> other resource involved in the tx that's causing the problem?
> 
> WRT root version, if you look at the UUIDs you find that the UUID of the
> root version is the same as the first version following the successors

That sounds like a serious bug to me.

> chain. The root version is just a "symbolic link" to the first node, if
> that makes sense.

I think that's misleading.

For instance, consider a linear version history, such as

   root -> 1 -> 2

You could delete version 1, and the result would be

   root -> 2

BR, Julian

RE: Problem with node.checkin() in same transaction node was created

Posted by "Connor, Brett (LNG-TWY)" <Br...@lexisnexis.co.uk>.
You need checkin() for the first one, after the save(), without any
checkout(). I don't know why you have the error you're getting, your
original code snippet looked ok at a quick glance. Perhaps there is some
other resource involved in the tx that's causing the problem?

WRT root version, if you look at the UUIDs you find that the UUID of the
root version is the same as the first version following the successors
chain. The root version is just a "symbolic link" to the first node, if
that makes sense.


-----Original Message-----
From: kenclark [mailto:kenclark@snet.net] 
Sent: 22 September 2008 17:46
To: users@jackrabbit.apache.org
Subject: Re: Problem with node.checkin() in same transaction node was
created


So then the correct way to handle adding the initial state of the
nt:file node is to do a checkin() immediately after the save, as I have
in my original code snippet?  (Or should I do a checkout() first even
though this is a new node?)

Thanks,
ken


Julian Reschke wrote:
> 
> kenclark wrote:
>> 
>> I reread the spec, and it is still not clear to me what exactly 
>> happens with the root version.  My assumption was that it is, like 
>> you say, exactly like any other version -- it should be a copy of the

>> versioned node as of the time the version was created (i.e. the 
>> initial save of the node).
>> ...
> 
> No, the root version is special; it only acts as root node for the 
> version history (it's the predecessor of the first "real" version).
> 
> BR, Julian
> 
> 

--
View this message in context:
http://www.nabble.com/Problem-with-node.checkin%28%29-in-same-transactio
n-node-was-created-tp19601525p19611941.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


REED ELSEVIER (UK) LIMITED - Registered office - 1-3 STRAND, LONDON WC2N 5JR
Registered in England - Company No. 02746621


Re: Problem with node.checkin() in same transaction node was created

Posted by kenclark <ke...@snet.net>.
So then the correct way to handle adding the initial state of the nt:file
node is to do a checkin() immediately after the save, as I have in my
original code snippet?  (Or should I do a checkout() first even though this
is a new node?)

Thanks,
ken


Julian Reschke wrote:
> 
> kenclark wrote:
>> 
>> I reread the spec, and it is still not clear to me what exactly happens
>> with
>> the root version.  My assumption was that it is, like you say, exactly
>> like
>> any other version -- it should be a copy of the versioned node as of the
>> time the version was created (i.e. the initial save of the node).
>> ...
> 
> No, the root version is special; it only acts as root node for the 
> version history (it's the predecessor of the first "real" version).
> 
> BR, Julian
> 
> 

-- 
View this message in context: http://www.nabble.com/Problem-with-node.checkin%28%29-in-same-transaction-node-was-created-tp19601525p19611941.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Re: Problem with node.checkin() in same transaction node was created

Posted by Julian Reschke <ju...@gmx.de>.
kenclark wrote:
> 
> I reread the spec, and it is still not clear to me what exactly happens with
> the root version.  My assumption was that it is, like you say, exactly like
> any other version -- it should be a copy of the versioned node as of the
> time the version was created (i.e. the initial save of the node).
> ...

No, the root version is special; it only acts as root node for the 
version history (it's the predecessor of the first "real" version).

BR, Julian

Re: Problem with node.checkin() in same transaction node was created

Posted by kenclark <ke...@snet.net>.

I reread the spec, and it is still not clear to me what exactly happens with
the root version.  My assumption was that it is, like you say, exactly like
any other version -- it should be a copy of the versioned node as of the
time the version was created (i.e. the initial save of the node).

However, this is not what I am seeing, as I point out in the other post:

http://www.nabble.com/How-do-I-make-a-first-version-when-versioning--td19601595.html

Perhaps I am missing something when traversing the version tree -- I will
double check this.  

Thanks also for the heads up on the XMLPersistenceManager -- I will look
into switching to another PM.

Thanks,
ken




Alexander Klimetschek wrote:
> 
> The initial version of a node (when you add the mix:versionable) is
> created upon save(), there is no need to call checkin. See here
> http://markmail.org/message/2alwjclh6kecpbdn or have a look at section
> 8 of the JCR spec http://jcp.org/en/jsr/detail?id=170.
> 
> Regards,
> Alex
> 
> On Mon, Sep 22, 2008 at 5:53 AM, kenclark <ke...@snet.net> wrote:
>>
>> I am trying to create a node (nt:file), save its parent folder, and then
>> checkin the node.  When I do this, I receive a transaction error (see
>> below).  The node does get created, but is corrupt -- it is missing the
>> jcr:mimeType child node, at least.
>>
>> If I leave out the checkin, everything works fine.
>>
>> Here is the code snippet:
>>
>>        Node fileNode = folderNode.addNode (filename, "nt:file");
>>        fileNode.addMixin("mix:versionable");
>>        fileNode.addMixin("mix:referenceable");
>>        fileNode.addMixin("kk:authored");
>>        fileNode.setProperty("kk:authorid", userId);
>>        fileNode.setProperty("kk:filename", filename);
>>
>>        //create the mandatory child node - jcr:content
>>        FileInputStream fis = null;
>>
>>        try
>>        {
>>            fis = new FileInputStream (file);
>>            Node resNode = fileNode.addNode ("jcr:content",
>> "nt:resource");
>>            resNode.setProperty ("jcr:mimeType", getMimeType(file));
>>            resNode.setProperty ("jcr:encoding", encoding);
>>            resNode.setProperty ("jcr:data", fis);
>>            Calendar lastModified = Calendar.getInstance ();
>>            lastModified.setTimeInMillis (file.lastModified ());
>>            resNode.setProperty ("jcr:lastModified", lastModified);
>>
>>            folderNode.save();
>>            fileNode.checkin();
>>
>>            return fileNode;
>>        }
>>        finally
>>        {
>>            if (fis != null) fis.close();
>>        }
>>
>> and here is the error:
>>
>> 23:46:24,250 WARN  [loggerI18N]
>> [com.arjuna.ats.internal.jta.resources.arjunacore.commitxaerror]
>> [com.arjuna.ats.internal.jta.resources.arju
>> nacore.commitxaerror] XAResourceRecord.commit - xa error
>> XAException.XA_RBOTHER
>> 23:46:24,265 ERROR [SeamPhaseListener] uncaught exception
>> java.lang.IllegalStateException: Could not commit transaction
>>        at
>> org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:602)
>>        at
>> org.jboss.seam.jsf.SeamPhaseListener.handleTransactionsAfterPhase(SeamPhaseListener.java:330)
>>        at
>> org.jboss.seam.jsf.SeamPhaseListener.afterServletPhase(SeamPhaseListener.java:231)
>>        at
>> org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:182)
>>        at
>> com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:280)
>> ...
>> Caused by: javax.transaction.HeuristicMixedException
>>        at
>> com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1395)
>>        at
>> com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:135)
>>        at
>> com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:87)
>>        at
>> org.jboss.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:140)
>>        at
>> org.jboss.seam.transaction.UTTransaction.commit(UTTransaction.java:52)
>>        at
>> org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:592)
>>        ... 60 more
>>
>> Thanks,
>> ken clark
>> --
>> View this message in context:
>> http://www.nabble.com/Problem-with-node.checkin%28%29-in-same-transaction-node-was-created-tp19601525p19601525.html
>> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Alexander Klimetschek
> alexander.klimetschek@day.com
> 
> 

-- 
View this message in context: http://www.nabble.com/Problem-with-node.checkin%28%29-in-same-transaction-node-was-created-tp19601525p19608659.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Re: Problem with node.checkin() in same transaction node was created

Posted by Alexander Klimetschek <ak...@day.com>.
The initial version of a node (when you add the mix:versionable) is
created upon save(), there is no need to call checkin. See here
http://markmail.org/message/2alwjclh6kecpbdn or have a look at section
8 of the JCR spec http://jcp.org/en/jsr/detail?id=170.

Regards,
Alex

On Mon, Sep 22, 2008 at 5:53 AM, kenclark <ke...@snet.net> wrote:
>
> I am trying to create a node (nt:file), save its parent folder, and then
> checkin the node.  When I do this, I receive a transaction error (see
> below).  The node does get created, but is corrupt -- it is missing the
> jcr:mimeType child node, at least.
>
> If I leave out the checkin, everything works fine.
>
> Here is the code snippet:
>
>        Node fileNode = folderNode.addNode (filename, "nt:file");
>        fileNode.addMixin("mix:versionable");
>        fileNode.addMixin("mix:referenceable");
>        fileNode.addMixin("kk:authored");
>        fileNode.setProperty("kk:authorid", userId);
>        fileNode.setProperty("kk:filename", filename);
>
>        //create the mandatory child node - jcr:content
>        FileInputStream fis = null;
>
>        try
>        {
>            fis = new FileInputStream (file);
>            Node resNode = fileNode.addNode ("jcr:content", "nt:resource");
>            resNode.setProperty ("jcr:mimeType", getMimeType(file));
>            resNode.setProperty ("jcr:encoding", encoding);
>            resNode.setProperty ("jcr:data", fis);
>            Calendar lastModified = Calendar.getInstance ();
>            lastModified.setTimeInMillis (file.lastModified ());
>            resNode.setProperty ("jcr:lastModified", lastModified);
>
>            folderNode.save();
>            fileNode.checkin();
>
>            return fileNode;
>        }
>        finally
>        {
>            if (fis != null) fis.close();
>        }
>
> and here is the error:
>
> 23:46:24,250 WARN  [loggerI18N]
> [com.arjuna.ats.internal.jta.resources.arjunacore.commitxaerror]
> [com.arjuna.ats.internal.jta.resources.arju
> nacore.commitxaerror] XAResourceRecord.commit - xa error
> XAException.XA_RBOTHER
> 23:46:24,265 ERROR [SeamPhaseListener] uncaught exception
> java.lang.IllegalStateException: Could not commit transaction
>        at
> org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:602)
>        at
> org.jboss.seam.jsf.SeamPhaseListener.handleTransactionsAfterPhase(SeamPhaseListener.java:330)
>        at
> org.jboss.seam.jsf.SeamPhaseListener.afterServletPhase(SeamPhaseListener.java:231)
>        at
> org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:182)
>        at
> com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:280)
> ...
> Caused by: javax.transaction.HeuristicMixedException
>        at
> com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1395)
>        at
> com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:135)
>        at
> com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:87)
>        at
> org.jboss.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:140)
>        at
> org.jboss.seam.transaction.UTTransaction.commit(UTTransaction.java:52)
>        at
> org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:592)
>        ... 60 more
>
> Thanks,
> ken clark
> --
> View this message in context: http://www.nabble.com/Problem-with-node.checkin%28%29-in-same-transaction-node-was-created-tp19601525p19601525.html
> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>
>



-- 
Alexander Klimetschek
alexander.klimetschek@day.com