ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seanfi...@apache.org
Subject svn commit: r1689947 - /ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/resource/FileLocator.java
Date Wed, 08 Jul 2015 19:37:25 GMT
Author: seanfinan
Date: Wed Jul  8 19:37:24 2015
New Revision: 1689947

URL: http://svn.apache.org/r1689947
Log:
CTAKES-367  Added listing of $CLASSPATH to logger error message when a file is not found.
 May help people resolve issues with simple causes.

Modified:
    ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/resource/FileLocator.java

Modified: ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/resource/FileLocator.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/resource/FileLocator.java?rev=1689947&r1=1689946&r2=1689947&view=diff
==============================================================================
--- ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/resource/FileLocator.java
(original)
+++ ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/resource/FileLocator.java
Wed Jul  8 19:37:24 2015
@@ -24,6 +24,7 @@ import java.io.*;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
+import java.net.URLClassLoader;
 
 /**
  * Utility class that attempts to locate files.
@@ -157,12 +158,20 @@ final public class FileLocator {
             return createDiscoveredPath( relativePath, file, "above Working Directory /ctakes"
);
          }
       }
-      LOGGER.error( "Could not find " + relativePath + " as absolute or in \n" + cwd
-                    + " or in any parent thereof or in $CTAKES_HOME \n" + cTakesHome );
+      final StringBuilder sb = new StringBuilder();
+      sb.append( "Could not find " ).append( relativePath ).append( "\nas absolute or in
$CLASSPATH :\n" );
+      final ClassLoader classLoader = ClassLoader.getSystemClassLoader();
+      final URL[] classpathUrls = ((URLClassLoader)classLoader).getURLs();
+      for ( URL url : classpathUrls ) {
+         sb.append( url.getFile() ).append( "\n" );
+      }
+      sb.append( "or in working directory : " ).append( cwd ).append( "\n" );
+      sb.append( "or in any parent thereof (with or without /ctakes/)\n" );
+      sb.append( "or in $CTAKES_HOME : " ).append( cTakesHome );
+      LOGGER.error( sb.toString() );
       throw new FileNotFoundException( "No File exists at " + relativePath );
    }
 
-
    /**
     * Check the java classpath for the presence of a file pointed to by relativePath
     *
@@ -180,6 +189,6 @@ final public class FileLocator {
       }
       final URI indexUri = new URI( indexUrl.toExternalForm() );
       return new File( indexUri );
-    }
+   }
 
 }
\ No newline at end of file



Mime
View raw message