[kaffe] Problem loading non-class files from jar (Velocity on Tomcat5)

Alan Tam Tam at SiuLung.com
Thu Jul 22 00:03:15 PDT 2004


Hi,

I tried Velocity on Tomcat (running on kaffe CVS head) and it failed 
with NullPointerException when it is trying to load velocity.properties, 
which is included in velocity.jar. Strace on both Kaffe and Sun VM shows 
the difference.

Kaffe:
...
[pid  3217] 
stat64("/home/sltam/tomcat-test/webapps/dmp-sltam/velocity.properties", 
0x414e1ba8) = -1 ENOENT (No such file or directory)
[pid  3217] 
stat64("/home/sltam/tomcat-test/webapps/dmp-sltam//WEB-INF/velocity.properties", 
0x414e1ba8) = -1 ENOENT (No such file or directory)
[pid  3217] 
stat64("/home/sltam/tomcat-test/webapps/dmp-sltam//WEB-INF/classes//org/apache/velocity/runtime/defaults/velocity.properties", 
0x414e1920) = -1 ENOENT (No such file or directory)
[pid  3217] 
stat64("/home/sltam/tomcat-test/common/classes//org/apache/velocity/runtime/defaults/velocity.properties", 
0x414e1960) = -1 ENOENT (No such file or directory)
[pid  3217] 
stat64("/home/sltam/tomcat-test/shared/classes//org/apache/velocity/runtime/defaults/velocity.properties", 
0x414e199c) = -1 ENOENT (No such file or directory)
...

Sun:
...
[pid  4208] 
stat64("/home/sltam/dmp-sltam/trunk/webapp/WEB-INF/classes/org/apache/velocity/runtime/defaults/velocity.properties", 
0xbfffc1a4) = -1 ENOENT (No such file or directory)
[pid  4208] 
stat64("/home/sltam/tomcat-test/work/Catalina/localhost/dmp-sltam/loader/org/apache/velocity/runtime/defaults/velocity.properties", 
0xbfffc27c) = -1 ENOENT (No such file or directory)
[pid  4208] 
open("/home/sltam/tomcat-test/work/Catalina/localhost/dmp-sltam/loader/org/apache/velocity/runtime/defaults/velocity.properties", 
O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 12
...

Stacktrace:
[ERROR] VelocityManager - -Unable to instantiate VelocityEngine! 
<java.lang.NullPointerException>java.lang.NullPointerException
   at java.io.InputStreamReader.<init> (InputStreamReader.java:106)
   at org.apache.commons.collections.ExtendedProperties.load (source 
file unknown)
   at org.apache.commons.collections.ExtendedProperties.load (source 
file unknown)
   at org.apache.velocity.runtime.RuntimeInstance.setDefaultProperties 
(RuntimeInstance.java:318)
   at org.apache.velocity.runtime.RuntimeInstance.initializeProperties 
(RuntimeInstance.java:443)
   at org.apache.velocity.runtime.RuntimeInstance.init 
(RuntimeInstance.java:225)
   at org.apache.velocity.runtime.RuntimeInstance.init 
(RuntimeInstance.java:461)
   at org.apache.velocity.app.VelocityEngine.init (VelocityEngine.java:140)

The configuration should be generated in 
org.apache.velocity.runtime.RuntimeInstance by:
            InputStream inputStream = getClass()
                .getResourceAsStream('/' + DEFAULT_RUNTIME_PROPERTIES);
where DEFAULT_RUNTIME_PROPERTIES == "velocity.properties".

I don't know whether it is related to the custom Tomcat ClassLoader or 
what, but I cannot reproduce the problem using a standalone program.

Any ideas?

-- 
Regards,
Alan





More information about the kaffe mailing list