karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hkes...@apache.org
Subject svn commit: r1447417 - in /karaf/trunk/main/src/main/java/org/apache/karaf/main: KarafActivatorManager.java Main.java lock/DefaultJDBCLock.java lock/SimpleFileLock.java util/BootstrapLogManager.java
Date Mon, 18 Feb 2013 18:22:34 GMT
Author: hkesler
Date: Mon Feb 18 18:22:34 2013
New Revision: 1447417

URL: http://svn.apache.org/r1447417
Log:
karaf-1748: made the exception for startup with locked log file more user friendly

Modified:
    karaf/trunk/main/src/main/java/org/apache/karaf/main/KarafActivatorManager.java
    karaf/trunk/main/src/main/java/org/apache/karaf/main/Main.java
    karaf/trunk/main/src/main/java/org/apache/karaf/main/lock/DefaultJDBCLock.java
    karaf/trunk/main/src/main/java/org/apache/karaf/main/lock/SimpleFileLock.java
    karaf/trunk/main/src/main/java/org/apache/karaf/main/util/BootstrapLogManager.java

Modified: karaf/trunk/main/src/main/java/org/apache/karaf/main/KarafActivatorManager.java
URL: http://svn.apache.org/viewvc/karaf/trunk/main/src/main/java/org/apache/karaf/main/KarafActivatorManager.java?rev=1447417&r1=1447416&r2=1447417&view=diff
==============================================================================
--- karaf/trunk/main/src/main/java/org/apache/karaf/main/KarafActivatorManager.java (original)
+++ karaf/trunk/main/src/main/java/org/apache/karaf/main/KarafActivatorManager.java Mon Feb
18 18:22:34 2013
@@ -45,7 +45,12 @@ public class KarafActivatorManager {
     public KarafActivatorManager(ClassLoader classLoader, Framework framework) {
         this.classLoader = classLoader;
         this.framework = framework;
-        LOG.addHandler(BootstrapLogManager.getDefaultHandler());
+        try{
+            LOG.addHandler(BootstrapLogManager.getDefaultHandler());
+        }catch(Exception e){
+            e.printStackTrace();
+        }
+
     }
 
     void startKarafActivators() throws IOException {

Modified: karaf/trunk/main/src/main/java/org/apache/karaf/main/Main.java
URL: http://svn.apache.org/viewvc/karaf/trunk/main/src/main/java/org/apache/karaf/main/Main.java?rev=1447417&r1=1447416&r2=1447417&view=diff
==============================================================================
--- karaf/trunk/main/src/main/java/org/apache/karaf/main/Main.java (original)
+++ karaf/trunk/main/src/main/java/org/apache/karaf/main/Main.java Mon Feb 18 18:22:34 2013
@@ -22,6 +22,7 @@ import java.io.BufferedReader;
 import java.io.File;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.lang.reflect.InvocationTargetException;
 import java.net.URI;
 import java.net.URL;
 import java.net.URLClassLoader;
@@ -170,8 +171,7 @@ public class Main {
                 main.launch();
             } catch (Throwable ex) {
                 // Also log to sytem.err in case logging is not yet initialized
-                System.err.println("Could not launch framework: " + ex);
-                ex.printStackTrace();
+                System.err.println(ex.getMessage());
 
                 main.LOG.log(Level.SEVERE, "Could not launch framework", ex);
                 main.destroy();
@@ -296,7 +296,12 @@ public class Main {
         try {
             return (Lock) Lock.class.getClassLoader().loadClass(config.lockClass).getConstructor(Properties.class).newInstance(config.props);
         } catch (Exception e) {
-            throw new RuntimeException("Exception instantiating lock class " + config.lockClass,
e);
+            if (e instanceof InvocationTargetException){
+                throw new RuntimeException("Exception instantiating lock class " + config.lockClass
+                                            + "\n" + ((InvocationTargetException)e).getTargetException().getMessage());
+            }else{
+                throw new RuntimeException("Exception instantiating lock class " + config.lockClass,
e);
+            }
         }
     }
 

Modified: karaf/trunk/main/src/main/java/org/apache/karaf/main/lock/DefaultJDBCLock.java
URL: http://svn.apache.org/viewvc/karaf/trunk/main/src/main/java/org/apache/karaf/main/lock/DefaultJDBCLock.java?rev=1447417&r1=1447416&r2=1447417&view=diff
==============================================================================
--- karaf/trunk/main/src/main/java/org/apache/karaf/main/lock/DefaultJDBCLock.java (original)
+++ karaf/trunk/main/src/main/java/org/apache/karaf/main/lock/DefaultJDBCLock.java Mon Feb
18 18:22:34 2013
@@ -63,8 +63,11 @@ public class DefaultJDBCLock implements 
     int timeout;
 
     public DefaultJDBCLock(Properties props) {
-        LOG.addHandler(BootstrapLogManager.getDefaultHandler());
-        
+        try{
+            LOG.addHandler(BootstrapLogManager.getDefaultHandler());
+        }catch (Exception e){
+            e.printStackTrace();
+        }
         this.url = props.getProperty(PROPERTY_LOCK_URL);
         this.driver = props.getProperty(PROPERTY_LOCK_JDBC_DRIVER);
         this.user = props.getProperty(PROPERTY_LOCK_JDBC_USER, DEFAULT_USER);

Modified: karaf/trunk/main/src/main/java/org/apache/karaf/main/lock/SimpleFileLock.java
URL: http://svn.apache.org/viewvc/karaf/trunk/main/src/main/java/org/apache/karaf/main/lock/SimpleFileLock.java?rev=1447417&r1=1447416&r2=1447417&view=diff
==============================================================================
--- karaf/trunk/main/src/main/java/org/apache/karaf/main/lock/SimpleFileLock.java (original)
+++ karaf/trunk/main/src/main/java/org/apache/karaf/main/lock/SimpleFileLock.java Mon Feb
18 18:22:34 2013
@@ -52,7 +52,9 @@ public class SimpleFileLock implements L
             File base = new File(props.getProperty(PROPERTY_LOCK_DIR));
             lockPath = new File(base, "lock"); 
             lockFile = new RandomAccessFile(lockPath, "rw");
-        } catch (IOException e) {
+        } catch (IOException ioe){
+            throw new RuntimeException("Karaf can't startup, make sure the log file can be
accessed and written by the user starting Karaf : " + ioe.getMessage());
+        } catch (Exception e){
             throw new RuntimeException("Could not create file lock", e);
         }
     }

Modified: karaf/trunk/main/src/main/java/org/apache/karaf/main/util/BootstrapLogManager.java
URL: http://svn.apache.org/viewvc/karaf/trunk/main/src/main/java/org/apache/karaf/main/util/BootstrapLogManager.java?rev=1447417&r1=1447416&r2=1447417&view=diff
==============================================================================
--- karaf/trunk/main/src/main/java/org/apache/karaf/main/util/BootstrapLogManager.java (original)
+++ karaf/trunk/main/src/main/java/org/apache/karaf/main/util/BootstrapLogManager.java Mon
Feb 18 18:22:34 2013
@@ -41,7 +41,7 @@ public class BootstrapLogManager {
 
     private static Properties configProps;
 
-    public static synchronized Handler getDefaultHandler () {
+    public static synchronized Handler getDefaultHandler () throws Exception {
         if (handler != null) {
             return handler;
         }
@@ -73,14 +73,8 @@ public class BootstrapLogManager {
             log = new File(filename);
         }
 
+        return new BootstrapLogManager.SimpleFileHandler(log);
 
-        try {
-            handler = new BootstrapLogManager.SimpleFileHandler(log);
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-
-        return handler;
     }
 
     public static void setProperties(Properties configProps) {



Mime
View raw message