Hello everyone,
I have a problem I have been wrestling with for most of the day so I hope someone can shine some light on this for me. This is the error I receive:
java.lang.reflect.InvocationTargetException
org.bonitasoft.engine.bpm.connector.ConnectorExecutionException: USERNAME=install | org.bonitasoft.engine.core.connector.exception.SConnectorException: org.bonitasoft.engine.connector.exception.SConnectorException: java.util.concurrent.ExecutionException: java.lang.NullPointerException
Test file locations include:
/home/gary/bonita/BonitaStudioCommunity-7.7.0/jre/lib
/home/gary/bonita/BonitaStudioCommunity-7.7.0/workspace/default/bin/org/mycompany/connector
/home/gary/bonita/BonitaStudioCommunity-7.7.0/workspace/default/connectors-impl
Below is my code (excuse the mess I’ve been hacking it around all day!). The line of code is highlighted by *****This is the line of code. I should point out, this is a test to see if I can locate where to load resources.
Thanks
Gary
package org.mycompany.connector;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.security.GeneralSecurityException;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Logger;
import java.lang.ClassLoader;
import java.net.URISyntaxException;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.bonitasoft.engine.connector.ConnectorException;
import org.bonitasoft.engine.connector.ConnectorValidationException;
import com.google.api.client.auth.oauth2.Credential;
import com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp;
import com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver;
import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow;
import com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets;
import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.api.client.util.store.MemoryDataStoreFactory;
import com.google.api.services.sheets.v4.Sheets;
import com.google.api.services.sheets.v4.SheetsScopes;
import com.google.api.services.sheets.v4.model.ValueRange;
ClassLoader classLoader = this.getClass().getClassLoader();
//LOGGER.info("class= " + classLoader.toString());
if (classLoader == null)
LOGGER.info(“class=null”);
LOGGER.info("Past classLoader");
LOGGER.info("The file is = " + this.fileName);
try {
LOGGER.info("In Try");
*****This is the line of code
Path path = Paths.get(GSv4ReadImpl.class.getResource(“Test”).toURI());
if (path == null)
LOGGER.info("path=null");
LOGGER.info("The file path is = " + path);
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
InputStream in = GSv4ReadImpl.class.getResourceAsStream("client_secret.json");
//InputStream in = classLoader.getResourceAsStream("client_secret.json");
LOGGER.info("Past getResourceAsStream");
if (in == null)
LOGGER.info("stream is null");
//LOGGER.info("InputStream " + in.toString());
GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JacksonFactory.getDefaultInstance(), new InputStreamReader(in));
LOGGER.info("clientSecrets 2 = " + clientSecrets.size());
List<String> scopes = Arrays.asList(SheetsScopes.SPREADSHEETS);
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(GoogleNetHttpTransport.newTrustedTransport(), JacksonFactory.getDefaultInstance(), clientSecrets, scopes).setDataStoreFactory(new MemoryDataStoreFactory())
.setAccessType("offline").build();
Credential credential = new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("user");
return credential;
}