Java NullPointerException when importing a Confluence space using CLI

Our Confluence version is 4.1.10, and I am using CLI 2.6. When I do the following command to import (or restore) a space, I always get the message "Exception: java.lang.NullPointerException", and nothing is done.

confluence.sh --action restoreExport --file "10002-130536-8.xml.zip"

The file is saved under <conf_home>/restore, and I think the syntax is correct. What is the problem here?

When I use the same file to do the restore from the Confluence UI, it is working.

Thank you in advance for any help!

7 answers

  1. Try with the current version of the CLI
  2. If it is still a problem, open an issue
  3. Provide the output of the command when used with the --debug parameter

Got more detailed output by supplying -v option:

confluence.sh --action restoreExport --file "10002-130536-8.xml.zip" -v

Server address: http://xxxxxxxx/confluence/rpc/soap-axis/confluenceservice-v1

Successful login to: http://xxxxxxxx/confluence/rpc/soap-axis/confluenceservice-v1 by user: asconfcli. Token is xxxxxxxx

Post data: buildIndex=true&localFileName=10002-130536-8.xml.zip

URL requested: http://xxxxxxxx/confluence/admin/restore-local-file.action?os_username=asconfcli&os_password=***

Request type: POST

Content type: application/url_encoded

Post data: buildIndex=true&localFileName=10002-130536-8.xml.zip

Response code: 302, message: Found, url: http://xxxxxxxx/confluence/admin/restore-local-file.action?os_username=asconfcli&os_password=***

xxxxxxxx logged out.

Exception: java.lang.NullPointerException

java.lang.NullPointerException

at java.util.regex.Matcher.getTextLength(Matcher.java:1140)

at java.util.regex.Matcher.reset(Matcher.java:291)

at java.util.regex.Matcher.<init>(Matcher.java:211)

at java.util.regex.Pattern.matcher(Pattern.java:888)

at org.swift.confluence.cli.ConfluenceRestClient.parseResultData(ConfluenceRestClient.java:135)

at org.swift.confluence.cli.ConfluenceRestClient.restRequest(ConfluenceRestClient.java:282)

at org.swift.confluence.cli.ConfluenceClient.restoreExport(ConfluenceClient.java:3861)

at org.swift.confluence.cli.ConfluenceClient.handleRequest(ConfluenceClient.java:658)

at org.swift.common.cli.AbstractRemoteClient.process(AbstractRemoteClient.java:119)

at org.swift.common.cli.CliClient.doWork(CliClient.java:298)

at org.swift.confluence.cli.ConfluenceClient.main(ConfluenceClient.java:130)

Bob,

Thanks for your quick response. I am able to get further after turning off our custom authentication on the Confluence applications. Now, the new error is "Remote error: No local file specified". Please see below. Do you happen to know the cause of the issue here?

$ ./confluence.sh --action restoreExport --file 10002-130536-8.xml.zip -v

Server address: https://xxxxxxxx/confluence/rpc/soap-axis/confluenceservice-v1

Successful login to: https://xxxxxxxx.stanford.edu/confluence/rpc/soap-axis/confluenceservice-v1 by user: asconfcli. Token is xxxxxxxx

Post data: buildIndex=true&localFileName=10002-130536-8.xml.zip

URL requested: https://xxxxxxxx/confluence/admin/restore-local-file.action?os_username=asconfcli&os_password=***

Request type: POST

Content type: application/url_encoded

Post data: buildIndex=true&localFileName=10002-130536-8.xml.zip

Reading Key: JSESSIONID

Val: A1533641100CA52A6F54674BB8AA67EB

Response code: 200, message: OK, url: https://xxxxxxxx/confluence/admin/restore-local-file.action?os_username=asconfcli&os_password=***

Start of response data: <title>com.atlassian.confluence.importexport.actions.RestoreLocalFileAction.action.name -

Remote error: No local file specified

org.swift.common.cli.AbstractRemoteClient$RemoteRestException: No local file specified

at org.swift.confluence.cli.ConfluenceRestClient.parseResultData(ConfluenceRestClient.java:167)

at org.swift.confluence.cli.ConfluenceRestClient.restRequest(ConfluenceRestClient.java:282)

at org.swift.confluence.cli.ConfluenceClient.restoreExport(ConfluenceClient.java:3861)

at org.swift.confluence.cli.ConfluenceClient.handleRequest(ConfluenceClient.java:658)

at org.swift.common.cli.AbstractRemoteClient.process(AbstractRemoteClient.java:119)

at org.swift.common.cli.CliClient.doWork(CliClient.java:298)

at org.swift.confluence.cli.ConfluenceClient.main(ConfluenceClient.java:130)

2ve04M0Cc9 logged out.

Remote error: No local file specified says that it is not finding the file named. Double check that. Otherwise, it looks like correct usage.

Hi Bob,

I put the file under <conf_home>/restore:

$ ls -l /opt/asconf/confluence_data/restore/10002-130536-8.xml.zip

-rw-r--r-- 1 asconf asconf 14926694 Jun 19 13:05 /opt/asconf/confluence_data/restore/10002-130536-8.xml.zip

I also tried to give the entire path to the file, but it still returned "Remote error: No local file specified".

I have one more question... how does the CLI know where my confluence home directory is?

Thanks for all your help.

Karen

$ ./confluence.sh --action restoreExport --file "/opt/asconf/confluence_data/restore/10002-130536-8.xml.zip" -v

Server address: https://xxxxxxxxxxxxxxxx/confluence/rpc/soap-axis/confluenceservice-v1

Successful login to: https://xxxxxxxxxxxxxxxxxxxxxx/confluence/rpc/soap-axis/confluenceservice-v1 by user: asconfcli. Token is G2YEEe8cqm

Post data: buildIndex=true&localFileName=%2Fopt%2Fasconf%2Fconfluence_data%2Frestore%2F10002-130536-8.xml.zip

URL requested: https://xxxxxxxxxxxxxxxxxxxx/confluence/admin/restore-local-file.action?os_username=asconfcli&os_password=***

Request type: POST

Content type: application/url_encoded

Post data: buildIndex=true&localFileName=%2Fopt%2Fasconf%2Fconfluence_data%2Frestore%2F10002-130536-8.xml.zip

Reading Key: JSESSIONID

Val: 7E47C05D924ADFA69ECED92961126621

Response code: 200, message: OK, url: https://xxxxxxxxxxxxxxxxxxxx/confluence/admin/restore-local-file.action?os_username=asconfcli&os_password=***

Start of response data: <title>com.atlassian.confluence.importexport.actions.RestoreLocalFileAction.action.name -

Remote error: No local file specified

org.swift.common.cli.AbstractRemoteClient$RemoteRestException: No local file specified

at org.swift.confluence.cli.ConfluenceRestClient.parseResultData(ConfluenceRestClient.java:167)

at org.swift.confluence.cli.ConfluenceRestClient.restRequest(ConfluenceRestClient.java:282)

at org.swift.confluence.cli.ConfluenceClient.restoreExport(ConfluenceClient.java:3861)

at org.swift.confluence.cli.ConfluenceClient.handleRequest(ConfluenceClient.java:658)

at org.swift.common.cli.AbstractRemoteClient.process(AbstractRemoteClient.java:119)

at org.swift.common.cli.CliClient.doWork(CliClient.java:298)

at org.swift.confluence.cli.ConfluenceClient.main(ConfluenceClient.java:130)

G2YEEe8cqm logged out.

Hi Bob,

I put the file under <conf_home>/restore:

$ ls -l /opt/asconf/confluence_data/restore/10002-130536-8.xml.zip

-rw-r--r-- 1 asconf asconf 14926694 Jun 19 13:05 /opt/asconf/confluence_data/restore/10002-130536-8.xml.zip

I also tried to give the entire path to the file, but it still returned "Remote error: No local file specified".

I have one more question... how does the CLI know where my confluence home directory is?

Thanks for all your help.

Karen

$ ./confluence.sh --action restoreExport --file "/opt/asconf/confluence_data/restore/10002-130536-8.xml.zip" -v

Server address: https://xxxxxxxxxxxxxxxx/confluence/rpc/soap-axis/confluenceservice-v1

Successful login to: https://xxxxxxxxxxxxxxxxxxxxxx/confluence/rpc/soap-axis/confluenceservice-v1 by user: asconfcli. Token is G2YEEe8cqm

Post data: buildIndex=true&localFileName=%2Fopt%2Fasconf%2Fconfluence_data%2Frestore%2F10002-130536-8.xml.zip

URL requested: https://xxxxxxxxxxxxxxxxxxxx/confluence/admin/restore-local-file.action?os_username=asconfcli&os_password=***

Request type: POST

Content type: application/url_encoded

Post data: buildIndex=true&localFileName=%2Fopt%2Fasconf%2Fconfluence_data%2Frestore%2F10002-130536-8.xml.zip

Reading Key: JSESSIONID

Val: 7E47C05D924ADFA69ECED92961126621

Response code: 200, message: OK, url:https://xxxxxxxxxxxxxxxxxxxx/confluence/admin/restore-local-file.action?os_username=asconfcli&os_password=***

Start of response data: <title>com.atlassian.confluence.importexport.actions.RestoreLocalFileAction.action.name -

Remote error: No local file specified

org.swift.common.cli.AbstractRemoteClient$RemoteRestException: No local file specified

at org.swift.confluence.cli.ConfluenceRestClient.parseResultData(ConfluenceRestClient.java:167)

at org.swift.confluence.cli.ConfluenceRestClient.restRequest(ConfluenceRestClient.java:282)

at org.swift.confluence.cli.ConfluenceClient.restoreExport(ConfluenceClient.java:3861)

at org.swift.confluence.cli.ConfluenceClient.handleRequest(ConfluenceClient.java:658)

at org.swift.common.cli.AbstractRemoteClient.process(AbstractRemoteClient.java:119)

at org.swift.common.cli.CliClient.doWork(CliClient.java:298)

at org.swift.confluence.cli.ConfluenceClient.main(ConfluenceClient.java:130)

G2YEEe8cqm logged out.

Your first approach was the correct way to do it. The CLI makes the request to the server similar to the how it is done via the UI (and similar to how you would do it via a curl command). The url used which has the file name you provide should match the url used under the covers when the action is done via UI. The server is the one that knows and finds the file in the home directory.

It would be easier if you followed the instructions from https://answers.atlassian.com/questions/182020/java-nullpointerexception-when-importing-a-confluence-space-using-cli/182045 .

Hi Bob,

It works after I use the current version of CLI. Thanks!

Another quick question, is there any way to turn off the re-indexing at the restore. We have about 300 spaces to import, so I would like to do the re-indexing once at the end after all of the 300 spaces are imported. Or, does the "restoreExport" can do the bulk import, such that it will do all files under <conf_home>/restore directory so I don't need to do 300 CLI restoreExport commands with each file specified.

Thanks again for all your help. The CLI you wrote is such an amazing tool!

Thanks,

Karen

No, nothing CLI related. Note that the new ACLI versions are no longer OSS - see Atlassian CLI license

If we cannot turn off the re-indexing for each restoreExport command, I wonder how the indexing would react when I issue 300 commands for 300 spaces import..... We might need to use the UI to do the import since we can uncheck the "index" option there....

Suggest an answer

Log in or Sign up to answer
Community showcase
Published 9 hours ago in Confluence Cloud

Happy holidays from our team to yours!

Hi Community!  2018 was filled with changes for our team, both big and small, and we've taken a lot of time to both celebrate our wins and recognize areas of improvement. One thing that we're a...

86 views 0 11
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you