I developed an app with tomcat 4 and all was sweetness and light.  I
gave it a shot under iplanet 6 beta and got:

VelocityServlet : Error processing the template
java.lang.NullPointerException
java.lang.NullPointerException at
org.apache.velocity.runtime.log.AvalonLogSystem.logVelocityMessage(AvalonLogSystem.java:157)
at org.apache.velocity.runtime.Runtime.log(Runtime.java:812) at
org.apache.velocity.runtime.Runtime.error(Runtime.java:850) at
org.apache.velocity.context.AbstractContext.put(AbstractContext.java:199)
at PDIServlet.handleRequest(Compiled Code) at
org.apache.velocity.servlet.VelocityServlet.doRequest(VelocityServlet.java:333)
at
org.apache.velocity.servlet.VelocityServlet.doGet(VelocityServlet.java:294)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at
com.iplanet.server.http.servlet.NSServletRunner.invokeServletService(NSServletRunner.java:916)
at
com.iplanet.server.http.servlet.WebApplication.service(WebApplication.java:1002)
at
com.iplanet.server.http.servlet.NSServletRunner.ServiceWebApp(NSServletRunner.java:980)


Uh, thanks.  The problem was that catalina, running as root, could
write to any log file all day long.  IWS, running as 'nobody', didn't
have write perms to the directory I had pointed it at back when I
started writing the app.  The loggers eat exceptions and dump errors
to stdout and sterr, which go nowhere particularly obvious with iws.
So, these two patches.  It seems to me that throwing an informative
exception up to the app is kinder than what it does now.

Index: src/java/org/apache/velocity/runtime/log/AvalonLogSystem.java
===================================================================
RCS file: /home/cvspublic/jakarta-velocity/src/java/org/apache/velocity/runtime/log/AvalonLogSystem.java,v
retrieving revision 1.5
diff -u -r1.5 AvalonLogSystem.java
--- src/java/org/apache/velocity/runtime/log/AvalonLogSystem.java	2001/05/06 19:45:47	1.5
+++ src/java/org/apache/velocity/runtime/log/AvalonLogSystem.java	2001/05/18 04:55:05
@@ -86,6 +86,7 @@
      *  from the Velocity properties
      */
     public AvalonLogSystem()
+       throws Exception
     {
         /*
          *  since this is a Velocity-provided logger, we will
@@ -96,20 +97,11 @@
         /*
          *  now init.  If we can't, panic!
          */
-        try
-        {
-            init( logfile );
+        init( logfile );
 
-            logVelocityMessage( 0, 
-                "AvalonLogSystem initialized using logfile " + logPath );
-        }
-        catch( Exception e )
-        {
-            System.out.println( 
-                "PANIC : Error configuring AvalonLogSystem : " + e );
-            System.err.println( 
-                "PANIC : Error configuring AvalonLogSystem : " + e );
-        }
+        logVelocityMessage( 0, 
+                            "AvalonLogSystem initialized using logfile " +
+                            logPath );
     }
 
     /**
@@ -122,6 +114,11 @@
     {
         FileOutputLogTarget target = new FileOutputLogTarget();
         File logFileLocation = new File (logFile);
+
+        if (!logFileLocation.canWrite())
+        {
+           throw new Exception("Unable to write to log file: " + logFile);
+        }
         
         logPath = logFileLocation.getAbsolutePath();

RCS file: /home/cvspublic/jakarta-velocity/src/java/org/apache/velocity/runtime/Runtime.java,v
retrieving revision 1.110
diff -u -r1.110 Runtime.java
--- src/java/org/apache/velocity/runtime/Runtime.java	2001/05/11 04:00:58	1.110
+++ src/java/org/apache/velocity/runtime/Runtime.java	2001/05/18 05:07:03
@@ -229,30 +229,22 @@
     {
         if (initialized == false)
         {
-            try
-            {
-                initializeProperties();
-                initializeLogger();
-                ResourceManager.initialize();
-                initializeDirectives();
-                initializeParserPool();
-                initializeGlobalCache();
+           initializeProperties();
+           initializeLogger();
+           ResourceManager.initialize();
+           initializeDirectives();
+           initializeParserPool();
+           initializeGlobalCache();
                 
-                /*
-                 *  initialize the VM Factory.  It will use the properties 
-                 * accessable from Runtime, so keep this here at the end.
-                 */
-                vmFactory.initVelocimacro();
+           /*
+            *  initialize the VM Factory.  It will use the properties 
+            * accessable from Runtime, so keep this here at the end.
+            */
+           vmFactory.initVelocimacro();
                 
-                info("Velocity successfully started.");
+           info("Velocity successfully started.");
                 
-                initialized = true;
-            }
-            catch (Exception e)
-            {
-                System.out.println(e);
-                e.printStackTrace();
-            }
+           initialized = true;
         }
     }

-bl

Reply via email to