You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Will Glass-Husain <wg...@forio.com> on 2004/01/04 22:56:34 UTC
Re: Velocity.init() problem
Have you done a logging or System.out.println on the value returned by
getServletContext().getRealPath("templates/")) to make sure it is the same
under both systems?
I browsed Bugzilla briefly and there were a few bugs in getRealPath in early
versions of Tomcat 4.0.x. None seemed to apply directly to your situation,
but I advise checking to see if the path is generated correctly.
WILL
----- Original Message -----
From: "Algirdas M." <sn...@splius.lt>
To: <ve...@jakarta.apache.org>
Sent: Sunday, January 04, 2004 2:43 PM
Subject: Velocity.init() problem
> Hello,
>
> I have j2se 1.3 and tomcat 4.0.3 on the server.
> I'm executing this code:
>
> Velocity.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH,
> getServletContext().getRealPath("templates/"));
>
> Velocity.setProperty(Velocity.RUNTIME_LOG,
> getServletContext().getRealPath("velocity.log"));
>
> try {
> Velocity.init();
> } catch (Exception e) {
> e.printStackTrace(System.out);
> }
>
> ..and I'm getting this exception:
>
> java.lang.NullPointerException
> at java.io.Reader.<init>(Reader.java:64)
> at java.io.InputStreamReader.<init>(InputStreamReader.java:89)
> at java.io.InputStreamReader.<init>(InputStreamReader.java:61)
> at org.apache.commons.collections.ExtendedProperties.load(Unknown
Source)
> at org.apache.commons.collections.ExtendedProperties.load(Unknown
Source)
> at
org.apache.velocity.runtime.RuntimeInstance.setDefaultProperties(RuntimeInst
ance.java:298)
> at
org.apache.velocity.runtime.RuntimeInstance.initializeProperties(RuntimeInst
ance.java:423)
> at
org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:266)
> at
org.apache.velocity.runtime.RuntimeSingleton.init(RuntimeSingleton.java:169)
> at org.apache.velocity.app.Velocity.init(Velocity.java:123)
> at xxx.objects.View.initGetMethod(View.java:133)
> at xxx.objects.View.doGet(View.java:66)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:247)
> at
org.apache.catalina.core.ApplicationFilterChain.access$0(ApplicationFilterCh
ain.java:197)
> at
org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain
.java:176)
> at java.security.AccessController.doPrivileged(Native Method)
> at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:172)
> at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:243)
> at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
> at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
> at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:190)
> at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
> at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
> at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2343)
> at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180
)
> at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
> at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.
java:170)
> at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
64)
> at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170
)
> at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
64)
> at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
> at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
64)
> at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
> at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:174)
> at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
> at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
> at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> at
org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:
1012)
> at
org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1122
)
> at java.lang.Thread.run(Thread.java:484)
>
>
>
> On my local computer I have j2sdk 1.4.2_03 and Tomcat 4.1.29 and the
> same code works fine - without exception.
>
> Where is the problem?
>
>
> Thank you.
>
> --
> Best regards,
> Algirdas mailto:snk@splius.lt
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
RE: Re[4]: Velocity.init() problem
Posted by "mr.x" <mr...@tele2.ch>.
Hi Algirdas
Did you check the Tomcat host-configuration ?
<Host name="localhost" debug="0" appBase="webapps" unpackWARs="false"
autoDeploy="false">
-> causes problems in some situations
<Host name="localhost" debug="0" appBase="webapps" unpackWARs="true"
autoDeploy="false">
-> worked always for me
Regards
Rolf
-----Original Message-----
From: Will Glass-Husain [mailto:wglass@forio.com]
Sent: Montag, 5. Januar 2004 19:35
To: Velocity Users List; Algirdas M.
Subject: Re: Re[4]: Velocity.init() problem
If you don't know what a security manager is, it's unlikely you are using
one. This would be Tomcat running with the -security option enabled, for
example.
Personally, I'm puzzled. I'll play with this on my end a bit on a JDK 1.3
machine. What OS are you using?
WILL
> WGH> Are you running under an unduly restrictive security manager?
>
> I don't know.. what is this?
>
>
>
>
> --
> Best regards,
> Algirdas mailto:snk@splius.lt
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: Re[4]: Velocity.init() problem
Posted by Will Glass-Husain <wg...@forio.com>.
If you don't know what a security manager is, it's unlikely you are using
one. This would be Tomcat running with the -security option enabled, for
example.
Personally, I'm puzzled. I'll play with this on my end a bit on a JDK 1.3
machine. What OS are you using?
WILL
> WGH> Are you running under an unduly restrictive security manager?
>
> I don't know.. what is this?
>
>
>
>
> --
> Best regards,
> Algirdas mailto:snk@splius.lt
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re[4]: Velocity.init() problem
Posted by "Algirdas M." <sn...@splius.lt>.
Hello,
Monday, January 5, 2004, 4:40:34 PM, you wrote:
WGH> No, Velocity is definitely 1.3 compatible. A couple of quick thoughts...
WGH> Just as a side note, you have an extra "web" directory in the first one, is
WGH> that's legit?
yes, I have, but the said directories still have same files.
WGH> Does your app have permissions to read the files?
Yes, it has.
Does no permission exception should be a NullPointerException?
WGH> Are you running under an unduly restrictive security manager?
I don't know.. what is this?
--
Best regards,
Algirdas mailto:snk@splius.lt
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: Re[2]: Velocity.init() problem
Posted by Will Glass-Husain <wg...@forio.com>.
No, Velocity is definitely 1.3 compatible. A couple of quick thoughts...
Just as a side note, you have an extra "web" directory in the first one, is
that's legit?
Does your app have permissions to read the files?
Are you running under an unduly restrictive security manager?
WILL
----- Original Message -----
From: "Algirdas M." <sn...@splius.lt>
To: "Velocity Users List" <ve...@jakarta.apache.org>
Sent: Monday, January 05, 2004 4:12 AM
Subject: Re[2]: Velocity.init() problem
> Hello Will,
>
> Sunday, January 4, 2004, 10:56:34 PM, you wrote:
>
> WGH> Have you done a logging or System.out.println on the value returned
by
> WGH> getServletContext().getRealPath("templates/")) to make sure it is the
same
> WGH> under both systems?
>
> in local system it is F:\projects\vvv\web\templates
> in server: /usr/share/tomcat4/webapps/vvv/templates
>
> both directories exists and have same files..
> maybe velocity requires bigger version of J2SE than 1.3?
>
> WGH> I browsed Bugzilla briefly and there were a few bugs in getRealPath
in early
> WGH> versions of Tomcat 4.0.x. None seemed to apply directly to your
situation,
> WGH> but I advise checking to see if the path is generated correctly.
>
> WGH> WILL
>
>
>
>
> --
> Best regards,
> Algirdas mailto:snk@splius.lt
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re[2]: Velocity.init() problem
Posted by "Algirdas M." <sn...@splius.lt>.
Hello Will,
Sunday, January 4, 2004, 10:56:34 PM, you wrote:
WGH> Have you done a logging or System.out.println on the value returned by
WGH> getServletContext().getRealPath("templates/")) to make sure it is the same
WGH> under both systems?
in local system it is F:\projects\vvv\web\templates
in server: /usr/share/tomcat4/webapps/vvv/templates
both directories exists and have same files..
maybe velocity requires bigger version of J2SE than 1.3?
WGH> I browsed Bugzilla briefly and there were a few bugs in getRealPath in early
WGH> versions of Tomcat 4.0.x. None seemed to apply directly to your situation,
WGH> but I advise checking to see if the path is generated correctly.
WGH> WILL
--
Best regards,
Algirdas mailto:snk@splius.lt
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org