Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-31088

java.lang.NullPointerException when try to attach file with non-Latin characters

      NOTE: This bug report is for Confluence Server. Using Confluence Cloud? See the corresponding bug report.

      Step to Reproduce

      1. Go to a Confluence page.
      2. Click Tools >> Attachment
      3. Click Choose File button
      4. Attach file with the name 'İ ' ( use the İ.txt attached in this ticket)
      5. The following error will appear in the browser and the atlassian-confluence.log file.
        java.lang.NullPointerException
        at com.atlassian.confluence.pages.actions.beans.AttachmentStorer.attachFiles(AttachmentStorer.java:64)
        Stack Trace:[hide]
        
        java.lang.NullPointerException
        at com.atlassian.confluence.pages.actions.beans.AttachmentStorer.attachFiles(AttachmentStorer.java:64)
        at com.atlassian.confluence.pages.actions.AbstractViewAttachmentsAction.execute(AbstractViewAttachmentsAction.java:104)
        at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:168)
        at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:35)
        at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:165)
        at 
        

      Workaround

      Applicable for other non-latin languages except for İ Turkish character

      1. Ensure your database collation settings are able to handle international strings.
        Refer to this comment for a PostgreSQL fix
      2. Refer to this link for more information

        1. Antrieb-Übersetzung.png
          Antrieb-Übersetzung.png
          60 kB
        2. İ.txt
          0.0 kB
        3. NullPointerException.txt
          31 kB
        4. server.xml
          2 kB
        5. server.xml
          2 kB

            [CONFSERVER-31088] java.lang.NullPointerException when try to attach file with non-Latin characters

            higuchi@ricksoft.jpさん

            I'm glad to hear that the information is helpful.

            Thanks.

            Nobuyuki Mukai added a comment - higuchi@ricksoft.jp さん I'm glad to hear that the information is helpful. Thanks.

            Hi, Nobuyuki

            This information is very helpful for us.

            Thank you.

            Akira Higuchi added a comment - Hi, Nobuyuki This information is very helpful for us. Thank you.

            As a side effect of this issue, deleting the uploaded file from GUI also fails. For this workaround, you can use REST API instead. Please follow the following step to delete the uploaded file –

            1. Confirm contentid of the attachment
              select * from content where pageid=<the page ID the file is attached>;
              
            2. Delete the content above with Confluence REST API
              curl -v -S -u user:password -X DELETE http://<confluence-base-url>/rest/api/content/<contentid obtained by Step 1>
              

            Nobuyuki Mukai added a comment - As a side effect of this issue, deleting the uploaded file from GUI also fails. For this workaround, you can use REST API instead. Please follow the following step to delete the uploaded file – Confirm contentid of the attachment select * from content where pageid=<the page ID the file is attached>; Delete the content above with Confluence REST API curl -v -S -u user:password -X DELETE http://<confluence-base-url>/rest/api/content/<contentid obtained by Step 1>

            Hi All,

            This problem was fixed in Confluence 6.7.2, we tested it.

             

            Thank you

            Regards,

            Emre

            Ortakatman ve Sürüm Yönetimi [MKK] added a comment - Hi All, This problem was fixed in Confluence 6.7.2, we tested it.   Thank you Regards, Emre

            Minh Tran added a comment -

            A fix for this issue is now available for Confluence Server customers.
            Upgrade now or check out the Release Notes to see what other issues are resolved.

            Minh Tran added a comment - A fix for this issue is now available for Confluence Server customers. Upgrade now or check out the Release Notes to see what other issues are resolved.

            Hi mkaradagli,

            Thank you for you question. This fix also will solve the 'i' char issue.

            Regards,
            George Lipatov

            George Lipatov added a comment - Hi mkaradagli , Thank you for you question. This fix also will solve the 'i' char issue. Regards, George Lipatov

            Are there any update for 'i' char ? No one can access or delete these files.

            Mert Karadağlı _ Köstebek Teknoloji _ added a comment - Are there any update for 'i' char ? No one can access or delete these files.

            In my case ( Finnish characters ) Postgres collating sequence was the problem - it needed to be set to UTF8 in addition to the charset. The attachments were uploaded - but couldn't be found. So I wonder is this single turkish character problem a DB bug or Confluence bug. Confluence installation should give very clear instructions about DB settings.

            Vesa Halkka added a comment - In my case ( Finnish characters ) Postgres collating sequence was the problem - it needed to be set to UTF8 in addition to the charset. The attachments were uploaded - but couldn't be found. So I wonder is this single turkish character problem a DB bug or Confluence bug. Confluence installation should give very clear instructions about DB settings.

            @Stephan Eisvogel +1 to you, highly accurate information. Thank you very much.

            HerrStinson added a comment - @Stephan Eisvogel +1 to you, highly accurate information. Thank you very much.

            Got it working... For anyone reading this:

            1. Run https://your-confluence/admin/encodingtest.action ; it has to show no error whatsoever after test.

            2. For Linux: In bin/setenv.sh below export CATALINA_OPTS add

            export LANG=en_US.UTF-8
            export LC_CTYPE="en_US.UTF-8"
            export LC_NUMERIC="en_US.UTF-8"
            export LC_TIME="en_US.UTF-8"
            export LC_COLLATE="en_US.UTF-8"
            export LC_MONETARY="en_US.UTF-8"
            export LC_MESSAGES="en_US.UTF-8"
            export LC_PAPER="en_US.UTF-8"
            export LC_NAME="en_US.UTF-8"
            export LC_ADDRESS="en_US.UTF-8"
            export LC_TELEPHONE="en_US.UTF-8"
            export LC_MEASUREMENT="en_US.UTF-8"
            export LC_IDENTIFICATION="en_US.UTF-8"
            export LC_ALL=

            to override any ANSI encoding in the Java VM towards UTF-8. Do not use any -D... system overrides, usually they are not enough or very difficult to get right concisely.

            3. In /etc/default/locale add lines to look like this (this may be optional):
            LANG="en_US.UTF-8"
            LANGUAGE="en_US:en"
            LC_ALL="en_US.UTF-8"

            4. Do not use MySQL, Atlassian loves and supports Postgresql more. On Postgresql, check database with
            echo -n '\l' | sudo -u postgres psql
            Output of \l command should look like this:
            List of databases
            Name | Owner | Encoding | Collate | Ctype | Access privileges
            ---------------------------------------------------+--------------------------
            confluence | confluence | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =Tc/confluence +

                    confluence=CTc/confluence+
                    postgres=CTc/confluence

            Notice encoding, collate and ctype all set to UTF-8. To create a postgresl database we use
            sudo -u postgres createdb -E UNICODE -T template0 -O confluence confluence.
            Add grant all on database confluence to confluence; grant all on database confluence to postgres; for permission or whatever you need.

            5. Check connectors in conf/server.xml that they contain URIEncoding="UTF-8" and useBodyEncodingForURI="true".

            6. In /admin/viewgeneralconfig.action check that under Formatting and International Settings Encoding is set to UTF-8.

            7. Restart Confluence one time.

            Doing all this and your Confluence will happily speak UTF-8.

            Stephan Eisvogel added a comment - Got it working... For anyone reading this: 1. Run https://your-confluence/admin/encodingtest.action ; it has to show no error whatsoever after test. 2. For Linux: In bin/setenv.sh below export CATALINA_OPTS add export LANG=en_US.UTF-8 export LC_CTYPE="en_US.UTF-8" export LC_NUMERIC="en_US.UTF-8" export LC_TIME="en_US.UTF-8" export LC_COLLATE="en_US.UTF-8" export LC_MONETARY="en_US.UTF-8" export LC_MESSAGES="en_US.UTF-8" export LC_PAPER="en_US.UTF-8" export LC_NAME="en_US.UTF-8" export LC_ADDRESS="en_US.UTF-8" export LC_TELEPHONE="en_US.UTF-8" export LC_MEASUREMENT="en_US.UTF-8" export LC_IDENTIFICATION="en_US.UTF-8" export LC_ALL= to override any ANSI encoding in the Java VM towards UTF-8. Do not use any -D... system overrides, usually they are not enough or very difficult to get right concisely. 3. In /etc/default/locale add lines to look like this (this may be optional): LANG="en_US.UTF-8" LANGUAGE="en_US:en" LC_ALL="en_US.UTF-8" 4. Do not use MySQL, Atlassian loves and supports Postgresql more. On Postgresql, check database with echo -n '\l' | sudo -u postgres psql Output of \l command should look like this: List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges ----------- ---------- -------- ----------- ----------- + -------------------------- confluence | confluence | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =Tc/confluence +         confluence=CTc/confluence+         postgres=CTc/confluence Notice encoding, collate and ctype all set to UTF-8. To create a postgresl database we use sudo -u postgres createdb -E UNICODE -T template0 -O confluence confluence. Add grant all on database confluence to confluence; grant all on database confluence to postgres; for permission or whatever you need. 5. Check connectors in conf/server.xml that they contain URIEncoding="UTF-8" and useBodyEncodingForURI="true". 6. In /admin/viewgeneralconfig.action check that under Formatting and International Settings Encoding is set to UTF-8. 7. Restart Confluence one time. Doing all this and your Confluence will happily speak UTF-8.

              glipatov George Lipatov
              jcheok Jing Hwa Cheok (Inactive)
              Affected customers:
              65 This affects my team
              Watchers:
              68 Start watching this issue

                Created:
                Updated:
                Resolved: