Confluence cannot make a backup
Asked by Tony Montana:

Hi!

Confluence cannot make a backup

WARN \[ConfluenceBackupRestoreManager:thread-1\] \[confluence.impl.backuprestore.ConfluenceBackupRestoreManager\] updateJobStateAfterCompletion Backup restore job BackupRestoreJob{id=17727489, jobOperation=BACKUP, jobScope=SPACE, jobState=PROCESSING, createTime=2023-11-22T08:15:48Z, startProcessingTime=2023-11-22T08:15:48Z, finishProcessingTime=null, cancelTime=null, owner='montana@supersite.net', whoCancelledTheJob='null', errorMessage='null'} failed: java.util.concurrent.ExecutionException: java.lang.NullPointerException: Cannot invoke \\"com.atlassian.sal.api.user.UserKey.getStringValue()\\" because \\"userKey\\" is null  

Why?

I forgot to add that the problem is only with this space. All others are backed up well.


Answers:
author: M?rten Woxberg
body: We had the same thing.

The workaround was to use the OLD Space Export.

comments: author: M?rten Woxberg
body: And since I didn't write down the workaround and had to find it again for myself here it is.

https://\<url\>/spaces/exportspace**xml**.action?key=


author: Miklos Tix
body: [@M?rten Woxberg](/t5/user/viewprofilepage/user-id/3945677) you da best, thanks for this, worked like a charm! :)


author: Esther Lansbergen
body: Thanks!


author: Gary Smolyak
body: Thank you, great find!


author: Radek Dost?l
body: I'm not familiar with that in particular, but the message is a pointer:

```
Cannot invoke \"com.atlassian.sal.api.user.UserKey.getStringValue()\" because \"userKey\" is null
```

<br />

Each user must have a userkey, that's how Confluence maps a lot of stuff.

I wonder if any of these will return anything - can you access the db?

```
SELECT * FROM user_mapping WHERE user_key IS NULL;

SELECT id,user_name FROM cwd_user WHERE lower_user_name NOT IN (SELECT lower_username FROM user_mapping);
```

<br />

Not to say these are the definitive answer, but that's where I'd start looking for a null key. Either one should return the offending user or users.

comments: author: Tony Montana
body: [@Radek Dost?l](/t5/user/viewprofilepage/user-id/715713) Postrgres

```
confdb1=# SELECT * FROM user_mapping WHERE user_key IS NULL;

SELECT id,user_name FROM cwd_user WHERE lower_user_name NOT IN (SELECT lower_username FROM user_mapping);
user_key | username | lower_username
----------+----------+----------------
(0 rows)

id | user_name
----+-----------
(0 rows)
```

I forgot to add that the problem is only with this space. All others are backed up well.


author: Tony Montana
body: If I copy space so backup is working


author: Radek Dost?l
body: Mhm, then I'm thinking during the export it tries to load some user reference (mention, author, etc.) and fails on that..

If you would be able to find the stacktrace from the backup job, we might see which methods it goes through before it throw the nullpointer. Then that would likely point us towards where to look next, what kind of content it is about.

The job *should*throw and print that to atlassian-confluence.log when it stops, perhaps grepping for 'NullPointerException' should make that search easy.

If the space copy works for you then perhaps this might not need solving in the end, it's not like this would seem to be anywhere common, at least internet search comes up empty.


author: Tony Montana
body: ```
2023-11-22 14:27:32,793 INFO [ConfluenceBackupRestoreManager:thread-11] [impl.backuprestore.backup.SpaceBackupService] doBackupSynchronously SPACE backup [17727492] with keys [ADH] has started.
2023-11-22 14:27:32,803 INFO [ConfluenceBackupRestoreManager:thread-11] [impl.backuprestore.backup.AbstractBackupService] performBackup SPACE backup [17727492] is now backing up entities and attachments.
2023-11-22 14:27:37,732 WARN [ConfluenceBackupRestoreManager:thread-11] [confluence.impl.backuprestore.ConfluenceBackupRestoreManager] updateJobStateAfterCompletion Backup restore job BackupRestoreJob{id=17727492, jobOperation=BACKUP, jobScope=SPACE, jobState=PROCESSING, createTime=2023-11-22T12:27:32Z, startProcessingTime=2023-11-22T12:27:32Z, finishProcessingTime=null, cancelTime=null, owner='montana@supersite.net', whoCancelledTheJob='null', errorMessage='null'} failed: java.util.concurrent.ExecutionException: java.lang.NullPointerException: Cannot invoke \"com.atlassian.sal.api.user.UserKey.getStringValue()\" because \"userKey\" is null
-- url: /rest/api/backup-restore/backup/space | userName: montana@supersite.net | referer: https://kb.supersite.net/plugins/servlet/backup-and-restore/backup | traceId: f15aa0cdb33b028a
com.atlassian.confluence.backuprestore.exception.BackupRestoreException: java.util.concurrent.ExecutionException: java.lang.NullPointerException: Cannot invoke "com.atlassian.sal.api.user.UserKey.getStringValue()" because "userKey" is null
at com.atlassian.confluence.impl.backuprestore.backup.SpaceBackupService.doBackupSynchronously(SpaceBackupService.java:124)
at com.atlassian.confluence.impl.backuprestore.BackupRestoreJobRunner.runJobSynchronously(BackupRestoreJobRunner.java:58)
at com.atlassian.confluence.impl.backuprestore.ConfluenceBackupRestoreManager.runJobAndUpdateJobProperties(ConfluenceBackupRestoreManager.java:271)
at com.atlassian.confluence.impl.backuprestore.ConfluenceBackupRestoreManager.processJobsFromTheQueue(ConfluenceBackupRestoreManager.java:250)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.util.concurrent.ExecutionException: java.lang.NullPointerException: Cannot invoke "com.atlassian.sal.api.user.UserKey.getStringValue()" because "userKey" is null
at java.base/java.util.concurrent.FutureTask.report(Unknown Source)
at java.base/java.util.concurrent.FutureTask.get(Unknown Source)
at com.atlassian.confluence.impl.backuprestore.ParallelTasksExecutor.waitUntilAllTasksComplete(ParallelTasksExecutor.java:119)
at com.atlassian.confluence.impl.backuprestore.ParallelTasksExecutor.waitUntilAllStageJobsComplete(ParallelTasksExecutor.java:92)
at com.atlassian.confluence.impl.backuprestore.ParallelTasksExecutor.waitUntilAllStageJobsComplete(ParallelTasksExecutor.java:108)
at com.atlassian.confluence.impl.backuprestore.backup.SpaceBackupService.backupAllEntitiesAndAttachments(SpaceBackupService.java:167)
at com.atlassian.confluence.impl.backuprestore.backup.AbstractBackupService.performBackup(AbstractBackupService.java:75)
at com.atlassian.confluence.impl.backuprestore.backup.SpaceBackupService.doBackupSynchronously(SpaceBackupService.java:107)
... 8 more
Caused by: java.lang.NullPointerException: Cannot invoke "com.atlassian.sal.api.user.UserKey.getStringValue()" because "userKey" is null
at com.atlassian.confluence.impl.backuprestore.backup.exporters.UserKeyExtractorFragmentTransformer.lambda$getReferences$0(UserKeyExtractorFragmentTransformer.java:67)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
at java.base/java.util.HashMap$KeySpliterator.forEachRemaining(Unknown Source)
at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source)
at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
at java.base/java.util.stream.ReferencePipeline.collect(Unknown Source)
at com.atlassian.confluence.impl.backuprestore.backup.exporters.UserKeyExtractorFragmentTransformer.getReferences(UserKeyExtractorFragmentTransformer.java:68)
at com.atlassian.confluence.impl.backuprestore.backup.exporters.ReferenceEntityFromBodyContentExtractor.lambda$extractReferenceContentFrom$1(ReferenceEntityFromBodyContentExtractor.java:85)
at java.base/java.util.stream.ReferencePipeline$7$1.accept(Unknown Source)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(Unknown Source)
at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(Unknown Source)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(Unknown Source)
at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
at java.base/java.util.stream.ReferencePipeline.forEach(Unknown Source)
at com.atlassian.confluence.impl.backuprestore.backup.exporters.ReferenceEntityFromBodyContentExtractor.extractReferenceContentFrom(ReferenceEntityFromBodyContentExtractor.java:90)
at com.atlassian.confluence.impl.backuprestore.backup.exporters.BodyContentDataExporter.extractReferencesFromBody(BodyContentDataExporter.java:162)
at com.atlassian.confluence.impl.backuprestore.backup.exporters.BodyContentDataExporter.extractReferencesFromBody(BodyContentDataExporter.java:130)
at com.atlassian.confluence.impl.backuprestore.backup.exporters.BodyContentDataExporter.lambda$exportInBatchByQueryWithCondition$0(BodyContentDataExporter.java:99)
... 4 more
```

So what. I agree, if I have workaround. But it is strange anyway


author: Tony Montana
body: [@Radek Dost?l](/t5/user/viewprofilepage/user-id/715713)

```
2023-11-22 14:27:32,793 INFO [ConfluenceBackupRestoreManager:thread-11] [impl.backuprestore.backup.SpaceBackupService] doBackupSynchronously SPACE backup [17727492] with keys [ADH] has started.
2023-11-22 14:27:32,803 INFO [ConfluenceBackupRestoreManager:thread-11] [impl.backuprestore.backup.AbstractBackupService] performBackup SPACE backup [17727492] is now backing up entities and attachments.
2023-11-22 14:27:37,732 WARN [ConfluenceBackupRestoreManager:thread-11] [confluence.impl.backuprestore.ConfluenceBackupRestoreManager] updateJobStateAfterCompletion Backup restore job BackupRestoreJob{id=17727492, jobOperation=BACKUP, jobScope=SPACE, jobState=PROCESSING, createTime=2023-11-22T12:27:32Z, startProcessingTime=2023-11-22T12:27:32Z, finishProcessingTime=null, cancelTime=null, owner='montana@supersite.net', whoCancelledTheJob='null', errorMessage='null'} failed: java.util.concurrent.ExecutionException: java.lang.NullPointerException: Cannot invoke \"com.atlassian.sal.api.user.UserKey.getStringValue()\" because \"userKey\" is null
-- url: /rest/api/backup-restore/backup/space | userName: montana@supersite.net | referer: https://kb.supersite.net/plugins/servlet/backup-and-restore/backup | traceId: f15aa0cdb33b028a
com.atlassian.confluence.backuprestore.exception.BackupRestoreException: java.util.concurrent.ExecutionException: java.lang.NullPointerException: Cannot invoke "com.atlassian.sal.api.user.UserKey.getStringValue()" because "userKey" is null
at com.atlassian.confluence.impl.backuprestore.backup.SpaceBackupService.doBackupSynchronously(SpaceBackupService.java:124)
at com.atlassian.confluence.impl.backuprestore.BackupRestoreJobRunner.runJobSynchronously(BackupRestoreJobRunner.java:58)
at com.atlassian.confluence.impl.backuprestore.ConfluenceBackupRestoreManager.runJobAndUpdateJobProperties(ConfluenceBackupRestoreManager.java:271)
at com.atlassian.confluence.impl.backuprestore.ConfluenceBackupRestoreManager.processJobsFromTheQueue(ConfluenceBackupRestoreManager.java:250)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.util.concurrent.ExecutionException: java.lang.NullPointerException: Cannot invoke "com.atlassian.sal.api.user.UserKey.getStringValue()" because "userKey" is null
at java.base/java.util.concurrent.FutureTask.report(Unknown Source)
at java.base/java.util.concurrent.FutureTask.get(Unknown Source)
at com.atlassian.confluence.impl.backuprestore.ParallelTasksExecutor.waitUntilAllTasksComplete(ParallelTasksExecutor.java:119)
at com.atlassian.confluence.impl.backuprestore.ParallelTasksExecutor.waitUntilAllStageJobsComplete(ParallelTasksExecutor.java:92)
at com.atlassian.confluence.impl.backuprestore.ParallelTasksExecutor.waitUntilAllStageJobsComplete(ParallelTasksExecutor.java:108)
at com.atlassian.confluence.impl.backuprestore.backup.SpaceBackupService.backupAllEntitiesAndAttachments(SpaceBackupService.java:167)
at com.atlassian.confluence.impl.backuprestore.backup.AbstractBackupService.performBackup(AbstractBackupService.java:75)
at com.atlassian.confluence.impl.backuprestore.backup.SpaceBackupService.doBackupSynchronously(SpaceBackupService.java:107)
... 8 more
Caused by: java.lang.NullPointerException: Cannot invoke "com.atlassian.sal.api.user.UserKey.getStringValue()" because "userKey" is null
at com.atlassian.confluence.impl.backuprestore.backup.exporters.UserKeyExtractorFragmentTransformer.lambda$getReferences$0(UserKeyExtractorFragmentTransformer.java:67)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
at java.base/java.util.HashMap$KeySpliterator.forEachRemaining(Unknown Source)
at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source)
at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
at java.base/java.util.stream.ReferencePipeline.collect(Unknown Source)
at com.atlassian.confluence.impl.backuprestore.backup.exporters.UserKeyExtractorFragmentTransformer.getReferences(UserKeyExtractorFragmentTransformer.java:68)
at com.atlassian.confluence.impl.backuprestore.backup.exporters.ReferenceEntityFromBodyContentExtractor.lambda$extractReferenceContentFrom$1(ReferenceEntityFromBodyContentExtractor.java:85)
at java.base/java.util.stream.ReferencePipeline$7$1.accept(Unknown Source)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(Unknown Source)
at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(Unknown Source)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(Unknown Source)
at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
at java.base/java.util.stream.ReferencePipeline.forEach(Unknown Source)
at com.atlassian.confluence.impl.backuprestore.backup.exporters.ReferenceEntityFromBodyContentExtractor.extractReferenceContentFrom(ReferenceEntityFromBodyContentExtractor.java:90)
at com.atlassian.confluence.impl.backuprestore.backup.exporters.BodyContentDataExporter.extractReferencesFromBody(BodyContentDataExporter.java:162)
at com.atlassian.confluence.impl.backuprestore.backup.exporters.BodyContentDataExporter.extractReferencesFromBody(BodyContentDataExporter.java:130)
at com.atlassian.confluence.impl.backuprestore.backup.exporters.BodyContentDataExporter.lambda$exportInBatchByQueryWithCondition$0(BodyContentDataExporter.java:99)
... 4 more
```

I agree, it's not important since I have a workaround. But it's still strange and I'd like to know the reason


author: Tony Montana
body: [@Radek Dost?l](/t5/user/viewprofilepage/user-id/715713) Anyway, I got workaround, I think it is enough. :)


author: Radek Dost?l
body: Yeah, if workaround works then it's all good.

The most I can read from this is

```
Caused by: java.lang.NullPointerException: Cannot invoke "com.atlassian.sal.api.user.UserKey.getStringValue()" because "userKey" is null
 [[
    at com.atlassian.confluence.impl.backuprestore.backup.exporters.UserKeyExtractorFragmentTransformer.lambda$getReferences$0(UserKeyExtractorFragmentTransformer.java:67)
 ]]
 finally dying trying to extract some missing userkey

 [[
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
    at java.base/java.util.HashMap$KeySpliterator.forEachRemaining(Unknown Source)
    at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
    at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source)
    at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
    at java.base/java.util.stream.ReferencePipeline.collect(Unknown Source)
 ]]
 more stream noise, collecting those references

 [[
    at com.atlassian.confluence.impl.backuprestore.backup.exporters.UserKeyExtractorFragmentTransformer.getReferences(UserKeyExtractorFragmentTransformer.java:68)
 ]]
 getting key references from something

 [[
    at com.atlassian.confluence.impl.backuprestore.backup.exporters.ReferenceEntityFromBodyContentExtractor.lambda$extractReferenceContentFrom$1(ReferenceEntityFromBodyContentExtractor.java:85)
 ]]
 body content

 [[
    at java.base/java.util.stream.ReferencePipeline$7$1.accept(Unknown Source)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
    at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(Unknown Source)
    at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
    at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(Unknown Source)
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(Unknown Source)
    at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
    at java.base/java.util.stream.ReferencePipeline.forEach(Unknown Source)
 ]]
 stream noise

 [[
    at com.atlassian.confluence.impl.backuprestore.backup.exporters.ReferenceEntityFromBodyContentExtractor.extractReferenceContentFrom(ReferenceEntityFromBodyContentExtractor.java:90)
    at com.atlassian.confluence.impl.backuprestore.backup.exporters.BodyContentDataExporter.extractReferencesFromBody(BodyContentDataExporter.java:162)
 ]]
 ReferenceEntityFromBodyContentExtractor.extractReferenceContentFrom
 so extracting some references from body content
 
```

So at best, my next guess would have been some form of body content, but that could be anything, pages, comments, blogs. Personally if I had no workaround I'd start looking for comment author keys, then page authors/updaters, and finally whichever ways there are to reference another user. Pain either way.

Turning on TRACE loggers for these packages might also log something more useful, or enabling sql logging might give us a hint what *kind* of content it is getting before the thread starts processing it.

But anyway.. If it works it works.


Tags: confluence-server

server