jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Edgar Merino <donvo...@gmail.com>
Subject OCM: Adding nodes externally (directly using the session)
Date Fri, 01 May 2009 00:32:00 GMT
Hello,

    This is the scenario: I've got an OCM entity (wrapping a node, path 
"/myNode"), I'm adding some resources (images) to the node using the jcr 
Session directly (code below), however when I try to persist changes 
(either using Session#save() or ObjectContentManager#save()) I get: 
javax.jcr.RepositoryException: /: unable to update item.: failed to 
write bundle: 9d42543e-87df-4b0e-82cf-a580e9922fa8. I need to add a list 
of images (nt:file nodes) to myNode, I cannot use OCM's default mapping 
of InputStream as a field in the mapped node, because I need all the 
properties to be Serializable (and InputStream is not Serializable).

    Are you able to see what am I doing wrong? thanks in advance,

Edgar Merino

<!-- CODE THAT GENERATES THE EXCEPTION -->


ObjectContentManager manager = ...; //retrieve manager
OCMNode myOCMNode = new OCMNode();
// ... fill properties ...
manager.insert(myOCMNode);

//obtain the session from the ObjectContentManager

Session session = manager.getSession();
Node entryNode = session.getRootNode().getNode("myNode");
Node fileNode = entryNode.addNode(fileName, "nt:file");
Node imageNode = fileNode.addNode("jcr:content", "nt:resource");
imageNode.setProperty("jcr:mimeType", mimeType);
imageNode.setProperty("jcr:encoding", "");
imageNode.setProperty("jcr:data", new FileInputStream(tmpFile));
Calendar lastModified = Calendar.getInstance();
lastModified.setTimeInMillis(tmpFile.lastModified());
imageNode.setProperty("jcr:lastModified", lastModified);   

session.save(); //or manager.save();







<!-- FULL STACK TRACE -->


javax.jcr.RepositoryException: /: unable to update item.: failed to 
write bundle: 9d42543e-87df-4b0e-82cf-a580e9922fa8
javax.jcr.RepositoryException: /: unable to update item.: failed to 
write bundle: 9d42543e-87df-4b0e-82cf-a580e9922fa8: failed to write 
bundle: 9d42543e-87df-4b0e-82cf-a580e9922fa8
        at org.apache.jackrabbit.core.ItemImpl.save(ItemImpl.java:1255)
        at org.apache.jackrabbit.core.SessionImpl.save(SessionImpl.java:897)
        at 
org.apache.jackrabbit.ocm.manager.impl.ObjectContentManagerImpl.save(ObjectContentManagerImpl.java:1068)
        at 
org.devpower.jcr.ocm.manager.OCMObjectManager.save(OCMObjectManager.java:72)
        at 
org.devpower.persistence.jcr.ObjectManagedJcrGenericDAO.flush(ObjectManagedJcrGenericDAO.java:95)
        at 
org.devpower.wicket.cms.widget.text.blog.JcrBlogManager.submitEntryImages(JcrBlogManager.java:114)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at 
org.apache.wicket.proxy.LazyInitProxyFactory$JdkHandler.invoke(LazyInitProxyFactory.java:416)
        at org.apache.wicket.proxy.$Proxy10.submitEntryImages(Unknown 
Source)
        at 
org.devpower.wicket.cms.widget.text.blog.EntryEditorPanel$EditorForm.saveEntry(EntryEditorPanel.java:181)
        at 
org.devpower.wicket.cms.widget.text.blog.EntryEditorPanel$EditorForm.onSubmit(EntryEditorPanel.java:110)
        at 
org.apache.wicket.markup.html.form.Form.delegateSubmit(Form.java:1355)
        at 
org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:810)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at 
org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:183)
        at 
org.apache.wicket.request.target.component.listener.ListenerInterfaceRequestTarget.processEvents(ListenerInterfaceRequestTarget.java:73)
        at 
org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:91)
        at 
org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1175)
        at org.apache.wicket.RequestCycle.step(RequestCycle.java:1252)
        at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1353)
        at org.apache.wicket.RequestCycle.request(RequestCycle.java:493)
        at 
org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:355)
        at 
org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:200)
        at 
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1139)
        at 
org.devpower.jcr.j2ee.filter.SessionPerRequestFilter.doFilter(SessionPerRequestFilter.java:32)
        at 
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1139)
        at 
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:378)
        at 
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
        at 
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
        at 
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
        at 
org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:417)
        at 
org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
        at 
org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
        at 
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
        at org.mortbay.jetty.Server.handle(Server.java:324)
        at 
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535)
        at 
org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:880)
        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:747)
        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
        at 
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
        at 
org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
Caused by: org.apache.jackrabbit.core.state.ItemStateException: failed 
to write bundle: 9d42543e-87df-4b0e-82cf-a580e9922fa8
        at 
org.apache.jackrabbit.core.persistence.bundle.BundleDbPersistenceManager.store(BundleDbPersistenceManager.java:546)
        at 
org.apache.jackrabbit.core.state.SharedItemStateManager$Update.end(SharedItemStateManager.java:704)
        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)
        ... 47 more
org.apache.jackrabbit.core.state.ItemStateException: failed to write 
bundle: 9d42543e-87df-4b0e-82cf-a580e9922fa8
        at 
org.apache.jackrabbit.core.persistence.bundle.BundleDbPersistenceManager.store(BundleDbPersistenceManager.java:546)
        at 
org.apache.jackrabbit.core.state.SharedItemStateManager$Update.end(SharedItemStateManager.java:704)
        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 
org.apache.jackrabbit.ocm.manager.impl.ObjectContentManagerImpl.save(ObjectContentManagerImpl.java:1068)
        at 
org.devpower.jcr.ocm.manager.OCMObjectManager.save(OCMObjectManager.java:72)
        at 
org.devpower.persistence.jcr.ObjectManagedJcrGenericDAO.flush(ObjectManagedJcrGenericDAO.java:95)
        at 
org.devpower.wicket.cms.widget.text.blog.JcrBlogManager.submitEntryImages(JcrBlogManager.java:114)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at 
org.apache.wicket.proxy.LazyInitProxyFactory$JdkHandler.invoke(LazyInitProxyFactory.java:416)
        at org.apache.wicket.proxy.$Proxy10.submitEntryImages(Unknown 
Source)
        at 
org.devpower.wicket.cms.widget.text.blog.EntryEditorPanel$EditorForm.saveEntry(EntryEditorPanel.java:181)
        at 
org.devpower.wicket.cms.widget.text.blog.EntryEditorPanel$EditorForm.onSubmit(EntryEditorPanel.java:110)
        at 
org.apache.wicket.markup.html.form.Form.delegateSubmit(Form.java:1355)
        at 
org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:810)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at 
org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:183)
        at 
org.apache.wicket.request.target.component.listener.ListenerInterfaceRequestTarget.processEvents(ListenerInterfaceRequestTarget.java:73)
        at 
org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:91)
        at 
org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1175)
        at org.apache.wicket.RequestCycle.step(RequestCycle.java:1252)
        at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1353)
        at org.apache.wicket.RequestCycle.request(RequestCycle.java:493)
        at 
org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:355)
        at 
org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:200)
        at 
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1139)
        at 
org.devpower.jcr.j2ee.filter.SessionPerRequestFilter.doFilter(SessionPerRequestFilter.java:32)
        at 
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1139)
        at 
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:378)
        at 
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
        at 
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
        at 
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
        at 
org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:417)
        at 
org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
        at 
org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
        at 
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
        at org.mortbay.jetty.Server.handle(Server.java:324)
        at 
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535)
        at 
org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:880)
        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:747)
        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
        at 
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
        at 
org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)

Mime
View raw message