Hi dain,
after this and the one change below (after the maven output), sxc comiles
fine into my archiva maven repository.
But compiling openejb3/container/openejb-jee ( remember thats where I
started), now breaks with
................
[INFO] [sxc-jaxb:generate {execution: default}]
The system is out of resources.
Consult the following stack trace for details.
java.lang.OutOfMemoryError: Java heap space
at com.sun.tools.javac.tree.TreeMaker.Ident(TreeMaker.java:324)
at com.sun.tools.javac.parser.Parser.term3(Parser.java:859)
at com.sun.tools.javac.parser.Parser.term2(Parser.java:582)
at com.sun.tools.javac.parser.Parser.term1(Parser.java:553)
at com.sun.tools.javac.parser.Parser.term(Parser.java:509)
at com.sun.tools.javac.parser.Parser.term(Parser.java:491)
at com.sun.tools.javac.parser.Parser.expression(Parser.java:481)
at com.sun.tools.javac.parser.Parser.arguments(Parser.java:1046)
at com.sun.tools.javac.parser.Parser.arguments(Parser.java:1061)
at com.sun.tools.javac.parser.Parser.superSuffix(Parser.java:1009)
at com.sun.tools.javac.parser.Parser.term3(Parser.java:835)
at com.sun.tools.javac.parser.Parser.term2(Parser.java:582)
at com.sun.tools.javac.parser.Parser.term1(Parser.java:553)
at com.sun.tools.javac.parser.Parser.term(Parser.java:509)
at com.sun.tools.javac.parser.Parser.term(Parser.java:491)
at
com.sun.tools.javac.parser.Parser.blockStatements(Parser.java:1397)
at com.sun.tools.javac.parser.Parser.block(Parser.java:1319)
at com.sun.tools.javac.parser.Parser.block(Parser.java:1331)
at
com.sun.tools.javac.parser.Parser.methodDeclaratorRest(Parser.java:2241)
at
com.sun.tools.javac.parser.Parser.classOrInterfaceBodyDeclaration(Parser.java:2189)
at
com.sun.tools.javac.parser.Parser.classOrInterfaceBody(Parser.java:2134)
at
com.sun.tools.javac.parser.Parser.classDeclaration(Parser.java:2004)
at
com.sun.tools.javac.parser.Parser.classOrInterfaceOrEnumDeclaration(Parser.java:1976)
at
com.sun.tools.javac.parser.Parser.typeDeclaration(Parser.java:1966)
at
com.sun.tools.javac.parser.Parser.compilationUnit(Parser.java:1909)
at com.sun.tools.javac.main.JavaCompiler.parse(JavaCompiler.java:257)
at com.sun.tools.javac.main.JavaCompiler.parse(JavaCompiler.java:281)
at
com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:399)
at com.sun.tools.javac.main.Main.compile(Main.java:592)
at com.sun.tools.javac.main.Main.compile(Main.java:544)
at com.sun.tools.javac.Main.compile(Main.java:85)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[INFO]
------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO]
------------------------------------------------------------------------
[INFO] Could not compile generated files! Code: 3
[INFO]
------------------------------------------------------------------------
[INFO] Trace
com.envoisolutions.sxc.builder.BuildException: Could not compile generated
files! Code: 3
at
com.envoisolutions.sxc.compiler.JavacCompiler.compile(JavacCompiler.java:105)
at
com.envoisolutions.sxc.jaxb.JAXBGenerator.generate(JAXBGenerator.java:88)
at
com.envoisolutions.sxc.jaxb.maven.SxcJaxbPlugin.execute(SxcJaxbPlugin.java:73)
at
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:447)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:539)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:480)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:459)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:311)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:278)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:143)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:333)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:126)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:282)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at
org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 29 seconds
[INFO] Finished at: Wed Jun 11 08:45:42 CEST 2008
[INFO] Final Memory: 21M/63M
[INFO]
------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------
here is another one (sxc/compiler/JavaCompiler.java):
-------------------------------------------------------------------------------------------------
package com.envoisolutions.sxc.compiler;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.envoisolutions.sxc.builder.BuildException;
import com.envoisolutions.sxc.util.Util;
public class JavacCompiler extends Compiler {
public ClassLoader compile(Map<String, File> sources) {
if (sources.isEmpty()) {
throw new IllegalArgumentException("sources is empty");
}
// create temp directory for classes
String tmpdir = System.getProperty("java.io.tmpdir");
File classDir = new File(new File(tmpdir), "classes" + hashCode() +
System.currentTimeMillis());
if (!classDir.mkdir()) {
throw new BuildException("Could not create output directory.");
}
try {
// class loader used to compile classes
ClassLoader classLoader =
Thread.currentThread().getContextClassLoader();
if (classLoader == null) classLoader =
getClass().getClassLoader();
// compile classes
compile(sources, classDir, classLoader);
// load classes
Thread.currentThread().setContextClassLoader(classLoader);
URLClassLoader cl = new URLClassLoader(new URL[]{
classDir.toURI().toURL()}, classLoader);
List<String> failedToLoad = new ArrayList<String>();
for (String className : sources.keySet()) {
try {
cl.loadClass(className);
} catch (ClassNotFoundException e) {
failedToLoad.add(className);
}
}
if (!failedToLoad.isEmpty()) {
throw new BuildException("Could not load generated classes
" + failedToLoad);
}
return cl;
} catch (IOException e) {
throw new BuildException(e);
} finally {
// clean up the temp directory
Util.delete(classDir);
}
}
public void compile(Map<String, File> sources, File classDir,
ClassLoader classLoader) {
Set<URL> urlSet = getClasspathURLs(classLoader);
String classpath = createClasspath(urlSet);
URLClassLoader newCL = createNewClassLoader();
// build arg array
List<String> args = new ArrayList<String>(sources.size() + 7);
args.add("-g");
args.add("-d");
args.add(classDir.getAbsolutePath());
args.add("-classpath");
args.add(classpath);
for (File file : sources.values()) {
args.add(file.getAbsolutePath());
}
// invoke compiler
ByteArrayOutputStream out = new ByteArrayOutputStream();
PrintWriter writer = new PrintWriter(out);
int exitCode;
try {
Class<?> main = newCL.loadClass("com.sun.tools.javac.Main");
Method method = main.getMethod("compile", String[].class,
PrintWriter.class);
exitCode = (Integer) method.invoke(null, args.toArray(new
String[args.size()]), writer);
} catch (ClassNotFoundException e1) {
throw new BuildException("Could not find javac compiler!", e1);
} catch (Exception e) {
throw new BuildException("Could not invoke javac compiler!",
e);
}
// check exit code
if (exitCode != 0) {
writer.close();
System.out.println(out.toString());
throw new BuildException("Could not compile generated files!
Code: " + exitCode);
}
}
private URLClassLoader createNewClassLoader() {
URL[] urls;
File toolsJar = new File(System.getProperty("java.home"),
"../lib/tools.jar");
if (toolsJar.exists()) {
try {
urls = new URL[]{toolsJar.toURL()};
} catch (MalformedURLException e) {
throw new BuildException("Could not convert the file
reference to tools.jar to a URL, path to tools.jar: '"
+ toolsJar.getAbsolutePath() + "'.");
}
} else {
urls = new URL[0];
}
URLClassLoader newCL = new URLClassLoader(urls);
Thread.currentThread().setContextClassLoader(newCL);
return newCL;
}
private String createClasspath(Set<URL> urls) {
StringBuilder cp = new StringBuilder();
boolean first = true;
for (URL u : urls) {
if (u.getProtocol().equals("file")) {
if (first) {
first = false;
} else {
cp.append(File.pathSeparatorChar);
}
String uStr = u.toString().replaceAll(" ", "%20");
try {
File file = new File(new URI(uStr));
cp.append(file.getAbsolutePath());
} catch (URISyntaxException e) {
}
}
}
return cp.toString();
}
private Set<URL> getClasspathURLs(ClassLoader cl) {
Set<URL> urls = new HashSet<URL>();
while (cl != null) {
if (cl instanceof URLClassLoader) {
URLClassLoader ucl = (URLClassLoader) cl;
URL[] clurls = ucl.getURLs();
if (clurls != null) {
urls.addAll(Arrays.asList(clurls));
}
}
cl = cl.getParent();
}
return urls;
}
}
-------------------------------------------------------------------------------------------------
The other one (line 114) is at a standard location, and should be fine.
mit freundlichen Grüßen/best regards
Wolfgang Schrecker
"Der Inhalt eines Begriffs nimmt ab, wenn sein Umfang zunimmt; wird dieser
allumfassend, so muß der Inhalt ganz verloren gehen."
from G. Frege: Die Grundlagen der Arithmetik S. 40
--
--------------------------------------------------
Atos Worldline Processing GmbH
Hahnstrasse 25
60528 Frankfurt/Main
Germany
Phone: +49 69/6657-1176
mailto:[EMAIL PROTECTED]
http://www.atosworldline.com
Geschäftsführer: Erik Munk Koefoed
Aufsichtsratsvorsitzender: Didier Dhennin
Sitz der Gesellschaft: Frankfurt/Main
Handelsregister: Frankfurt/Main HRB 40 417
--------------------------------------------------
Atos Worldline Processing GmbH
Hahnstraße 25
60528 Frankfurt/Main
Germany
Phone: +49 69/6657-1176
Fax :
mailto: [EMAIL PROTECTED]
http://www.atosworldline.com
Geschäftsführer: Erik Munk Koefoed
Aufsichtsratsvorsitzender: Didier Dhennin
Sitz der Gesellschaft: Frankfurt/Main
Handelsregister: Frankfurt/Main HRB 40 417
* * * * * * * * L E G A L D I S C L A I M E R * * * * * * * *
This e-mail is destined for the above mentioned recipient. In case you
received this e-mail by accident, we would appreciate it if you could
contact the sender and delete all copies stored on your computer.
Please be aware that the security and confidentiality of electronic data
transmitted by e-mail is not completely guaranteed and that data may be seen,
copied, downloaded or changed by third persons during transmission.
Atos Origin accepts no liability for the security and confidentiality of
data and documents sent by e-mail. Please make sure that all important
messages will be confirmed in writing by means of a telefax or a letter.
* * * * * * * * L E G A L D I S C L A I M E R * * * * * * * *