Hi,

I am experiencing problems with the import functionality of Jackrabbit.  It 
appears that the import mechanism fails when there are references to nodes that 
are marked as 'mandatory autocreated' in the CND file. I have written a small 
Java application (with a simple CND-file) that reproduces this problem. The 
ReferentialIntegrityException that is thrown states that the object being 
referenced does not exist, but it does exist in the XML being imported (The 
'missing' object is the mandatory autocreated object). Is this a bug, or is 
this particular configuration unsupported in Jackrabbit?

Environment:
Jackrabbit Core 1.4.6.
jdk1.6.0_07.
Fedora 9 Linux (also reproduced on Windows).
The repository configuration used by my test application uses 
org.apache.jackrabbit.core.fs.mem.MemoryFileSystem and 
org.apache.jackrabbit.core.persistence.mem.InMemPersistenceManager.


Stacktrace, cnd-file, and Java code are listed at the bottom of this e-mail.

Regards,
Audun

----------------------------------------
The exception I am getting is:
----------------------------------------

Exception in thread "main" java.lang.IllegalStateException: oops
        at 
com.corporater.test.JackrabbitImportTester.main(JackrabbitImportTester.java:79)
Caused by: javax.jcr.ReferentialIntegrityException: Target node 
4ac00d54-84c4-49bd-b2f9-cb3e790ce370 of REFERENCE property does not exist
        at 
org.apache.jackrabbit.core.state.SharedItemStateManager.checkReferentialIntegrity(SharedItemStateManager.java:1440)
        at 
org.apache.jackrabbit.core.state.SharedItemStateManager$Update.begin(SharedItemStateManager.java:557)
        at 
org.apache.jackrabbit.core.state.SharedItemStateManager.beginUpdate(SharedItemStateManager.java:843)
        at 
org.apache.jackrabbit.core.state.SharedItemStateManager.update(SharedItemStateManager.java:873)
        at 
org.apache.jackrabbit.core.state.LocalItemStateManager.update(LocalItemStateManager.java:334)
        at 
org.apache.jackrabbit.core.state.XAItemStateManager.update(XAItemStateManager.java:337)
        at 
org.apache.jackrabbit.core.state.LocalItemStateManager.update(LocalItemStateManager.java:310)
        at 
org.apache.jackrabbit.core.state.SessionItemStateManager.update(SessionItemStateManager.java:317)
        at org.apache.jackrabbit.core.ItemImpl.save(ItemImpl.java:1247)
        at org.apache.jackrabbit.core.SessionImpl.save(SessionImpl.java:897)
        at 
com.corporater.test.JackrabbitImportTester.main(JackrabbitImportTester.java:77)


----------------------------------------
My CND file is as follows:
----------------------------------------





[test:Container]> nt:base 
        + * (nt:base) multiple
        
[test:Child]> nt:base, mix:referenceable
        
[test:Parent]> nt:base
        + test:Test (test:Child) = test:Child mandatory autocreated
        
[test:Linked]> nt:base
        - test:linked (reference) mandatory


------------------------------------------------------------------------
The Java-code that reproduced the problem is as follows:
------------------------------------------------------------------------
                try {
                        Node container = 
session.getRootNode().addNode("container", "test:Container");
                        Node parentNode = container.addNode("Test", 
"test:Parent");
                        Node childNode = parentNode.getNode("test:Test");
                        Node linkedNode = container.addNode("Link", 
"test:Linked");
                        linkedNode.setProperty("test:linked", childNode);
                        session.save();
                        ByteArrayOutputStream bout = new 
ByteArrayOutputStream();
                        
session.exportSystemView(session.getRootNode().getNode("container").getPath(), 
bout, false, false);
                        bout.flush();
                        bout.close();
                        container.remove();
                        session.save();
                        session.importXML(session.getRootNode().getPath(), new 
ByteArrayInputStream(bout.toByteArray()), 
ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW);
                        // This save() call fails with a 
ReferentialIntegrityException
                        session.save();
                } catch (Exception e) {
                        throw new IllegalStateException("oops", e);
                }



_________________________________________________________________
News, entertainment and everything you care about at Live.com. Get it now!
http://www.live.com/getstarted.aspx

Reply via email to