Java NullPointerException when importing a Confluence space using CLI
Asked by Karen Tsai:

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!


Answers:
author: Karen Tsai
body: 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....


author: Karen Tsai
body: 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

comments: author: Bob Swift (personal)
body: No, nothing CLI related. Note that the new ACLI versions are no longer OSS - see [Atlassian CLI license](https://bobswift.atlassian.net/wiki/display/ACLI/Atlassian+CLI+license)


author: Karen Tsai
body: 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=\*\*\*](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=\*\*\*](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.

comments: author: Bob Swift (personal)
body: 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](java-nullpointerexception-when-importing-a-confluence-space-using-cli/182045) .


author: Karen Tsai
body: 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=\*\*\*](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=\*\*\*](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.


author: Karen Tsai
body: 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=\*\*\*](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=\*\*\*](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.

comments: author: Bob Swift (personal)
body: **Remote error: No local file specified** says that it is not finding the file named. Double check that. Otherwise, it looks like correct usage.


author: Karen Tsai
body: 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=\*\*\*](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=\*\*\*](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)


author: Bob Swift (personal)
body: 1. Try with the current version of the CLI
2. If it is still a problem, [open an issue](https://bobswift.atlassian.net/browse/CSOAP)
3. Provide the output of the command when used with the **--debug** parameter