jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pamarthi, Ramakrishna" <rk.pamar...@hp.com>
Subject javax.jcr.ReferentialIntegrityException - the node cannot be removed because it is still being referenced.
Date Tue, 18 Mar 2008 09:51:47 GMT
 Dear All,

We are getting the following error. Any idea?

at org.apache.catalina.core.StandardEngineValve.invoke(Unknown Source)
        at org.apache.catalina.connector.CoyoteAdapter.service(Unknown Source)
        at org.apache.jk.server.JkCoyoteHandler.invoke(Unknown Source)
        at org.apache.jk.common.HandlerRequest.invoke(Unknown Source)
        at org.apache.jk.common.ChannelSocket.invoke(Unknown Source)
        at org.apache.jk.common.ChannelSocket.processConnection(Unknown Source)
        at org.apache.jk.common.SocketConnection.runIt(Unknown Source)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(Unknown Source)
        at java.lang.Thread.run(Thread.java:595)
Caused by: com.hp.ocs.content.InvalidContentException: Cannot save the node [id=?none(node
not saved yet)?, path=/ocs:repository/ocs:content/it_VA/newsTopic].
        at com.hp.ocs.content.NodeManager.handleRepositoryException(NodeManager.java:931)
        at com.hp.ocs.content.NodeManager.saveNode(NodeManager.java:60)
        at com.hp.ocs.content.ContentBase.remove(ContentBase.java:182)
        ... 41 more
Caused by: javax.jcr.ReferentialIntegrityException: e913439f-60a3-40cb-bc4d-b4fec3c25156:
the node cannot be removed because it is still being referenced.
        at org.apache.jackrabbit.core.state.SharedItemStateManager.checkReferentialIntegrity(SharedItemStateManager.java:1400)
        at org.apache.jackrabbit.core.state.SharedItemStateManager$Update.begin(SharedItemStateManager.java:556)
        at org.apache.jackrabbit.core.state.SharedItemStateManager.beginUpdate(SharedItemStateManager.java:825)
        at org.apache.jackrabbit.core.state.SharedItemStateManager.update(SharedItemStateManager.java:855)
        at org.apache.jackrabbit.core.state.LocalItemStateManager.update(LocalItemStateManager.java:326)
        at org.apache.jackrabbit.core.state.XAItemStateManager.update(XAItemStateManager.java:313)
        at org.apache.jackrabbit.core.state.LocalItemStateManager.update(LocalItemStateManager.java:302)
        at org.apache.jackrabbit.core.state.SessionItemStateManager.update(SessionItemStateManager.java:306)
        at org.apache.jackrabbit.core.ItemImpl.save(ItemImpl.java:1240)
        at com.hp.ocs.content.NodeManager.saveNode(NodeManager.java:55)


Here are the functions:

public void remove() throws InvalidContentException     {
                try {
                        Node parentNode = NodeManager.getParentNode(node);
                        NodeManager.removeNode(node);
                        NodeManager.saveNode(parentNode);
                } catch (InvalidContentException e) {
            throw new InvalidContentException(MessageFormat.format(
                    "Cannot remove the node",
                    new Object[] { node }), e);
                }
        }

public static void removeNode(Node node) throws InvalidContentException {
                try {
                        synchronized (ContentUtils.JCR_WRITE_LOCK) {
                                removeReferences(node);
                                node.remove();
                        }
                } catch (RepositoryException e) {
                        Object[] params = {toString(node)};
                        String msg = MessageFormat
                                        .format("Cannot remove node {0}.", params);
                        handleRepositoryException(msg, e, true);
                }
        }

        private static void removeReferences(Node node)
                        throws InvalidContentException, RepositoryException {
                PropertyIterator iter = node.getReferences();
                String uuid = node.getUUID();
                while (iter.hasNext()) {
                        Property ref = iter.nextProperty();
                        Value[] values = ref.getValues();
                        for (int i = 0; i < values.length; i++) {
                                if (StringUtils.equals(uuid, values[i].getString())) {
                                        values[i] = null;
                                }
                        }
                        Node parent = ref.getParent();
                        setValues(parent, ref.getName(), values);
                        saveNode(parent);
                }
        }


Best Regards,
RK

Mime
View raw message