jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From SalmasCM <sal...@criticalmass.com>
Subject Re: modified externally: node / when deleting node
Date Mon, 04 May 2009 15:04:43 GMT

I am not convinced that this is a JackRabbit bug. It could well be but it's
more likely an issue in my application code. I believe it has to do with
concurrency and my using 2 sessions simultaneously. I believe that something
screws up with consurrency before I exit and then when I restart my server
everything is screwed up. I am going to try limiting things to one thread
per session by synchronizing on the same object whenever I do something in
preview and then having a second object that I synchronize whenever I do
something in the default workspace. I will let you know if this solves
things.
However, I do think that it would be nice to have documentation about
concurrency and how to do things in an application server environment.We use
BEA Weblogic which spawns a bunch of threads and so its probably more
challenging using Jackrabbit in this environment. 

Thanks so much for getting back to me. I have been struggling with this and
really need to get it working asap.

Regards


Stefan Guggisberg wrote:
> 
> On Sun, May 3, 2009 at 5:36 AM, SalmasCM <salmas@criticalmass.com> wrote:
>>
>> I have been trying for weeks to get things working in my application and
>> am
>> not making any progress.
>> I don't believe my use case is very unusual and I am hoping that you will
>> be
>> able to help me.
>>
>> 1. I have a lot of legacy data that I load in using the XML import
>> feature.
>> Each section is loaded under it's own top level node. The top level nodes
>> live directly under root.
>> 2. I have 2 workspaces , preview and default. Changes and data loads
>> happen
>> in preview and are cloned/merged into default.
>>
>> Everything works if I bulk load the data with the XML import once but
>> falls
>> apart if I load a all the sections into preview and then clone to default
>> and then later wish to reload a node with the XML import.
>>
>> I am unable to reload since it thinks it's a new node so if I reload for
>> example employees then it creates employees[1] which is not what I want.
>>
>> I have then 2 options.
>> 1. to force it to recognize the top node as the same node as previously
>> loaded, to do this I would have to indicate the UUID for the top node.
>> However, I have no idea how to make the UUID in the XML data file the
>> same
>> as it would create when reloading?
>> 2. So I tried to delete the node from both preview and default workspaces
>> before loading. I ran into many issues and finally succeeded in reloading
>> the data. However, I ran into issues when I modify any data in preview.
>>
>> I get
>>
>> Item cannot be saved because it has been modified externally: node /
>> javax.jcr.InvalidItemStateException: Item cannot be saved because it has
>> been modified externally: node /
>>
>> This is the sequence of events.
>>
>> 1.  load data using the XML loading under topNodeA in preview workspace
>> 2. I modify some of the data under topNodeA in preview workspace.
>> 3. I save the session etc.
>> 4. I clone the topNodeA and its subtree to the default space.
>> 4. I stop my application server and restart.
>> 5. I get a new session into the preview workspace
>> 6. I try to delete topNodeA in the preview workspace and then I get the
>> above error.
> 
> without having seen your code i really can't tell but there might be a
> problem in your application logic. when you do restart and connect
> to the repository (assuming there isn't any other session interfering),
> i can't think of any way how this exception could be triggered.
> 
> please provide a simple complete test case and your exact
> configuration/setup and i'll have a look what's going wrong.
> 
> cheers
> stefan
> 
>>
>> However, I do NOT receive this error when I do the following (do not get
>> out
>> of the existing session for that workspace and then subsequently get a
>> new
>> one but instead remain in the same session for the delete)
>>
>> 1.  load data using the XML loading under topNodeA in preview workspace
>> 2. I modify some of the data under topNodeA in preview workspace.
>> 3. I save the session etc.
>> 4. I clone the topNodeA and its subtree to the default space.
>> 5. I try to delete topNodeA in the preview workspace and then I DO NOT
>> get
>> the above error.
>>
>> I lock the node while making changes like so:
>>
>>    /**
>>     *
>>     * @param nodeToSet
>>     *            The node in which to set the property.
>>     * @param attribute
>>     * @param value
>>     */
>>    public static boolean saveAttribute(Node nodeToSet, String attribute,
>> Object value) {
>>        boolean success = false;
>>        if ((nodeToSet != null) && (attribute != null) && (value
!= null))
>> {
>>            try {
>>                synchronized (nodeToSet) {
>>                    boolean iLockedThis=false;
>>                    if (!nodeToSet.isLocked()) {
>>                        nodeToSet.addMixin("mix:lockable");
>>                        session.save();
>>                        nodeToSet.lock(true, true);
>>                        iLockedThis=true;
>>                    }
>>                    if (value instanceof InputStream) {
>>                        nodeToSet.setProperty(attribute, (InputStream)
>> value);
>>                        try {
>>                            ((InputStream) value).close();
>>                        } catch (IOException e) {
>>                            getInstance().logger.error("IOException
>> in:saveAttribute " + e);
>>                        }
>>                        success = true;
>>                    } else if (value instanceof Calendar) {
>>                        nodeToSet.setProperty(attribute, (Calendar)
>> value);
>>                        success = true;
>>                    } else if (value instanceof String) {
>>                        String stringToSet = (String) value;
>>                        nodeToSet.setProperty(attribute, stringToSet);
>>                        success = true;
>>                    } else if (value instanceof Long) {
>>                        nodeToSet.setProperty(attribute, ((Long)
>> value).longValue());
>>                        success = true;
>>                    } else if (value instanceof Integer) {
>>                        nodeToSet.setProperty(attribute, ((Integer)
>> value).longValue());
>>                        success = true;
>>                    } else if (value instanceof Double) {
>>                        nodeToSet.setProperty(attribute, ((Double)
>> value).doubleValue());
>>                        success = true;
>>                    } else if (value instanceof Boolean) {
>>                        nodeToSet.setProperty(attribute, ((Boolean)
>> value).booleanValue());
>>                        success = true;
>>                    }
>>                    if (iLockedThis) {
>>                        session.save();
>>                        nodeToSet.unlock();
>>                    }
>>                }
>>            } catch (final javax.jcr.ValueFormatException e) {
>>                getInstance().logger.error("ValueFormatException
>> in:saveAttribute " + e);
>>            } catch (final javax.jcr.version.VersionException e) {
>>                getInstance().logger.error("VersionException
>> in:saveAttribute " + e);
>>            } catch (final javax.jcr.lock.LockException e) {
>>                getInstance().logger.error("LockException in:saveAttribute
>> "
>> + e);
>>            } catch (final javax.jcr.nodetype.ConstraintViolationException
>> e) {
>>
>> getInstance().logger.error("javax.jcr.nodetype.ConstraintViolationException
>> in:saveAttribute " + e);
>>            } catch (final javax.jcr.RepositoryException e) {
>>                getInstance().logger.error("RepositoryException
>> in:saveAttribute " + e);
>>            }
>>        }
>>        return success;
>>    }
>> --
>> View this message in context:
>> http://www.nabble.com/modified-externally%3A-node---when-deleting-node-tp23352361p23352361.html
>> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/modified-externally%3A-node---when-deleting-node-tp23352361p23370294.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Mime
View raw message