Hello All
I am running Embedded GlassFish from a TestNG test. It works great in one maven project and fails in another saying:
Exception in thread "main" org.glassfish.embed.GFException: Failed to write domain XML
The code is both projects are identical. The projects are getting glassfish from the same root. I can confirm that the temp directory it's complaining about actually exists. I am running TestNG 5.8, Java 1.6u10, on Ubuntu 8.10. I get the same errors outside of TestNG:
Here's the error I get running the initialization code in a main() method:
Exception in thread "main" org.glassfish.embed.GFException: Failed to write domain XML
at org.glassfish.embed.impl.DomainXmlHolder.writeDomainXml(DomainXmlHolder.java:74)
at org.glassfish.embed.impl.DomainXml2.getDomainXml(DomainXml2.java:71)
at com.sun.enterprise.v3.server.DomainXml.run(DomainXml.java:60)
at com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl.createHabitat(AbstractModulesRegistryImpl.java:139)
at com.sun.enterprise.module.bootstrap.Main.createHabitat(Main.java:392)
at com.sun.enterprise.module.bootstrap.Main.launch(Main.java:309)
at com.sun.enterprise.module.bootstrap.Main.launch(Main.java:303)
at org.glassfish.embed.GlassFish.start(GlassFish.java:359)
at org.glassfish.embed.GlassFish.<init>(GlassFish.java:169)
at TestContainerPOC.main(TestContainerPOC.java:24)
Caused by: javax.xml.transform.TransformerException: java.io.FileNotFoundException: file:/tmp/domain64141xml (No such file or directory)
at org.apache.xalan.transformer.TransformerIdentityImpl.createResultContentHandler(TransformerIdentityImpl.java:245)
at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:278)
at org.glassfish.embed.impl.DomainXmlHolder.writeDomainXml(DomainXmlHolder.java:69)
... 9 more
Caused by: java.io.FileNotFoundException: file:/tmp/domain64141xml (No such file or directory)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
at java.io.FileOutputStream.<init>(FileOutputStream.java:70)
at org.apache.xalan.transformer.TransformerIdentityImpl.createResultContentHandler(TransformerIdentityImpl.java:235)
... 11 more
Here's my code:
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URL;
import java.util.Collections;
import java.util.Set;
import java.util.logging.Level;
import javax.ws.rs.core.UriBuilder;
import org.glassfish.embed.GlassFish;
import org.glassfish.embed.ScatteredWar;
public class TestContainerPOC {
private static final String CONTEXT_NAME = "myproject";
private static final int SERVER_PORT = 8766;
static final URI BASE_URI = UriBuilder.fromUri("
http://127.0.0.1/").port(SERVER_PORT).path(CONTEXT_NAME).build();
public static void main(String[] args) throws IOException {
GlassFish.setLogLevel(Level.SEVERE); // glassfish is too chatty for me.
// Start Glassfish
GlassFish glassfish = new GlassFish(BASE_URI.getPort());
// Deploy Glassfish referencing the web.xml
final URL mainClasses = new File("target/classes").toURI().toURL();
final Set<URL> classes = Collections.singleton(mainClasses);
final File webXml = new File("src/main/webapp/WEB-INF/web.xml");
final File webDir = new File("src/main/webapp");
ScatteredWar war = new ScatteredWar(BASE_URI.getRawPath(), webDir, webXml, classes);
glassfish.deploy(war);
}
}
(I apologize, but I couldn't get the code to format nicely)
[Message sent by forum member 'javageek_boston' (javageek_boston)]
http://forums.java.net/jive/thread.jspa?messageID=334346