Author: chatellier Date: 2009-05-07 16:18:21 +0000 (Thu, 07 May 2009) New Revision: 2197 Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SubProcessSimulationLauncher.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/CompileHelper.java Log: Lance les simulations sous process avec les classpath en entier. Ajout de la m?\195?\169moire sur la ligne de commande. Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SubProcessSimulationLauncher.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SubProcessSimulationLauncher.java 2009-05-07 15:45:26 UTC (rev 2196) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SubProcessSimulationLauncher.java 2009-05-07 16:18:21 UTC (rev 2197) @@ -26,9 +26,10 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.net.URL; +import java.net.URLClassLoader; import java.rmi.RemoteException; -import java.net.URLClassLoader; -import java.net.URL; +import java.util.ArrayList; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; @@ -38,6 +39,7 @@ import fr.ifremer.isisfish.IsisFish; import fr.ifremer.isisfish.datastore.SimulationStorage; import fr.ifremer.isisfish.simulator.SimulationControl; +import fr.ifremer.isisfish.util.CompileHelper; /** * Lanceur de simulation dans un sous processus. @@ -143,8 +145,11 @@ String java = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java"; - String classpath = System.getProperty("java.class.path"); + //String classpath = System.getProperty("java.class.path"); + // TODO make a method to get runtime classpath + String classpath = CompileHelper.getClassPathAsString(new ArrayList<File>()); + if (classpath == null) { // could not find the jvm property (jnlp context for example) // rebuild the classpath as in {@link AspectClassLoader} @@ -161,23 +166,26 @@ //FIXME, should do as in {@link AspectClassLoader} } } + if (log.isDebugEnabled()) { log.debug("classpath to use : " + classpath); } + // prepare le process ProcessBuilder processBuilder = null; if (tempPrescriptFile != null) { - processBuilder = new ProcessBuilder(java, "-classpath", + processBuilder = new ProcessBuilder(java, "-Xmx1024M", "-classpath", classpath, IsisFish.class.getName(), "--option", "launch.ui", "false", "--simulateWithSimulationAndScript", simulationId, simulationZip.getAbsolutePath(), tempPrescriptFile.getAbsolutePath()); } else { - processBuilder = new ProcessBuilder(java, "-classpath", + processBuilder = new ProcessBuilder(java, "-Xmx1024M", "-classpath", classpath, IsisFish.class.getName(), "--option", "launch.ui", "false", "--simulateWithSimulation", simulationId, simulationZip.getAbsolutePath()); } + processBuilder.redirectErrorStream(true); // demarrage du process Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/CompileHelper.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/CompileHelper.java 2009-05-07 15:45:26 UTC (rev 2196) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/CompileHelper.java 2009-05-07 16:18:21 UTC (rev 2197) @@ -234,17 +234,16 @@ /** * Return full classpath (for compilation or javadoc) as string. - * Separated by {@link File.pathSeparator}. + * Separated by {@link File#pathSeparator}. * * Add : * <ul> * <li>System.getProperty("java.class.path") * <li>All first jar dependency (META-INF/MANIFEST.MF) - * <li>target/classes (if exists : for maven tests) * </ul> * @return classptah as string */ - protected static String getClassPathAsString(List<File> classpath) + public static String getClassPathAsString(List<File> classpath) throws Exception { String result = StringUtils.join(classpath.iterator(), File.pathSeparator)