• Ryszard Lach
    Ryszard Lach, 2011/11/06 09:58

    I have a problem with importing attachments. After few minutes of creating attachment files in .../data/storage I get 'failed to execute macro' error.
    In catalina.out I get exceptions:

    com.xpn.xwiki.XWikiException: Error number 3004 in 3: Exception while manipulating the archive for attachment tables.txt
    Wrapped Exception: Error number 2002 in 2: Error parsing xml
    Wrapped Exception: Error on line 1 of document  : Content is not allowed in prolog. Nested exception: Content is not allowed in prolog.
            at com.xpn.xwiki.doc.XWikiAttachmentArchive.getRevision(XWikiAttachmentArchive.java:285)
            at com.xpn.xwiki.store.AttachmentArchiveSaveRunnable.<init>(AttachmentArchiveSaveRunnable.java:81)
            at com.xpn.xwiki.store.FilesystemAttachmentVersioningStore.getArchiveSaveRunnable(FilesystemAttachmentVersioningStore.java:202)
            at com.xpn.xwiki.store.FilesystemAttachmentStore$AttachmentSaveTransactionRunnable.<init>(FilesystemAttachmentStore.java:363)
            at com.xpn.xwiki.store.FilesystemAttachmentStore.getAttachmentContentSaveRunnable(FilesystemAttachmentStore.java:145)
            at sun.reflect.GeneratedMethodAccessor294.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:229)
            at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:52)
            at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:132)
            at Script7.doIt(Script7.groovy:140)
            at Script7.this$4$doIt(Script7.groovy)

    It seems there is such an exception for every one of my attachments.

    Can you help me?

    TIA

    R.

  • Vincent Massol
    Vincent Massol, 2012/04/03 13:55

    Fred Blabla reported an issue with this extension here: http://jira.xwiki.org/browse/XWIKI-7638

    I've closed it since it's not the right place.

  • Caleb James DeLisle
    Caleb James DeLisle, 2012/04/04 06:24

    Upgraded to work with 3.4 and newer, thanks for bringing the issue to my attention.

  • Jamie Maher
    Jamie Maher, 2012/05/17 22:29

    When switching to Filesystem attachment storage and running under a security manager I had to adjust my policy file.

    The following were added to the default Web Application Permissions section of the policy file.

    I didn't test if these simply needed adding to the xwiki codebase section only.
    (grant codeBase "file:${catalina.home}/webapps/xwiki/-")

     permission java.util.PropertyPermission "user.dir", "read";
       
    permission java.util.PropertyPermission "office.*", "read";
    permission java.util.PropertyPermission "file.encoding", "read";
    permission java.util.PropertyPermission "java.io.tmpdir", "read";        
    permission java.util.PropertyPermission "org.apache.commons.logging.LogFactory.HashtableImpl", "read";
    permission java.util.PropertyPermission "org.quartz.properties", "read";
    permission java.util.PropertyPermission "ANTLR_DO_NOT_EXIT", "read";  
    permission java.util.PropertyPermission "ANTLR_USE_DIRECT_CLASS_LOADING", "read";
    permission java.util.PropertyPermission "org.apache.xerces.xni.parser.XMLParserConfiguration", "read";        
    permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
    permission java.lang.RuntimePermission "getClassLoader";
    permission java.lang.RuntimePermission "createClassLoader";  
    permission java.lang.RuntimePermission "setContextClassLoader";
    permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina";
    permission java.lang.RuntimePermission "accessClassInPackage.sun.reflect";
    permission java.lang.RuntimePermission "accessDeclaredMembers";
    permission java.lang.RuntimePermission "getenv.ProgramFiles";
    permission java.lang.RuntimePermission "getenv.APPDATA";

    //Allow file storage directory reading - for directory and everything underneath
    permission java.io.FilePermission "${catalina.home}${file.separator}xwikidata${file.separator}", "read,write,delete";
    permission java.io.FilePermission "${catalina.home}${file.separator}xwikidata${file.separator}-", "read,write,delete";
    //Allow file storage directory reading - temporary directory and everything underneath
    permission java.io.FilePermission "${catalina.home}${file.separator}temp${file.separator}", "read,write,delete";
    permission java.io.FilePermission "${catalina.home}${file.separator}temp${file.separator}-", "read,write,delete";
    • Caleb James DeLisle
      Caleb James DeLisle, 2012/05/18 13:57

      Added these to the security manager template. Thanks for the tip.

  • Guillaume Delhumeau
    Guillaume Delhumeau, 2012/06/19 16:13

    Hi, because of this bug:
    http://jira.xwiki.org/browse/XWIKI-7936

    I had to modify your script. Here is the diff:
    277c277,279
    <             for (XWikiAttachment attach : doc.getAttachmentList()) {
    ---
    >             //for (XWikiAttachment attach : doc.getAttachmentList()) { // http://jira.xwiki.org/browse/XWIKI-7936
    >             def hql = "select att from XWikiAttachment att WHERE att.docId=?";
    >             for (XWikiAttachment attach : xwiki.search(hql, [doc.getId()])) { attach.setDoc(doc);

    It's important, otherwise some attachments will not be stored on FS and some bugs happen.

    • Caleb James DeLisle
      Caleb James DeLisle, 2012/10/30 21:13

      Integrated in 2.1, thanks for the patch and sorry it took so long.

  • Ganesan M
    Ganesan M, 2013/07/30 15:03

    While I try to Switch from database attachment to File system I got error 'failed to execute macro'.
    Then I opened the code and changed " private void main()"  to " public void main()" It exported almost all the attachments to my hard disk. Can you please try to change this bug?

    Thanks.

    • Caleb James DeLisle
      Caleb James DeLisle, 2013/07/30 15:11

      Hi Ganesan,
      If you're getting a 'failed to execute macro' error, you can click on it and it will expand to show the actual error and stack trace. Also this is not a good place to ask for help, it's better to ask on the users mailing list MailingLists because it will be seen by more people.

  • Danilo Oliveira
    Danilo Oliveira, 2013/08/28 15:20

    Hello all!
    I faced the same problem as Ganesan! When I run the script I got a error:

    "Script4.groovy: 62: Mixing private and public/protected methods of the same name causes multimethods to be disabled and is forbidden to avoid surprising behaviour. Renaming the private methods will solve the problem.  @ line 62, column 1.    private void main()"
    Then I changed the private fucntion "main" to public!

    Then, it worked perfectly!

    Bye

  • Vincent Massol
    Vincent Massol, 2013/11/12 10:47

    A problem that needs to be fixed was reported by Matthias Wegner at http://jira.xwiki.org/browse/XWIKI-9657

  • garth arnold
    garth arnold, 2014/08/05 01:29

    Hello. My experience is when running this on 6.0.1.

    When run in dry run mode a large number of attachments are listed. When run with dry run disabled, fewer attachments appear to be processed (are listed). Icon attachments (eg avatar PNGs) were lost as well as some documents. 

    I don't see a way to repeat the db->file system move - which I can understand because I wouldn't want attachments duplicated - but it would be nice to be able to see the full list of attachments again in order to know what was omitted. This experience was on an evaluation wiki (prior to planned use) so this is throwaway content, but it doesn't seem like intended behavior.

  • garth arnold
    garth arnold, 2014/08/05 02:01

    Addendum to my comment above: while reloading the page with the script *did not* allow me to repeat the dry run, switching to edit mode and then exiting did reset the page so that I could repeat the dry run, confirming that many more files were listed in that mode. Reviewing the jira link in Vincent's post of 2013/11/12 I believe that the issue described there is still present (attachments that come with the default wiki pages aren't processed) but other attachments were also omitted. User beware.

  • Craig Wright
    Craig Wright, 2016/12/30 01:52

    FOR THOSE NEW TO XWIKI:

    Snippets are a "snippet" of code that runs within a page on your wiki. To run the Snippet, copy and paste the most recent version of the snippet into a newly-created page on your wiki. I pasted it into the editor with "Source" mode enabled, it may work in WYSIWYG mode as well. After saving the page, you will see instructions on how to run the script.

Get Connected