geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r513983 - in /geronimo/server/branches/1.2/maven-plugins/geronimo-maven-plugin: pom.xml src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/StartServerMojo.java
Date Fri, 02 Mar 2007 22:01:35 GMT
Author: jdillon
Date: Fri Mar  2 14:01:34 2007
New Revision: 513983

URL: http://svn.apache.org/viewvc?view=rev&rev=513983
Log:
Dump the server.log to console if the server failed to start

Modified:
    geronimo/server/branches/1.2/maven-plugins/geronimo-maven-plugin/pom.xml
    geronimo/server/branches/1.2/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/StartServerMojo.java

Modified: geronimo/server/branches/1.2/maven-plugins/geronimo-maven-plugin/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/branches/1.2/maven-plugins/geronimo-maven-plugin/pom.xml?view=diff&rev=513983&r1=513982&r2=513983
==============================================================================
--- geronimo/server/branches/1.2/maven-plugins/geronimo-maven-plugin/pom.xml (original)
+++ geronimo/server/branches/1.2/maven-plugins/geronimo-maven-plugin/pom.xml Fri Mar  2 14:01:34
2007
@@ -59,6 +59,12 @@
             <artifactId>mx4j-remote</artifactId>
         </dependency>
         
+        <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+            <version>1.2</version>
+        </dependency>
+        
         <!-- Support for SurefireReporter -->
         <dependency>
             <groupId>org.apache.maven.surefire</groupId>

Modified: geronimo/server/branches/1.2/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/StartServerMojo.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/1.2/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/StartServerMojo.java?view=diff&rev=513983&r1=513982&r2=513983
==============================================================================
--- geronimo/server/branches/1.2/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/StartServerMojo.java
(original)
+++ geronimo/server/branches/1.2/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/StartServerMojo.java
Fri Mar  2 14:01:34 2007
@@ -31,6 +31,11 @@
 import java.util.List;
 import java.util.ArrayList;
 
+import java.io.InputStream;
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
+import java.io.IOException;
+
 import org.apache.maven.plugin.MojoExecutionException;
 
 import org.apache.tools.ant.taskdefs.Java;
@@ -39,6 +44,7 @@
 import org.apache.geronimo.mavenplugins.geronimo.ServerProxy;
 
 import org.codehaus.plexus.util.FileUtils;
+import org.apache.commons.io.IOUtils;
 
 /**
  * Start the Geronimo server.
@@ -271,11 +277,17 @@
         boolean started = false;
         while (!started) {
             if (verifyTimedOut.isSet()) {
-                throw new MojoExecutionException("Unable to verify if the server was started
in the given time");
+                String msg = "Unable to verify if the server was started in the given time";
+                log.error(msg);
+                dumpServerLog();
+                throw new MojoExecutionException(msg);
             }
 
             if (errorHolder.isSet()) {
-                throw new MojoExecutionException("Failed to start Geronimo server", (Throwable)errorHolder.get());
+                String msg = "Failed to start Geronimo server";
+                log.error(msg);
+                dumpServerLog();
+                throw new MojoExecutionException(msg, (Throwable)errorHolder.get());
             }
 
             started = server.isFullyStarted();
@@ -301,7 +313,32 @@
             t.join();
         }
     }
-
+    
+    private void dumpServerLog() throws IOException {
+        // If we logged output, copy the logs into the console stream
+        if (logOutput) {
+            File file = getLogFile();
+            if (!file.exists()) {
+                log.warn("Server log does not exist; skipping dump");
+            }
+            else {
+                System.out.println("----8<----");
+                InputStream input = new BufferedInputStream(new FileInputStream(file));
+                try {
+                    //
+                    // TODO: Might be nice to just get the last ~100 lines or something...
+                    //
+                    
+                    IOUtils.copy(input, System.out);
+                }
+                finally {
+                    input.close();
+                }
+                System.out.println("---->8----");
+            }
+        }
+    }
+    
     private String appendSystemPath(final String name, final File file) {
         assert name != null;
         assert file != null;



Mime
View raw message