Probleme connecteur Excel

1
0
-1

Bonjour.

Lorsque j'utilise des connecteurs qui me servent à lire dans des fichiers Excel, j'ai régulièrement des échecs dans le lancement de tâche qui utilisent ces connecteurs. Généralement les 3 premiers essais fonctionnent, et à partir du 4eme essai ça échoue. Je dois alors fermé et redémarrer Bonita BPM pour recommencer le cycle.

Lorsque le problème survient, j'ai les logs suivants :

2014-06-04 16:56:57 org.bonitasoft.engine.api.impl.ProcessStarter
Infos: THREAD_ID=51 | HOSTNAME=W28323 | TENANT_ID=1 | The user <YLombardi> has started the process instance <4> of process <LecturePipeRelease> in version <1.0> and id <5400778236262692958>
2014-06-04 16:56:57 org.bonitasoft.engine.execution.work.FailureHandlingBonitaWork
Avertissement: THREAD_ID=86 | HOSTNAME=W28323 | TENANT_ID=1 | The work [ProcessInstanceContextWork: processInstanceId = 4] failed. The failure will be handled.
2014-06-04 16:56:57 org.bonitasoft.engine.execution.work.FailureHandlingBonitaWork
Avertissement: THREAD_ID=86 | HOSTNAME=W28323 | TENANT_ID=1 | org.bonitasoft.engine.core.connector.exception.SConnectorException : "PROCESS_DEFINITION_ID=5400778236262692958 | PROCESS_NAME=LecturePipeRelease | PROCESS_VERSION=1.0 | PROCESS_INSTANCE_ID=4 | ROOT_PROCESS_INSTANCE_ID=4 | FLOW_NODE_DEFINITION_ID=-8787642490530830311 | FLOW_NODE_INSTANCE_ID=16 | FLOW_NODE_NAME=Lecture Liste Id Release | CONNECTOR_DEFINITION_IMPLEMENTATION_CLASS_NAME=LectureListeNumeroReleases | CONNECTOR_INSTANCE_ID=7 | org.bonitasoft.engine.connector.exception.SConnectorException: java.util.concurrent.ExecutionException: java.lang.ExceptionInInitializerError"
2014-06-04 16:56:58 org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/bonita].[jsp]
Précis:  Disabling the response for futher output

Si quelqu'un a une idée sur le pourquoi de ce problème, ça m'aiderait pas mal. Merci d'avance.

Comments

Submitted by yannick.lombardi on Fri, 06/06/2014 - 11:59

J'ai essayé de simplifier au maximum mon connecteur pour voir d'où peut venir le problème mais je suis toujours bloqué.

Voici mon connecteur :

/**
 *
 */

package org.mycompany.connector;

import org.bonitasoft.engine.connector.ConnectorException;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.io.File;

/**
 *The connector execution will follow the steps
 * 1 - setInputParameters() --> the connector receives input parameters values
 * 2 - validateInputParameters() --> the connector can validate input parameters values
 * 3 - connect() --> the connector can establish a connection to a remote server (if necessary)
 * 4 - executeBusinessLogic() --> execute the connector
 * 5 - getOutputParameters() --> output are retrieved from connector
 * 6 - disconnect() --> the connector can close connection to remote server (if any)
 */

public class TestExcelSimpleImpl extends AbstractTestExcelSimpleImpl {

        @Override
        protected void executeBusinessLogic() throws ConnectorException{
                //Get access to the connector input parameters
       
                //TODO execute your business logic here
                String output1 = getData("D:\\Doc stage\\essai.xlsm", "Feuil1");
       
                //WARNING : Set the output of the connector execution. If outputs are not set, connector fails
                setOutput1(output1);
       
         }

        @Override
        public void connect() throws ConnectorException{
                //[Optional] Open a connection to remote server
       
        }

        @Override
        public void disconnect() throws ConnectorException{
                //[Optional] Close connection to remote server
       
        }      

    public static String getData(String nomFichier, String nomOnglet) {
        Workbook workbook = openWorkbook(nomFichier);
        Sheet sheet = workbook.getSheet(nomOnglet);
        Row row = sheet.getRow(0);
        Cell cell = row.getCell(0);
        return cell.getStringCellValue();
    }

    public static Workbook openWorkbook(String nomFichier) {
        File file = new File(nomFichier);
        try {
            OPCPackage pkg = OPCPackage.open(file);
            XSSFWorkbook wb = new XSSFWorkbook(pkg);
            pkg.close();
            return wb;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

}

J'ai importé tous les jars concernant Apache Poi pour la lecture dans Excel.

Ce connecteur fonctionne parfaitement bien les 4 premières fois que je l'utilise, mais après ça ça plante. Et la seule piste que j'ai c'est les logs.

2014-06-06 11:52:43 org.bonitasoft.engine.api.impl.transaction.process.DisableProcess
Infos: THREAD_ID=37 | HOSTNAME=W28323 | TENANT_ID=1 | The user <YLombardi> has disabled process <Pool4> in version <1.0> with id <6026270127151785568>
2014-06-06 11:52:45 org.bonitasoft.engine.api.impl.ProcessManagementAPIImplDelegate
Infos: THREAD_ID=37 | HOSTNAME=W28323 | TENANT_ID=1 | The user <YLombardi> has deleted process with id = <6026270127151785568>
2014-06-06 11:52:48 org.bonitasoft.engine.api.impl.ProcessAPIImpl
Infos: THREAD_ID=37 | HOSTNAME=W28323 | TENANT_ID=1 | The user <YLombardi> has installed process <Pool4> in version <1.0> with id <5517258604722021641>
2014-06-06 11:52:48 org.bonitasoft.engine.api.impl.transaction.process.EnableProcess
Infos: THREAD_ID=37 | HOSTNAME=W28323 | TENANT_ID=1 | The user <YLombardi> has enabled process <Pool4> in version <1.0> with id <5517258604722021641>
2014-06-06 11:52:51 org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/bonita].[jsp]
Précis:  Disabling the response for futher output
2014-06-06 11:52:51 org.bonitasoft.engine.api.impl.ProcessStarter
Infos: THREAD_ID=50 | HOSTNAME=W28323 | TENANT_ID=1 | The user <YLombardi> has started the process instance <7> of process <Pool4> in version <1.0> and id <5517258604722021641>
2014-06-06 11:52:51 org.bonitasoft.engine.execution.work.FailureHandlingBonitaWork
Avertissement: THREAD_ID=87 | HOSTNAME=W28323 | TENANT_ID=1 | The work [ProcessInstanceContextWork: processInstanceId = 7] failed. The failure will be handled.
2014-06-06 11:52:51 org.bonitasoft.engine.execution.work.FailureHandlingBonitaWork
Avertissement: THREAD_ID=87 | HOSTNAME=W28323 | TENANT_ID=1 | org.bonitasoft.engine.core.connector.exception.SConnectorException : "PROCESS_DEFINITION_ID=5517258604722021641 | PROCESS_NAME=Pool4 | PROCESS_VERSION=1.0 | PROCESS_INSTANCE_ID=7 | ROOT_PROCESS_INSTANCE_ID=7 | FLOW_NODE_DEFINITION_ID=-7980742042625586070 | FLOW_NODE_INSTANCE_ID=18 | FLOW_NODE_NAME=Step1 | CONNECTOR_DEFINITION_IMPLEMENTATION_CLASS_NAME=sf | CONNECTOR_INSTANCE_ID=7 | org.bonitasoft.engine.connector.exception.SConnectorException: java.util.concurrent.ExecutionException: java.lang.ExceptionInInitializerError"

Mais je ne vois vraiment pas d'où provient le problème. De l'aide serait la bienvenue.

Merci d'avance.

Submitted by yannick.lombardi on Tue, 06/10/2014 - 10:01

Bonjour. Je me permet de remonter le sujet, je bloque toujours sur ce soucis. J'ai essayé différente méthode pour ouvrir lire dans mon fichier xlsm et j'ai exactement le même soucis quelle que soit la méthode.

Voici ce que j'ai testé :

public static String getData3(String nomFichier, String nomOnglet) {
        Workbook workbook = openWorkbook3(nomFichier);
        Sheet sheet = workbook.getSheet(nomOnglet);
        Row row = sheet.getRow(0);
        Cell cell = row.getCell(0);
        return cell.getStringCellValue();
    }
public static Workbook openWorkbook3(String nomFichier) {
        File file = new File(nomFichier);
        try {
            Workbook workbook = WorkbookFactory.create(file);
            return workbook;
        } catch (IOException e) {
            e.printStackTrace();
        } catch (InvalidFormatException e) {
            e.printStackTrace();
        }
        return null;
    }
 public static String getData2(String nomFichier, String nomOnglet) {
        XSSFWorkbook workbook = openWorkbook(nomFichier);
        XSSFSheet sheet = workbook.getSheet2(nomOnglet);
        XSSFRow row = sheet.getRow(0);
        XSSFCell cell = row.getCell(0);
        return cell.getStringCellValue();
    }
 public static XSSFWorkbook openWorkbook2(String nomFichier) {
        XSSFWorkbook excel;
        try {
            FileInputStream fileInputStream = new FileInputStream(nomFichier);
            excel = new XSSFWorkbook(fileInputStream);
            fileInputStream.close();
            return excel;
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
 public static String getData(String nomFichier, String nomOnglet) {
        XSSFWorkbook workbook = openWorkbook(nomFichier);
        XSSFSheet sheet = workbook.getSheet(nomOnglet);
        XSSFRow row = sheet.getRow(0);
        XSSFCell cell = row.getCell(0);
        return cell.getStringCellValue();
    }
public static XSSFWorkbook openWorkbook(String nomFichier) {
        File file = new File(nomFichier);
        try {
            OPCPackage pkg = OPCPackage.open(file);
            XSSFWorkbook wb = new XSSFWorkbook(pkg);
            pkg.close();
            return wb;
        } catch (InvalidFormatException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }

J'ai trouvé ces 3 méthodes sur le net, toutes fonctionnent sur Eclipse et autres IDE, mais aucunes ne fonctionnent plus de 5 fois une fois intégrée dans Bonita BPM. J'ai toujours droit à : org.bonitasoft.engine.connector.exception.SConnectorException: java.util.concurrent.ExecutionException: java.lang.ExceptionInInitializerError

Submitted by aurelien.pupier on Tue, 06/10/2014 - 12:02

Bonjour,

Peux-tu essayer en mettant les appels aux méthodes close dans un finally. Es-tu sur Windows? Utilises-tu Apache POI dans plusieurs process différents? Si oui, essaies de mettre les librairies au niveau du container (Tomcat/Jboss) et de ne pas les embarquer dans le .bar.

Cordialement,

Submitted by yannick.lombardi on Tue, 06/10/2014 - 14:43

Merci pour cette réponse.

Oui je suis sur Windows. J'utilise Apache Poi dans plusieurs processus. J'utilise le tomcat qui est fourni avec BonitaBPMCommunity-6.3.0. A quel endroit dois je placer les librairies pour qu'elles ne soient pas embarquées ?

Je viens d'ajouter les closes dans un finally et il y a déjà une amélioration. Je n'ai plus l'erreur "java.util.concurrent.ExecutionException: java.lang.ExceptionInInitializerError" qui apparait dans les logs. Par contre je passe dans le catch :

try {
                        output1 = getData("D:\\Doc stage\\essai.xlsm", "Feuil1");
                } catch (Exception e) {
                        output1 = e.toString();
                }

Il m'indique un NullPointerException.

Est ce qu'il est possible de rediriger les exceptions vers les logs pour avoir plus de détails ?

Submitted by aurelien.pupier on Tue, 06/10/2014 - 14:49

Pour inclure de slogs depuis un connecteur, voir l'exemple: http://documentation.bonitasoft.com/logging-overview#your_log

Il faut mettre les librairies dans workspace/tomcat/lib . /!\ il faut bien mettre également les dépendances. Il faut bien noter les librairies rajoutées afin de pouvoir les enlever si cela rentre en conflit avec d'autres choses plus tard et il faut bien enlevé toutes ce slibrairies des .bar.

Submitted by yannick.lombardi on Tue, 06/10/2014 - 16:55

J'ai ajouté un logger dans ma méthode executeBusinessLogic() mais je ne vois rien apparaitre de nouveau dans les logs. Il me semble pourtant bien avoir suivit les explications de : http://documentation.bonitasoft.com/logging-overview#your_log.

J'ai ajouté le jar slf4j-api dans les dépendences, j'ai ajouté le code dans ma méthode :

                Logger log = LoggerFactory.getLogger("org.bonitasoft.connector.testExcel");
                log.debug("TEST");

et j'ai mis le fichier logging.properties en mettant les lignes à FINEST :

org.bonitasoft.engine.core.connector.level = FINEST
org.bonitasoft.engine.connector.level = FINEST
org.bonitasoft.connector.testExcel = FINEST
org.bonitasoft.connector.handlers = 5bonita.org.apache.juli.FileHandler
org.bonitasoft.connector.level = FINEST

puis j'ai redémarré le Tomcat. Aucun "TEST" n'apparait dans le fichier de logs.

1 answer

1
+2
-1
This one is the BEST answer!

Au final je n'ai pas réussi à trouver d'où provenait le problème. J'ai par contre changé de librairie en optant pour Aspose plutôt que Apache Poi. Et là, plus le moindre soucis. Du coup le problème est contourné et mon connecteur fonctionne parfaitement.

Notifications