how add file in alfresco with JCR ?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2009 04:55 AM
Hi,
I am trying to add a file (for example "pdf") to alfresco.
when I compile this code :
this is the error :
Thank you for your help :!:
I am trying to add a file (for example "pdf") to alfresco.
when I compile this code :
vJcrSession = vJcrRepository.login(new SimpleCredentials("admin", "admin".toCharArray()));String fileName = "pdf/AlfrescoFAQ_1_1_FR.pdf"; FileInputStream inputStream = new FileInputStream(fileName); Node root = vJcrSession.getRootNode();Node createdNodeRef = root.addNode(fileName, "nt:file");Node dataNode = createdNodeRef.addNode("jcr:content", "nt:resource");dataNode.setProperty("jcr:mimeType", "application/pdf");dataNode.setProperty("jcr:encoding", "");dataNode.setProperty("jcr:data", inputStream);vJcrSession.save();
this is the error :
09:41:56,152 User:admin ERROR [alfresco.thread.WorkerThreadImpl] java.lang.reflect.InvocationTargetExceptionjava.lang.reflect.InvocationTargetException 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.alfresco.thread.WorkerThreadImpl.run(WorkerThreadImpl.java:97) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619)Caused by: javax.jcr.PathNotFoundException: Path 'pdf/AlfrescoFAQ_1_1_FR.pdf' does not exist from node workspace://SpacesStore/704b4554-30d2-4054-8502-6d52316b49df at org.alfresco.jcr.item.NodeImpl.addNode(NodeImpl.java:166) 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.alfresco.jcr.util.JCRProxyFactory$SessionContextInvocationHandler.invoke(JCRProxyFactory.java:138) at $Proxy175.addNode(Unknown Source) … 8 more09:41:56,156 ERROR [alfresco.thread.WorkerThreadManager] error on dispatched method [addNode]javax.jcr.PathNotFoundException: Path 'pdf/AlfrescoFAQ_1_1_FR.pdf' does not exist from node workspace://SpacesStore/704b4554-30d2-4054-8502-6d52316b49df at org.alfresco.jcr.item.NodeImpl.addNode(NodeImpl.java:166) 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.alfresco.jcr.util.JCRProxyFactory$SessionContextInvocationHandler.invoke(JCRProxyFactory.java:138) at $Proxy175.addNode(Unknown Source) 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.alfresco.thread.WorkerThreadImpl.run(WorkerThreadImpl.java:97) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619)09:45:57,307 ERROR [alfresco.thread.WorkerThreadManager] Inactive worker thread removed from threadMap310:20:32,461 ERROR [transaction.SpringAwareUserTransaction.trace] Detected first UserTransaction which is being garbage collected without a commit() or rollback()10:20:32,461 ERROR [transaction.SpringAwareUserTransaction.trace] Logging of transaction call stack is now enabled andwill affect performance
Thank you for your help :!:
Labels:
- Labels:
-
Archive
4 REPLIES 4
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2009 05:49 AM
Hi!
Did you solve your problem?
I have the same problem with getNode…
Thank you!
Did you solve your problem?
I have the same problem with getNode…
javax.jcr.PathNotFoundException: A node does not exist at path app:guest_home/test/jconsole.PNG relative to node workspace://SpacesStore/4b736ff7-fefe-40e2-a15c-50e2a4d0dd15 at org.alfresco.jcr.item.ItemResolver.findNode(ItemResolver.java:92) at org.alfresco.jcr.item.NodeImpl.getNode(NodeImpl.java:474) at sun.reflect.GeneratedMethodAccessor490.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.alfresco.jcr.util.JCRProxyFactory$SessionContextInvocationHandler.invoke(JCRProxyFactory.java:138) at $Proxy172.getNode(Unknown Source) at sun.reflect.GeneratedMethodAccessor490.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.alfresco.thread.WorkerThreadImpl.run(WorkerThreadImpl.java:99) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675) at java.lang.Thread.run(Thread.java:595)
Thank you!
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2009 10:36 AM
No gdelafos !
I can not add the file with JCR :cry:
I can not add the file with JCR :cry:
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2009 05:03 AM
did you guys gt the solution..even i wanted to know this?

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2010 09:04 AM
Hello,
I'd also like to add a file to Alfresco, however within an action (derived from ActionExecuterAbstractBase) context. The Wiki documentation confused me more than it actually helped.
Maybe someone here might answer my questions:
1. All examples contain login/logout. I don't think that's necessary from within an Action context, is it?
2. How do I get the JCR.Repository object from within an Action?
3. Is there a way the get the javax.jcr.Node for a given NodeRef?
Regards,
Martin.
I'd also like to add a file to Alfresco, however within an action (derived from ActionExecuterAbstractBase) context. The Wiki documentation confused me more than it actually helped.

1. All examples contain login/logout. I don't think that's necessary from within an Action context, is it?
2. How do I get the JCR.Repository object from within an Action?
3. Is there a way the get the javax.jcr.Node for a given NodeRef?
Regards,
Martin.
