IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Servlets/JSP Java Discussion :

[débutant][servlet] erreur avec WordAPI.exe


Sujet :

Servlets/JSP Java

  1. #1
    Membre régulier
    Avatar de july
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    88
    Détails du profil
    Informations personnelles :
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations forums :
    Inscription : Janvier 2005
    Messages : 88
    Points : 98
    Points
    98
    Par défaut [débutant][servlet] erreur avec WordAPI.exe
    Bonjour à tous,
    J'utilise une servlet et l'api word pour générer automatiquement un document word à partir des données saisies par l'utilisateur sur mon application. Tout fonctionnait bien mais maintenant je reçois l'erreur suivante et je ne sais pas pourquoi :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
     
    java.io.IOException: CreateProcess: c:\WordProcessing\WordAPI.exe error=3
    	at java.lang.ProcessImpl.create(Native Method)
    	at java.lang.ProcessImpl.<init>(ProcessImpl.java:81)
    	at java.lang.ProcessImpl.start(ProcessImpl.java:30)
    	at java.lang.ProcessBuilder.start(ProcessBuilder.java:451)
    	at java.lang.Runtime.exec(Runtime.java:591)
    	at java.lang.Runtime.exec(Runtime.java:429)
    	at java.lang.Runtime.exec(Runtime.java:326)
    	at beans.WordProcessing.exec(WordProcessing.java:193)
    	at servlet.com.envMemoInt.doPost(envMemoInt.java:500)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
    	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:738)
    	at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
    	at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
    	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
    	at java.lang.Thread.run(Thread.java:595)
    c:/WordProcessing/WordAPI.exe could not be executed.
    Please ensure that WordAPI.exe may be found by java.exe by putting it in an appropriate directory.
    Je ne comprends vraiment pas !
    Quelqu'un sait ?

  2. #2
    Membre averti Avatar de guignol
    Inscrit en
    Mai 2002
    Messages
    309
    Détails du profil
    Informations forums :
    Inscription : Mai 2002
    Messages : 309
    Points : 339
    Points
    339
    Par défaut
    c:/WordProcessing/WordAPI.exe

    Ton exécutable wordAPi est bien accessible à ce chemin?

    Sinon fais voir le code stp qui invoque ton api WordAPI
    - Fais une recherche, c'est un conseil. Si je me mets à t'aider, tu vas pas t'en sortir

    - "Même avec les yeux grands ouverts, je n'y vois rien".

  3. #3
    Membre régulier
    Avatar de july
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    88
    Détails du profil
    Informations personnelles :
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations forums :
    Inscription : Janvier 2005
    Messages : 88
    Points : 98
    Points
    98
    Par défaut
    Voila ma la méthode dans ma servlet qui appelle le wordAPI.exe
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
     
    public static boolean exec() {
        closeWordInput();
        String cmd = "c:/WordProcessing/WordAPI.exe";
    	try {
    	 	Runtime run = Runtime.getRuntime();
    	 	Process p = run.exec(cmd);
           	p.waitFor();
    	 }
    	 catch (Exception e) {
    	 	e.printStackTrace();
    	 	System.out.println(cmd + " could not be executed.");
    	 	System.out.println("Please ensure that WordAPI.exe may be found by java.exe by putting it in an appropriate directory.");
    	 	return false;
    	 }
    	 return true;
      }
    J'ai vérifié quelque chose manuellement. Quand je double clique sur wordAPI.exe j'ai l'erreur suivante :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    The input file "WordInp.txt" couldn't be found.
     
    Did you already implement the java class WordProcessing?
     
    For further information press the documentation button to visit
    the java class description at http://www.must.de/Javactpe.htm
    Je ne sais pas si cela a un rapport...

  4. #4
    Membre averti Avatar de guignol
    Inscrit en
    Mai 2002
    Messages
    309
    Détails du profil
    Informations forums :
    Inscription : Mai 2002
    Messages : 309
    Points : 339
    Points
    339
    Par défaut
    L'erreur affichée concerne ton exécutable wordApi.exe : l'exécutable est trouvé mais une erreur à son exécution se produit (error=3).

    Je pense effectivement que ça peut venir de l'absence de wordInp.txt qui n'est pas trouvé, et engendre un blocage de l'exécution de ton wordAPI.
    - Fais une recherche, c'est un conseil. Si je me mets à t'aider, tu vas pas t'en sortir

    - "Même avec les yeux grands ouverts, je n'y vois rien".

  5. #5
    Membre régulier
    Avatar de july
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    88
    Détails du profil
    Informations personnelles :
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations forums :
    Inscription : Janvier 2005
    Messages : 88
    Points : 98
    Points
    98
    Par défaut
    En fait ce fichier se crée (normalement) automatiquement.
    Je place le code complet de ma servlet c'est peut etre mieu...
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
     
    public class WordProcessing {
     
      // define your standard:
      private static final boolean noteNotMatchingBookmarks = false; // shall the user be informed that certain bookmarks weren't found in the template?
      // end of standard definition
     
      private static File wordInput;
      private static FileWriter wordInputWriter;
     
      /**
       * Triggers to the template selection dialog and creates a new document
       * based on the chosen template.
       */
      public static void createNewDocumentFromTemplateToSelectByUser() {
        output("@createNewDocumentFromTemplate", "TEMPLATE_TO_SELECT_BY_USER");
      }
     
      /**
       * Creates a new document based on the desired template.
       * @param templateName the name of the template to be used
       */
      public static void createNewDocumentFromTemplate(String templateName) {
        output("@createNewDocumentFromTemplate", templateName);
      }
     
      /**
       * Set the warning flag about not matching bookmarks
       * Decides whether the user shall be informed that the template didn't
       * include certain bookmarks.
       * @param noteNotMatchingBookmarks whether the user should be warned
       */
      public static void setNoteNotMatchingBookmarks(boolean noteNotMatchingBookmarks) {
        if (noteNotMatchingBookmarks) output("@noteNotMatchingBookmarks", "TRUE");
        else output("@noteNotMatchingBookmarks", "FALSE");
      }
     
      /**
       * Goes to the specified bookmark and types the desired text.
       * @param bookmark the bookmark where text type starts
       * @param textToType the text to be included
       */
      public static void typeTextAtBookmark(String bookmark, String textToType) {
        output(bookmark, textToType);
      }
     
      /**
       * Goes to the specified bookmark and types the desired text with line feed.
       * @param linesToType the lines to be included
       */
      public static void typeTextAtBookmark(String bookmark, String[] linesToType) {
        StringBuffer textToType = new StringBuffer();
        for (int i=0; i < linesToType.length; i++) {
          textToType.append(linesToType[i] + "\n");
        }
        output(bookmark, new String(textToType));
      }
     
      /**
       * Sets the document directory for future document saving.
       * @param documentDirectory the name of the directory
       */
      public static void changeDocumentDirectory(String documentDirectory) {
        output("@changeDocumentDirectory", documentDirectory);
      }
     
      /**
       * Saves the active document using the indicated name
       * (usually without extension).
       * @param documentName the name of the document
       */
      public static void saveDocumentAs(String documentName) {
        output("@saveDocumentAs", documentName);
      }
     
      /**
       * Saves the active document using the indicated name and closes it.
       * @param documentName the name of the document
       */
      public static void saveDocumentAsAndClose(String documentName) {
        output("@saveDocumentAsAndClose", documentName);
      }
     
      /**
       * Closes the active document.
       */
      public static void closeDocument() {
        output("@closeDocument", "");
      }
     
      /**
       * Prints the document on the standard printer and closes the document without saving.
       */
      public static void printAndForget() {
        output("@printAndForget", "");
      }
     
      /**
       * Prints the document on the specified printer and closes the document without saving.
       * @param printerName the name of the desired printer
       */
      public static void printAndForget(String printerName) {
        output("@printAndForget", printerName);
      }
     
      /**
       * Triggers to the printer selection dialog, prints the document
       * on the selected printer and closes the document without saving.
       */
      public static void printToPrinterToSelectByUserAndForget() {
        output("@printAndForget", "PRINTER_TO_SELECT_BY_USER");
      }
     
      /**
       * Executes an arbitrary WordBasic macro.
       * @param macroName the name of the macro to be executed
       */
      public static void executeMacro(String macroName) {
        output("@executeMacro", macroName);
      }
     
      /**
       * Quits the word processing application.
       */
      public static void quitApplication() {
        output("@quitApplication", "");
      }
     
      /**
       * Quits the word processing application after a pause.
       * This gives the word processing time to finish e.g. a print job.
       * This avoids dialogs by the word processing system wether the print job is to stop
       */
      public static void quitApplicationAfterWaiting(int milliseconds) {
        output("@quitApplicationAfterWaiting", String.valueOf(milliseconds));
      }
     
      /**
       * Starts the execution of the above instructions.
       * (This stacking is particularly helpful at large numbers of standard letters.)
       * Always use use this as the last method of a sequence.
       */
      public static boolean exec() {
        closeWordInput();
        String cmd = "c:/WordProcessing/WordAPI.exe";
    	try {
    	 	Runtime run = Runtime.getRuntime();
    	 	Process p = run.exec(cmd);
           	p.waitFor();
    	 }
    	 catch (Exception e) {
    	 	e.printStackTrace();
    	 	System.out.println(cmd + " could not be executed.");
    	 	System.out.println("Please ensure that WordAPI.exe may be found by java.exe by putting it in an appropriate directory.");
    	 	return false;
    	 }
    	 return true;
      }
     
      /**
       * Annule le traitement en cours.
       */
      public static void cancel() {
        if (wordInputWriter != null) closeWordInput();
      }
     
      /**
       * Génération et initialisation d'une commande Word. 
       * @param key : commande.
       * @param value : paramètre de la commande.
       */
      private static void output(String key, String value) {
        String record;
        record = key;
        while (record.length() < 40) record += " ";
        record += value;
        if (wordInputWriter == null) {
          if (!openWordInput()){
          	return;
          }
        }
        try {
          wordInputWriter.write(record + "\r\n");
          wordInputWriter.flush();
        }
        catch ( IOException e2 ) {
          System.out.println( "caught: " + e2 );
        }
      }
     
      private static boolean openWordInput() {
        try {
        	/*Attention a ne pas changer le répertoire de location de WordInp.txt.*/
          wordInput = new File("WordInp.txt");
          wordInputWriter = new FileWriter(wordInput);
          setNoteNotMatchingBookmarks(noteNotMatchingBookmarks);
        }
        catch ( IOException e2 ) {
          System.out.println( "caught: " + e2 );
          System.out.println("could not open interface file WordInp.txt");
          return false;
        }
        return true;
      }
     
      private static void closeWordInput() {
        try {
          wordInputWriter.close();
          wordInput = null;
          wordInputWriter = null;
        }
        catch ( IOException e2 ) {
          System.out.println( "caught: " + e2 );
        }
      }
     
    }

  6. #6
    Membre averti Avatar de guignol
    Inscrit en
    Mai 2002
    Messages
    309
    Détails du profil
    Informations forums :
    Inscription : Mai 2002
    Messages : 309
    Points : 339
    Points
    339
    Par défaut
    quand tu crées ton wordInp.txt

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    private static boolean openWordInput() {
        try {
           /*Attention a ne pas changer le répertoire de location de WordInp.txt.*/
          wordInput = new File("WordInp.txt");
          wordInputWriter = new FileWriter(wordInput);
    Tu es sûre qu'il le crée au bon endroit?
    - Fais une recherche, c'est un conseil. Si je me mets à t'aider, tu vas pas t'en sortir

    - "Même avec les yeux grands ouverts, je n'y vois rien".

  7. #7
    Membre régulier
    Avatar de july
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    88
    Détails du profil
    Informations personnelles :
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations forums :
    Inscription : Janvier 2005
    Messages : 88
    Points : 98
    Points
    98
    Par défaut
    Non je ne suis sure de rien !
    Comme je ne spécifie pas le chemin d'accès j'imagine qu'il le crée dans le répertoire par défaut...
    Ce qui me parait bizarre c'est que cela fonctionnait et que du jour au lendemain ça ne marche plus !

  8. #8
    Membre averti Avatar de guignol
    Inscrit en
    Mai 2002
    Messages
    309
    Détails du profil
    Informations forums :
    Inscription : Mai 2002
    Messages : 309
    Points : 339
    Points
    339
    Par défaut
    Citation Envoyé par july
    Non je ne suis sure de rien !
    Comme je ne spécifie pas le chemin d'accès j'imagine qu'il le crée dans le répertoire par défaut...
    Ce qui me parait bizarre c'est que cela fonctionnait et que du jour au lendemain ça ne marche plus !
    Houla c'est pas top tout ça!

    Bon, ben vérifie ou est créé ton ptit fichier et si ton wordAPI peut y accéder (ce dont je doute...).
    - Fais une recherche, c'est un conseil. Si je me mets à t'aider, tu vas pas t'en sortir

    - "Même avec les yeux grands ouverts, je n'y vois rien".

  9. #9
    Membre régulier
    Avatar de july
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    88
    Détails du profil
    Informations personnelles :
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations forums :
    Inscription : Janvier 2005
    Messages : 88
    Points : 98
    Points
    98
    Par défaut
    Bon alors j'ai vérifié il me crée bien le fichier avec le chemin suivant : C:\WINNT\system32\WordInp.txt
    Quelqu'un a une idée du problème ?

  10. #10
    Membre averti Avatar de guignol
    Inscrit en
    Mai 2002
    Messages
    309
    Détails du profil
    Informations forums :
    Inscription : Mai 2002
    Messages : 309
    Points : 339
    Points
    339
    Par défaut
    Citation Envoyé par july
    Bon alors j'ai vérifié il me crée bien le fichier avec le chemin suivant : C:\WINNT\system32\WordInp.txt
    Quelqu'un a une idée du problème ?
    J'ai regardé un peu ce lien http://www.must.de/Javactpe.htm qui était marqué dans les erreurs, et là je sèche un peu sur ton problème...

    Je pense que c'est un problème de chemin lié à l'accès au fichier WordInp.tx. Essaie de créer ton fichier WordInp.txt dans le même répertoire que ton exécutable WordAPI.exe.
    - Fais une recherche, c'est un conseil. Si je me mets à t'aider, tu vas pas t'en sortir

    - "Même avec les yeux grands ouverts, je n'y vois rien".

  11. #11
    Membre régulier
    Avatar de july
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    88
    Détails du profil
    Informations personnelles :
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations forums :
    Inscription : Janvier 2005
    Messages : 88
    Points : 98
    Points
    98
    Par défaut
    Le chemin d'accès n'était effectivement pas le bon du coup il ne le trouvait pas !
    J'ai changé et ça remarche !
    Merci beaucoup guignol

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 4
    Dernier message: 04/08/2011, 10h26
  2. Grave erreur avec cl.exe
    Par esselfe dans le forum MFC
    Réponses: 2
    Dernier message: 16/06/2009, 17h01
  3. Réponses: 6
    Dernier message: 03/08/2006, 13h19
  4. [débutant][servlet]Problème avec Servlet login
    Par stago dans le forum Servlets/JSP
    Réponses: 2
    Dernier message: 10/05/2005, 00h05
  5. [Débutant][Applet] Communication avec Servlet - IO Exception
    Par gandalf_le_blanc dans le forum Applets
    Réponses: 35
    Dernier message: 16/04/2004, 13h29

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo