Return-Path: Delivered-To: apmail-jackrabbit-users-archive@minotaur.apache.org Received: (qmail 69220 invoked from network); 14 Jun 2009 12:40:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 14 Jun 2009 12:40:38 -0000 Received: (qmail 76245 invoked by uid 500); 14 Jun 2009 12:40:49 -0000 Delivered-To: apmail-jackrabbit-users-archive@jackrabbit.apache.org Received: (qmail 76194 invoked by uid 500); 14 Jun 2009 12:40:49 -0000 Mailing-List: contact users-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@jackrabbit.apache.org Delivered-To: mailing list users@jackrabbit.apache.org Received: (qmail 76183 invoked by uid 99); 14 Jun 2009 12:40:49 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 14 Jun 2009 12:40:49 +0000 X-ASF-Spam-Status: No, hits=3.1 required=10.0 tests=HTML_MESSAGE,SPF_PASS,URIBL_RHS_DOB X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of mrduguo@gmail.com designates 209.85.219.212 as permitted sender) Received: from [209.85.219.212] (HELO mail-ew0-f212.google.com) (209.85.219.212) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 14 Jun 2009 12:40:38 +0000 Received: by ewy8 with SMTP id 8so3551577ewy.43 for ; Sun, 14 Jun 2009 05:40:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=LAIvGDQlf7GzC54/rURNWTZUz+JjX62HN7mlNDzDI4k=; b=oVt7uSFh7Ma6D98bdYU1fW3ZAOuVlbe3mFSYQWa7tKkq3vAXuZAW87nNihHanSC5xa 295K49v7M6PEGtPDIIGxIF4QPNsotk0vp5wU6osTv9pRuztytHOsypMcBq0dlJqm17LI iMRiU+PbF5dUq47FcoZ5l/sqIZ3LMTv8XzZpA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=UqcCc1fv5nI6fAR3uy0Rz858V99MiNiy+f7g211fGtGgH2j/MzLKHRLvBSQxiVXe6K n2cSegQKA+90WidKg8roGsYK7Mfgd1IBDrPSkLJeMQisnanV7i7FZsSt4V8XSSOKhUPK 4VbJT2DP/raNaxqdClyoXCjWCuG5j+dO2CxRQ= MIME-Version: 1.0 Received: by 10.216.46.194 with SMTP id r44mr2027699web.20.1244983215214; Sun, 14 Jun 2009 05:40:15 -0700 (PDT) In-Reply-To: References: Date: Sun, 14 Jun 2009 13:40:15 +0100 Message-ID: Subject: Re: problem attaching InputStream to jcr:data From: Guo Du To: users@jackrabbit.apache.org Content-Type: multipart/alternative; boundary=001485f040604b52f7046c4e3ebf X-Virus-Checked: Checked by ClamAV on apache.org --001485f040604b52f7046c4e3ebf Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit You may need to create the stream value before set the property: node.setProperty("jcr:data", session.getValueFactory().createValue(fileInputStream)); Good luck! On Sat, Jun 13, 2009 at 11:44 PM, Vibhu Sharma wrote: > Hi, > I have just downloaded the jackrabbit-1.5.5 jars and now when I am > trying to upload a file and attach it to jcr:data of nt:resource, > tomcat just throws an Exception - javax.servlet.ServletException: > Servlet execution threw an exception > > May anyone point me where the problem is. Thanks in advance > > I am using Tomcat 6 with jackrabbit 1.5.5, LocalfileSystem on a > Windows Box and DerbyPersistence Manager. > > The code snippet for adding the node is as follows: > > fileNode = baseNode.addNode("nameOfNode", "nt:file"); > contentNode = fileNode.addNode("jcr:content","nt:resource"); > _logger.debug(" setting the uploaded content in text node : > "+content.getMimeType()); > _logger.debug(" setting the jcr:data "); > contentNode.setProperty("jcr:data", content.getContentStream()); > _logger.debug(" set the jcr:data"); > contentNode.setProperty("jcr:mimeType", content.getMimeType()); > _logger.debug(" set the mime type : file : "+content.getContentStream()); > _logger.debug(" setting the jcr:lastModified "); > contentNode.setProperty("jcr:lastModified", Calendar.getInstance()); > _logger.debug(" text node specific properties added successfully"); > > the Logger just prints "setting the jcr:data" and then the page > displays the above mentioned exception > > Following is the snippet of the log > > DEBUG [main] (RepositoryImpl.java:428) - No configuration entry for > SecurityManager. Using > org.apache.jackrabbit.core.security.simple.SimpleSecurityManager > INFO [main] (SimpleSecurityManager.java:116) - init: using Repository > LoginModule configuration for Jackrabbit > DEBUG [main] (SimpleSecurityManager.java:136) - No adminID defined in > LoginModule/JAAS config -> using default. > DEBUG [main] (ProviderRegistryImpl.java:66) - Could not register > principal provider: principalProvider configuration entry missing. > INFO [main] (RepositoryImpl.java:435) - SecurityManager = class > org.apache.jackrabbit.core.security.simple.SimpleSecurityManager > DEBUG [main] (AbstractLoginModule.java:119) - Initalize LoginModule: > DEBUG [main] (AbstractLoginModule.java:138) - - PrincipalProvider -> > > 'org.apache.jackrabbit.core.security.simple.SimpleSecurityManager$SimplePrincipalProvider' > DEBUG [main] (SimpleLoginModule.java:44) - init: SimpleLoginModule. Done. > DEBUG [main] (AbstractLoginModule.java:163) - - Option: anonymousId -> > 'anonymous' > DEBUG [main] (MLRUItemStateCache.java:148) - > org.apache.jackrabbit.core.state.MLRUItemStateCache@b41166 size=1, > 3664/4194304 > DEBUG [main] (RepositoryConfig.java:176) - got repository session for text > DEBUG [main] (RepositoryConfig.java:73) - got session, now registering > node types... > DEBUG [main] (NodeTypeRegistry.java:1287) - > {http://www.projectoffguard.com/base}textalready exists > FATAL [main] (RepositoryConfig.java:99) - error instantiating session > or registering node types : Invalid node type definition: > {http://www.projectoffguard.com/base}textalready exists > DEBUG [main] (DBSource.java:24) - reached DbHelper > DEBUG [http-8080-1] (BeanUtilsBean.java:814) - > BeanUtils.populate(com.offguard.upload.form.ContentForm@43487e, > {content.genre=[Ljava.lang.String;@14c7a98, > content.subGenre=[Ljava.lang.String;@4a96a, > type=[Ljava.lang.String;@e920f, userId=[Ljava.lang.String;@974600, > content.title=[Ljava.lang.String;@174cb21, > content.language=[Ljava.lang.String;@c3e967, media=DarshanResume.pdf, > content.description=[Ljava.lang.String;@1079ff}) > DEBUG [http-8080-1] (BeanUtilsBean.java:895) - > setProperty(com.offguard.upload.form.ContentForm@43487e, > content.genre, [aw]) > DEBUG [http-8080-1] (BeanUtilsBean.java:910) - Target bean = [ > null , 0 , null , false , false , null , null ] > DEBUG [http-8080-1] (BeanUtilsBean.java:911) - Target name = genre > DEBUG [http-8080-1] (ConvertUtilsBean.java:460) - Convert string 'aw' > to class 'java.lang.String' > DEBUG [http-8080-1] (ConvertUtilsBean.java:468) - Using converter > ConverterFacade[StringConverter[UseDefault=true]] > DEBUG [http-8080-1] (AbstractConverter.java:127) - Converting 'String' > value 'aw' to type 'String' > DEBUG [http-8080-1] (PropertyUtilsBean.java:2138) - setSimpleProperty: > Invoking method public void > com.offguard.bean.content.Content.setGenre(java.lang.String) with > value aw (class java.lang.String) > DEBUG [http-8080-1] (BeanUtilsBean.java:895) - > setProperty(com.offguard.upload.form.ContentForm@43487e, > content.subGenre, [aw]) > DEBUG [http-8080-1] (BeanUtilsBean.java:910) - Target bean = [ > null , 0 , null , false , false , null , null ] > DEBUG [http-8080-1] (BeanUtilsBean.java:911) - Target name = subGenre > DEBUG [http-8080-1] (ConvertUtilsBean.java:460) - Convert string 'aw' > to class 'java.lang.String' > DEBUG [http-8080-1] (ConvertUtilsBean.java:468) - Using converter > ConverterFacade[StringConverter[UseDefault=true]] > DEBUG [http-8080-1] (AbstractConverter.java:127) - Converting 'String' > value 'aw' to type 'String' > DEBUG [http-8080-1] (PropertyUtilsBean.java:2138) - setSimpleProperty: > Invoking method public void > com.offguard.bean.content.Content.setSubGenre(java.lang.String) with > value aw (class java.lang.String) > DEBUG [http-8080-1] (BeanUtilsBean.java:895) - > setProperty(com.offguard.upload.form.ContentForm@43487e, type, [1]) > DEBUG [http-8080-1] (BeanUtilsBean.java:910) - Target bean = > com.offguard.upload.form.ContentForm@43487e > DEBUG [http-8080-1] (BeanUtilsBean.java:911) - Target name = type > DEBUG [http-8080-1] (MethodUtils.java:941) - Matching name=getType on > class com.offguard.upload.form.ContentForm > DEBUG [http-8080-1] (MethodUtils.java:1026) - No match found. > DEBUG [http-8080-1] (MethodUtils.java:941) - Matching name=isType on > class com.offguard.upload.form.ContentForm > DEBUG [http-8080-1] (MethodUtils.java:1026) - No match found. > DEBUG [http-8080-1] (BeanUtilsBean.java:895) - > setProperty(com.offguard.upload.form.ContentForm@43487e, userId, > [1001]) > DEBUG [http-8080-1] (BeanUtilsBean.java:910) - Target bean = > com.offguard.upload.form.ContentForm@43487e > DEBUG [http-8080-1] (BeanUtilsBean.java:911) - Target name = userId > DEBUG [http-8080-1] (MethodUtils.java:941) - Matching name=getUserId > on class com.offguard.upload.form.ContentForm > DEBUG [http-8080-1] (MethodUtils.java:1026) - No match found. > DEBUG [http-8080-1] (MethodUtils.java:941) - Matching name=isUserId on > class com.offguard.upload.form.ContentForm > DEBUG [http-8080-1] (MethodUtils.java:1026) - No match found. > DEBUG [http-8080-1] (BeanUtilsBean.java:895) - > setProperty(com.offguard.upload.form.ContentForm@43487e, > content.title, [aw]) > DEBUG [http-8080-1] (BeanUtilsBean.java:910) - Target bean = [ > null , 0 , null , false , false , null , null ] > DEBUG [http-8080-1] (BeanUtilsBean.java:911) - Target name = title > DEBUG [http-8080-1] (ConvertUtilsBean.java:460) - Convert string 'aw' > to class 'java.lang.String' > DEBUG [http-8080-1] (ConvertUtilsBean.java:468) - Using converter > ConverterFacade[StringConverter[UseDefault=true]] > DEBUG [http-8080-1] (AbstractConverter.java:127) - Converting 'String' > value 'aw' to type 'String' > DEBUG [http-8080-1] (PropertyUtilsBean.java:2138) - setSimpleProperty: > Invoking method public void > com.offguard.bean.content.Content.setTitle(java.lang.String) with > value aw (class java.lang.String) > DEBUG [http-8080-1] (BeanUtilsBean.java:895) - > setProperty(com.offguard.upload.form.ContentForm@43487e, > content.language, [awe]) > DEBUG [http-8080-1] (BeanUtilsBean.java:910) - Target bean = [ > null , 0 , aw , false , false , null , null ] > DEBUG [http-8080-1] (BeanUtilsBean.java:911) - Target name = language > DEBUG [http-8080-1] (ConvertUtilsBean.java:460) - Convert string 'awe' > to class 'java.lang.String' > DEBUG [http-8080-1] (ConvertUtilsBean.java:468) - Using converter > ConverterFacade[StringConverter[UseDefault=true]] > DEBUG [http-8080-1] (AbstractConverter.java:127) - Converting 'String' > value 'awe' to type 'String' > DEBUG [http-8080-1] (PropertyUtilsBean.java:2138) - setSimpleProperty: > Invoking method public void > com.offguard.bean.content.Content.setLanguage(java.lang.String) with > value awe (class java.lang.String) > DEBUG [http-8080-1] (BeanUtilsBean.java:895) - > setProperty(com.offguard.upload.form.ContentForm@43487e, media, > DarshanResume.pdf) > DEBUG [http-8080-1] (BeanUtilsBean.java:910) - Target bean = > com.offguard.upload.form.ContentForm@43487e > DEBUG [http-8080-1] (BeanUtilsBean.java:911) - Target name = media > DEBUG [http-8080-1] (PropertyUtilsBean.java:2138) - setSimpleProperty: > Invoking method public void > > com.offguard.upload.form.ContentForm.setMedia(org.apache.struts.upload.FormFile) > with value DarshanResume.pdf (class > org.apache.struts.upload.CommonsMultipartRequestHandler$CommonsFormFile) > DEBUG [http-8080-1] (BeanUtilsBean.java:895) - > setProperty(com.offguard.upload.form.ContentForm@43487e, > content.description, [aw]) > DEBUG [http-8080-1] (BeanUtilsBean.java:910) - Target bean = [ > null , 0 , aw , false , false , awe , null ] > DEBUG [http-8080-1] (BeanUtilsBean.java:911) - Target name = > description > DEBUG [http-8080-1] (ConvertUtilsBean.java:460) - Convert string 'aw' > to class 'java.lang.String' > DEBUG [http-8080-1] (ConvertUtilsBean.java:468) - Using converter > ConverterFacade[StringConverter[UseDefault=true]] > DEBUG [http-8080-1] (AbstractConverter.java:127) - Converting 'String' > value 'aw' to type 'String' > DEBUG [http-8080-1] (PropertyUtilsBean.java:2138) - setSimpleProperty: > Invoking method public void > com.offguard.bean.content.Content.setDescription(java.lang.String) > with value aw (class java.lang.String) > DEBUG [http-8080-1] (DBAuthenticator.java:57) - getting connection > DEBUG [http-8080-1] (DBAuthenticator.java:107) - sql : select status > from user_account where user_id = 1001 > DEBUG [http-8080-1] (DBAuthenticator.java:38) - authentication successful > DEBUG [http-8080-1] (CommonAction.java:64) - authentication successful > DEBUG [http-8080-1] (AddAction.java:43) - in process action > DEBUG [http-8080-1] (AddAction.java:102) - Addaction - in set propertiesb > DEBUG [http-8080-1] (AddAction.java:106) - currDate : 2009:06:14:03:33:55 > DEBUG [http-8080-1] (AddAction.java:126) - --- content : size : 35000 > DEBUG [http-8080-1] (AddAction.java:127) - --- content : size : > application/pdf > DEBUG [http-8080-1] (AddAction.java:128) - --- media : > java.io.ByteArrayInputStream@12ea1dd > DEBUG [http-8080-1] (RepositoryConfig.java:119) - getting repository > session for text > DEBUG [http-8080-1] (AbstractLoginModule.java:119) - Initalize LoginModule: > DEBUG [http-8080-1] (AbstractLoginModule.java:138) - - > PrincipalProvider -> > > 'org.apache.jackrabbit.core.security.simple.SimpleSecurityManager$SimplePrincipalProvider' > DEBUG [http-8080-1] (SimpleLoginModule.java:44) - init: SimpleLoginModule. > Done. > DEBUG [http-8080-1] (AbstractLoginModule.java:163) - - Option: > anonymousId -> 'anonymous' > DEBUG [http-8080-1] (MLRUItemStateCache.java:148) - > org.apache.jackrabbit.core.state.MLRUItemStateCache@8fa0d1 size=1, > 3664/4194304 > DEBUG [http-8080-1] (RepositoryConfig.java:123) - got repository > session for text > DEBUG [http-8080-1] (ContentDAO.java:43) - entered add node > DEBUG [http-8080-1] (MLRUItemStateCache.java:148) - > org.apache.jackrabbit.core.state.MLRUItemStateCache@10275fa size=1, > 2164/4194304 > DEBUG [http-8080-1] (ItemManager.java:787) - caching item > cafebabe-cafe-babe-cafe-babecafebabe > DEBUG [http-8080-1] (ItemManager.java:787) - caching item > 9265f3d8-6d19-4d00-9d7d-24d00131ff80 > DEBUG [http-8080-1] (ItemManager.java:787) - caching item > 9265f3d8-6d19-4d00-9d7d-24d00131ff80/{ > http://www.jcp.org/jcr/1.0}primaryType > DEBUG [http-8080-1] (ItemManager.java:787) - caching item > 9265f3d8-6d19-4d00-9d7d-24d00131ff80/{http://www.jcp.org/jcr/1.0}uuid > DEBUG [http-8080-1] (TextDAO.java:29) - setting the uploaded content > in text node : application/pdf > DEBUG [http-8080-1] (TextDAO.java:31) - setting the jcr:data > DEBUG [http-8080-1] (ItemManager.java:787) - caching item > 9265f3d8-6d19-4d00-9d7d-24d00131ff80/{http://www.jcp.org/jcr/1.0}data > DEBUG [http-8080-1] (ItemManager.java:884) - destroyed item > 9265f3d8-6d19-4d00-9d7d-24d00131ff80/{http://www.jcp.org/jcr/1.0}data > DEBUG [http-8080-1] (ItemManager.java:801) - removing items > 9265f3d8-6d19-4d00-9d7d-24d00131ff80/{http://www.jcp.org/jcr/1.0}data > from cache > DEBUG [http-8080-1] (ItemManager.java:884) - destroyed item > 9265f3d8-6d19-4d00-9d7d-24d00131ff80 > DEBUG [http-8080-1] (ItemManager.java:801) - removing items > 9265f3d8-6d19-4d00-9d7d-24d00131ff80 from cache > DEBUG [http-8080-1] (ItemManager.java:874) - invalidated item > cafebabe-cafe-babe-cafe-babecafebabe > DEBUG [http-8080-1] (ItemManager.java:818) - removing item > cafebabe-cafe-babe-cafe-babecafebabe from cache > -- Kind regards, Du, Guo --001485f040604b52f7046c4e3ebf--