Confluence throws NullPointerException when migrating attachments from database to filesystem
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
Problem
You get a NullPointerException error when trying to migrate from using the database to using the file system storage for attachments.
In the logs, you will see the pre-migration tasks start:
1
INFO [Long running task: Attachment data migration] [persistence.dao.hibernate.AbstractHibernateAttachmentDao] migrate Performing pre-migration tasks.
Followed by this error:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
ERROR [Long running task: Attachment data migration] [confluence.util.longrunning.AttachmentMigrationLongRunningTask] runInternal
-- referer: https://wiki.example.com/admin/doeditattachmentstorage.action | url: /admin/doattachmentmigration.action | userName: admin | action: doattachmentmigration
java.lang.NullPointerException
at java.io.File.<init>(File.java:277)
at com.atlassian.confluence.pages.persistence.dao.BootstrapAttachmentLocationResolver.getFileLocation(BootstrapAttachmentLocationResolver.java:19)
at com.atlassian.confluence.pages.persistence.dao.filesystem.FileSystemAttachmentDataDao.prepareForMigrationTo(FileSystemAttachmentDataDao.java:254)
at com.atlassian.confluence.pages.persistence.dao.hibernate.AbstractHibernateAttachmentDao$IntraHibernateAttachmentMigrator.migrate(AbstractHibernateAttachmentDao.java:883)
at com.atlassian.confluence.util.longrunning.AttachmentMigrationLongRunningTask$1.doInTransactionWithoutResult(AttachmentMigrationLongRunningTask.java:72)
at org.springframework.transaction.support.TransactionCallbackWithoutResult.doInTransaction(TransactionCallbackWithoutResult.java:33)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:128)
at com.atlassian.confluence.util.longrunning.AttachmentMigrationLongRunningTask.runInternal(AttachmentMigrationLongRunningTask.java:66)
at com.atlassian.confluence.util.longrunning.ConfluenceAbstractLongRunningTask.run(ConfluenceAbstractLongRunningTask.java:27)
at com.atlassian.confluence.util.longrunning.ManagedTask.run(ManagedTask.java:58)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Diagnosis
Environment
Previously you used an older version of Confluence (e.g. 5.4 and earlier) with attachments stored in the database.
You upgraded at some point to a newer version of Confluence (e.g.: 5.9 or 5.10) and attempted to migrate attachments to the filesystem
Cause
This is caused by a missing parameter in confluence.cfg.xml which defines the attachment storage location:
1
<property name="attachments.dir">${confluenceHome}/attachments</property>
Solution
Resolution
Add the above line to /path/to/confluence-home/confluence.cfg.xml – for example see line 13 below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
<?xml version="1.0" encoding="UTF-8"?> <confluence-configuration> <setupStep>complete</setupStep> <setupType>custom</setupType> <buildNumber>5998</buildNumber> <properties> <property name="admin.ui.allow.daily.backup.custom.location">false</property> <property name="admin.ui.allow.manual.backup.download">false</property> <property name="admin.ui.allow.site.support.email">false</property> <property name="atlassian.license.message">xxxxxxxxxxxxxxxxxxxxxaxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</property> <property name="confluence.setup.server.id">XXXX-XXXX-XXXX-XXXX</property> <property name="attachments.dir">${confluenceHome}/attachments</property> <property name="confluence.webapp.context.path"></property> <property name="hibernate.c3p0.acquire_increment">1</property> <property name="hibernate.c3p0.idle_test_period">100</property> <property name="hibernate.c3p0.max_size">30</property> <property name="hibernate.c3p0.max_statements">0</property> <property name="hibernate.c3p0.min_size">0</property> <property name="hibernate.c3p0.timeout">30</property> <property name="hibernate.connection.driver_class">org.postgresql.Driver</property> <property name="hibernate.connection.isolation">2</property> <property name="hibernate.connection.password">Sanitized by Support Utility</property> <property name="hibernate.connection.url">jdbc:postgresql://localhost/wiki</property> <property name="hibernate.connection.username">Sanitized by Support Utility</property> <property name="hibernate.database.lower_non_ascii_supported">true</property> <property name="hibernate.dialect">net.sf.hibernate.dialect.PostgreSQLDialect</property> <property name="hibernate.setup">true</property> <property name="lucene.index.dir">${localHome}/index</property> <property name="webwork.multipart.saveDir">${localHome}/temp</property> </properties> </confluence-configuration>
Re-run the attachment migration
Was this helpful?