2 Replies Latest reply on Mar 31, 2008 2:47 PM by Peter Johnson

    npe for wiki attachments

    Peter Johnson Master

      JBoss AS 4.2.1, JBoss Portal 2.6.2, JBoss Wiki beta2

      Has anybody noticed that you cannot upload attachments in the wiki? You get a null pointer exception in the commons file upload module.

      Point of interest - JBoss Wiki builds with commons file upload 1.0, yet does not ship with it. JBoss Portal comes with commons file upload 1.2, so that is the one that gets used.

      Apparently the MultipartStream class defined in commons file upload has the ability to notify someone regarding read events. According to the comments in the code, the notifier is optional (i.e., can be null). Unfortunately, whoever wrote the code never looked at that comment, hence the NPE when no notifier is provided.

      Anyway, a simple patch to MultipartStream fixed the problem - I can now upload attachments. If anyone is interested, I can supply the patch. (Apparently someone else noticed this too because Apache's SVN repository has the fix.)

        • 1. Re: npe for wiki attachments
          Jorge Vitor Newbie

          I'm having the exact same problem. Could you give me more info how you fixed this?

          • 2. Re: npe for wiki attachments
            Peter Johnson Master

            In the MultipartStream class, both methods readBytes() and makeAvailable() contain the statement:

            notifier.noteBytesRead(bytesRead);

            I simply added a check for null:

            if (notifier != null) {
             notifier.noteBytesRead(bytesRead);
            }


            To apply this patch:
            1) download the fileupload 1.2 source
            2) Edit the MultipartStream.java source file
            3) Compile only that Java source file, placing the commons fileupload jar in the classpath (you will get 5 class files - there are 4 embedded classes)
            4) Replace the existing MultipartStream class files in the jar file with the newly compiled ones.
            5) Place the updated jar file into the portal's lib directory.