Salut à tous,

J'ai une exception en essayant de créer un process via la fonction exec de la classe Runtime.
J'essaye de lancer la commande wscompile (du JWSDP). Même en essayant de lancer la commande "dir", j'ai la même erreur:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
 
java.io.IOException: CreateProcess: wscompile -gen:client -d "C:\Documents and Settings\dme\.dum4ws\tmp\classes" -classpath "C:\Documents and Settings\dme\.dum4ws\tmp\classes" "C:\Documents and Settings\dme\.dum4ws\config-wsdl.xml" error=2
	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:464)
Quand je lance exactement la même commande dans une invite DOS, ça marche.

ça fait la même chose si je spécifie le patch complet de la commande wscompile.

Quelqu'un peut me dire ce qui ne va pas...

Pour info voilà ma classe qui lance la commande:
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
 
public class WSDL2JavaNoExit {
 
  public static Logger m_logger = Logger.getLogger(WSDL2JavaNoExit.class);
 
  /****
   * Lance wscompile
   */
  public static void run(String dir_out_stub) throws Exception{
        try {
      Runtime rt = Runtime.getRuntime();
      String cmd[] = new String[7];
      cmd[0] = "wscompile";
      cmd[1] = "-gen:client";
      cmd[2] = "-d";
      cmd[3] = dir_out_stub;
      cmd[4] = "-classpath";
      cmd[5] = dir_out_stub;
      cmd[6] = "L:\\config-wsdl.xml";
      m_logger.debug("Launch the command " + cmd);
      Process proc = rt.exec(cmd);
      // any error message?
      StreamGobbler errorGobbler = new StreamGobbler(proc.getErrorStream(), "ERROR");
      // any output?
      StreamGobbler outputGobbler = new StreamGobbler(proc.getInputStream(), "OUTPUT");
      // kick them off
      errorGobbler.start();
      outputGobbler.start();
      // any error???
      int exitVal = proc.waitFor();
      m_logger.debug("ExitValue: " + exitVal);
    }
    catch (Exception e) {
      m_logger.fatal("Exception catched",e);
    }
  }
}
 
/****
 * Récupère la sortie standard de la commande wscompile
 */
class StreamGobbler extends Thread
{
  public static Logger m_logger = Logger.getLogger(StreamGobbler.class);
  InputStream is;
  String type;
  StreamGobbler(InputStream is, String type) {
    this.is = is;
    this.type = type;
  }
 
  public void run() {
    try {
      InputStreamReader isr = new InputStreamReader(is);
      BufferedReader br = new BufferedReader(isr);
      String line = null;
      while ( (line = br.readLine()) != null)
        m_logger.debug(type + ">" + line);
    }
    catch (IOException ioe) {
      m_logger.error("Exception catched",ioe);
    }
  }
}
Merci
fifi