Google Storage setup: JSON parse exception

Trying to get Google Storage set up for assets, and when nuxeo starts this is the error message I get:

Caused by: org.nuxeo.ecm.core.api.NuxeoException: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('/' (code 47)): maybe a (non-standard) comment? (not recognized as one since Feature 'ALLOW_COMMENTS' not enabled for parser)
 at [Source: (ByteArrayInputStream); line: 1, column: 2]
        at org.nuxeo.ecm.core.storage.gcp.GoogleStorageBinaryManager.setupCloudClient(GoogleStorageBinaryManager.java:125) ~[nuxeo-core-binarymanager-gcp-10.10-HF12.jar:?]
        at org.nuxeo.ecm.blob.AbstractCloudBinaryManager.initialize(AbstractCloudBinaryManager.java:122) ~[nuxeo-core-binarymanager-common-10.10-HF12.jar:?]
        at org.nuxeo.ecm.core.blob.BlobManagerComponent.getBlobProvider(BlobManagerComponent.java:191) ~[nuxeo-core-api-10.10.jar:?]
        at org.nuxeo.ecm.core.blob.BlobManagerComponent.getBlobProviderWithNamespace(BlobManagerComponent.java:202) ~[nuxeo-core-api-10.10.jar:?]
        at org.nuxeo.ecm.core.transientstore.keyvalueblob.KeyValueBlobTransientStore.getBlobProvider(KeyValueBlobTransientStore.java:180) ~[nuxeo-core-cache-10.10.jar:?]
        at org.nuxeo.ecm.core.transientstore.keyvalueblob.KeyValueBlobTransientStore.doGC(KeyValueBlobTransientStore.java:239) ~[nuxeo-core-cache-10.10.jar:?]
        at java.util.HashMap$Values.forEach(HashMap.java:976) ~[?:?]
        at org.nuxeo.ecm.core.transientstore.TransientStorageComponent.doGC(TransientStorageComponent.java:98) ~[nuxeo-core-cache-10.10.jar:?]
        at org.nuxeo.ecm.core.transientstore.TransiantStorageGCWork.work(TransiantStorageGCWork.java:41) ~[nuxeo-core-cache-10.10.jar:?]
        at org.nuxeo.ecm.core.work.AbstractWork.runWorkWithTransaction(AbstractWork.java:437) ~[nuxeo-core-event-10.10.jar:?]
        at org.nuxeo.ecm.core.work.AbstractWork.run(AbstractWork.java:357) ~[nuxeo-core-event-10.10.jar:?]
        ... 4 more
Caused by: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('/' (code 47)): maybe a (non-standard) comment? (not recognized as one since Feature 'ALLOW_COMMENTS' not enabled for parser)
 at [Source: (ByteArrayInputStream); line: 1, column: 2]
        at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1804) ~[jackson-core-2.9.8.jar:2.9.8]
        at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:693) ~[jackson-core-2.9.8.jar:2.9.8]
        at com.fasterxml.jackson.core.base.ParserMinimalBase._reportUnexpectedChar(ParserMinimalBase.java:591) ~[jackson-core-2.9.8.jar:2.9.8]
        at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._skipComment(UTF8StreamJsonParser.java:3104) ~[jackson-core-2.9.8.jar:2.9.8]
        at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._skipWSOrEnd2(UTF8StreamJsonParser.java:2984) ~[jackson-core-2.9.8.jar:2.9.8]
        at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._skipWSOrEnd(UTF8StreamJsonParser.java:2940) ~[jackson-core-2.9.8.jar:2.9.8]
        at com.fasterxml.jackson.core.json.UTF8StreamJsonParser.nextToken(UTF8StreamJsonParser.java:691) ~[jackson-core-2.9.8.jar:2.9.8]
        at com.google.api.client.json.jackson2.JacksonParser.nextToken(JacksonParser.java:55) ~[google-http-client-jackson2-1.19.0.jar:1.19.0]
        at com.google.api.client.json.JsonParser.startParsing(JsonParser.java:220) ~[google-http-client-1.19.0.jar:1.19.0]
        at com.google.api.client.json.JsonParser.parse(JsonParser.java:379) ~[google-http-client-1.19.0.jar:1.19.0]
        at com.google.api.client.json.JsonParser.parse(JsonParser.java:354) ~[google-http-client-1.19.0.jar:1.19.0]
        at com.google.api.client.json.JsonObjectParser.parseAndClose(JsonObjectParser.java:87) ~[google-http-client-1.19.0.jar:1.19.0]
        at com.google.api.client.json.JsonObjectParser.parseAndClose(JsonObjectParser.java:81) ~[google-http-client-1.19.0.jar:1.19.0]
        at com.google.auth.oauth2.GoogleCredentials.fromStream(GoogleCredentials.java:151) ~[google-auth-library-oauth2-http-0.15.0.jar:?]
        at com.google.auth.oauth2.GoogleCredentials.fromStream(GoogleCredentials.java:129) ~[google-auth-library-oauth2-http-0.15.0.jar:?]
        at org.nuxeo.ecm.core.storage.gcp.GoogleStorageBinaryManager.setupCloudClient(GoogleStorageBinaryManager.java:98) ~[nuxeo-core-binarymanager-gcp-10.10-HF12.jar:?]
        at org.nuxeo.ecm.blob.AbstractCloudBinaryManager.initialize(AbstractCloudBinaryManager.java:122) ~[nuxeo-core-binarymanager-common-10.10-HF12.jar:?]
        at org.nuxeo.ecm.core.blob.BlobManagerComponent.getBlobProvider(BlobManagerComponent.java:191) ~[nuxeo-core-api-10.10.jar:?]
        at org.nuxeo.ecm.core.blob.BlobManagerComponent.getBlobProviderWithNamespace(BlobManagerComponent.java:202) ~[nuxeo-core-api-10.10.jar:?]
        at org.nuxeo.ecm.core.transientstore.keyvalueblob.KeyValueBlobTransientStore.getBlobProvider(KeyValueBlobTransientStore.java:180) ~[nuxeo-core-cache-10.10.jar:?]
        at org.nuxeo.ecm.core.transientstore.keyvalueblob.KeyValueBlobTransientStore.doGC(KeyValueBlobTransientStore.java:239) ~[nuxeo-core-cache-10.10.jar:?]
        at java.util.HashMap$Values.forEach(HashMap.java:976) ~[?:?]
        at org.nuxeo.ecm.core.transientstore.TransientStorageComponent.doGC(TransientStorageComponent.java:98) ~[nuxeo-core-cache-10.10.jar:?]
        at org.nuxeo.ecm.core.transientstore.TransiantStorageGCWork.work(TransiantStorageGCWork.java:41) ~[nuxeo-core-cache-10.10.jar:?]
        at org.nuxeo.ecm.core.work.AbstractWork.runWorkWithTransaction(AbstractWork.java:437) ~[nuxeo-core-event-10.10.jar:?]
        at org.nuxeo.ecm.core.work.AbstractWork.run(AbstractWork.java:357) ~[nuxeo-core-event-10.10.jar:?]
        ... 4 more

The error seems to have something to do with the “\n” in the `private_key` value of the Google Service Account JSON key, which I don't think I should remove. Has anybody run into this problem and know how to fix it?

0 votes

1 answers

44 views

ANSWER



Hello, I've faced some issues related to the JSON structure. It should look like (data anonymized obviously, but you'll get the idea):

nuxeo.gcp.credentials={"type":"service_account","project_id":"my-super-project","private_key_id":"1234","private_key":"-----BEGIN PRIVATE KEY-----\\nXXXX/\\nXXXX
\\nXXXX/ricLjO2jedTdm/XSwMst7Gp2/RNzk2iQLYhiQoERmY/ZFI1qJVFGaIk\\nNm152wluobxo+Cmu9z74hT8a3i4GGaozrZKQ4ooRE034auKkeeQfytKDQsrr4u2r\\nXXXX/c3zEvIKktybAXofp2G4NBRGqmKobZDU1ZquI5KKZjYBtS47JhY19nXqYw\\n9BytmKRxTOLoGVhxTOaWIrMmfWxw0H4j3F+2wreJOOoT1zHDh1nx4fHx6/DoNEyU\\nViyrjmWjAgMBAAECggEAK6JzUyop9gPzgYzhMe/te81IIQvwL7/LLOVRKw6HvJ7H\\nXXXX/W0Ic9zhapOniy7x8AOqupkOhpYOAu0[....]/r\\n-----END PRIVATE KEY-----\\n","client_email":"somebody@super-project.iam.gserviceaccount.com","client_id":"123456","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_x509_cert_url":"https://www.googleapis.com/robot/v1/metadata/x509/nuxeo-storage-toto%40superproject.iam.gserviceaccount.com"}
0 votes



Does the JSON have to be put directly into the config file like that? I thought that nuxeo.gcp.credentials was supposed to point to the file that contains the JSON.
03/24/2020

I'm experiencing a similar issue. I have to enter the JSON string in nuxeo.conf at nuxeo.gcp.credentials config parameter. Otherwise, I get the error list above. The key piece to getting mine to connect was escaping the \n with \n and adding a \r right before the 'END PRIVATE KEY' (/r\n—–END PRIVATE KEY—–).
03/31/2020