The storing looks fine but the retrieval looks wrong.  Try this:

Node resourceNode =
session.getRootNode().getNode("ptattachment").getNode(fileName).getNode("jcr:content");
InputStream in = resourceNode.getProperty("jcr:data").getStream();

On Fri, 2010-01-01 at 04:01 -0800, test123456 wrote:

> I am adding a image to the jackrabbit repository.
> I am using jackrabbit 1.6.0 version .
> 
> While try to retrieve the image from the repository  it is throwing the
> PathNotFoundException for jcr:data
> 
> It is showing only two properties 
> jcr:created
> jcr:primaryType
> 
> there is no jcr:data property.
> 
> What will be the problem 
> I used the following snippet for adding the image to repository
> 
>                         Node folder =
> session.getRootNode().addNode("ptattachment");
>                       
>                       Node file = folder.addNode(fileName, "nt:file");
>                                               
>                       MimeTable mt = MimeTable.getDefaultTable();
>                       String mimeType = mt.getContentTypeFor(fileName);
>                       if (mimeType == null) mimeType = 
> "application/octet-stream";
>                       
>                       Node contentNode = file.addNode("jcr:content", 
> "nt:resource");
>                       contentNode.setProperty("jcr:data", fileStream);
>                       contentNode.setProperty("jcr:lastModified", 
> Calendar.getInstance());
>                       contentNode.setProperty("jcr:mimeType", mimeType);
>                       
>                       session.save();
> 
> And used following code to retrieve the image
> node = session.getRootNode().getNode("ptattachment");
> InputStream in = n.getProperty("jcr:data").getStream();
> 


Reply via email to