You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Emyr James <em...@OrbisUK.com> on 2002/04/15 17:08:35 UTC

forumdemo & tomcat problems

Dear all,

I've been using velocity in java apps without any problems. I now want
to start using it within servlets.
I built the forumdemo example, put forumdemo.war in the webapps
directory, and fired up my browser.
The fromt page appears fine, but when I click on 'Today's blab topic' I
get...

Error: 500
Location: /forumdemo/servlet/forum
Internal Servlet Error:

java.lang.NullPointerException
 at java.lang.ClassLoader.resolveClass0(Native Method)
 at java.lang.ClassLoader.resolveClass(ClassLoader.java:641)
 at
org.apache.tomcat.loader.AdaptiveClassLoader.loadClass(AdaptiveClassLoader.java:430)

 at
org.apache.tomcat.loader.AdaptiveServletLoader.loadClass(AdaptiveServletLoader.java:174)

 at
org.apache.tomcat.core.ServletWrapper.loadServlet(ServletWrapper.java:265)

 at org.apache.tomcat.core.ServletWrapper.init(ServletWrapper.java:289)
 at org.apache.tomcat.core.Handler.service(Handler.java:254)
 at
org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
 at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:806)

 at
org.apache.tomcat.core.ContextManager.service(ContextManager.java:752)
 at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:213)

 at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)

 at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)

 at java.lang.Thread.run(Thread.java:536)

I get very similar problems when I try to do very simple stuff that uses
VelocityServlet.

Can anyone give me any hints / pointers as to where I'm going wrong?

Many Thanks,
Emyr James


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Problem passing parameter

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 4/16/02 9:10 AM, "Peter Romianowski" <me...@gmx.de> wrote:

>> 
>> No, but we can fix it :)
>> 
>> I need it for the client's project I am working on, so might as well do it
>> now.
> 
> That would be GREAT! What would be the result of the fix? Do I have to use
> 1.4dev then? Is it stable enough for production?

At the moment it is, but that will change soon :)


If the fix is small - really small - and really clear - we could talk about
rolling into 1.3.  


> 
> Thanks,
> Peter
> 
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 

-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
Be a giant.  Take giant steps.  Do giant things...


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Problem passing parameter

Posted by Peter Romianowski <me...@gmx.de>.
> 
> No, but we can fix it :)
> 
> I need it for the client's project I am working on, so might as well do it
> now.

That would be GREAT! What would be the result of the fix? Do I have to use
1.4dev then? Is it stable enough for production?

Thanks,
Peter

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Problem passing parameter

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 4/16/02 8:57 AM, "Peter Romianowski" <me...@gmx.de> wrote:

> Hi,
> 
>>> Am I missing something? If this is a bug - is there
>>> a workaround? BTW: I use velocity-1.2.
>> 
>> I've run into the same thing...
>> 
>> Could you try with the 1.4 latest?
> 
> Done (NB 15/04). But the result stays the same :( Any ideas for a
> workaround?
> 

No, but we can fix it :)

I need it for the client's project I am working on, so might as well do it
now.

-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting

Maven & Gump are friends


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Problem passing parameter

Posted by Peter Romianowski <me...@gmx.de>.
Hi,

> > Am I missing something? If this is a bug - is there
> > a workaround? BTW: I use velocity-1.2.
> 
> I've run into the same thing...
> 
> Could you try with the 1.4 latest?

Done (NB 15/04). But the result stays the same :( Any ideas for a 
workaround?

Peter

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Problem passing parameter

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 4/16/02 8:15 AM, "Peter Romianowski" <me...@gmx.de> wrote:

> Hi,
> 
> I have a weird problem. I want to do the following:
> 
> $obj.getSomething( "param1", $obj2.getALongValue())
> 
> whereas $obj2.getALongValue() returns a value of
> type long (primitive). The result is that velocity
> renders this as text instead of evaluating it.
> When I put $obj2.getALongValue() somewhere in my
> template, it renders correctly to the value of
> the method-call. If I do something like:
> 
> #set ($value = 2) <-- Note: NOT a long
> $obj.getSomething( "param1", $value)
> 
> it renders correctly. Does velocity have a
> problem with long parameters? I think I remember
> a maildiscussion about that, but I am not sure
> (and I was not able to find something in the
> archives).
> 
> Am I missing something? If this is a bug - is there
> a workaround? BTW: I use velocity-1.2.

I've run into the same thing...

Could you try with the 1.4 latest?

-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
Java : the speed of Smalltalk with the simple elegance of C++... 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Template Caching

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 4/16/02 8:36 AM, "Peter Romianowski" <me...@gmx.de> wrote:

>> I had a similar problem, did a private workaround, but can put in the 1.4
>> tree if it's useful.
>> 
>> The idea is just to add something along the lines of
>> 
>>   public Template makeTemplate(Reader);
>> 
>> So that you can create and cache your own templates, getting the benefit of
>> the cache....
> 
> +1 for that. I think there are enough use cases for that.
> 
>> I am not sure if that is better than your own resource loader - with your
>> own loader, that extracts the <template> from the doc, you could keep the
>> 'standard model' of
>> 
>>   Template t = getResource("foobar.xml");
>> 
>> And get all of Velocity's cache management for free...
> 
> Idea #1 would work better for me, since I process the XML-file in another
> part of my application that has fairly nothing to do with velocity (In fact
> I use a pluggable "template-renderer-framework", where velocity is just
> one choice among others).

But the best one :)

> 
> Another question: I saw the latest release is 1.3rc1. The development is
> 1.4 - what will be the next release? 1.3 or 1.4. And is there any schedule
> for a release?

I was going to push out 1.3rc2 last night, but fell asleep.  Look for it
tonight.  That's the path to the 1.3 release.  The slowness is because of a
bug that was found late in 1.3-dev which appears to be fixed, but being
cautious.

The 1.4-dev is the current dev tree...

> 
> Thanks,
> Peter
> 
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 

-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
"We will be judged not by the monuments we build, but by the monuments we
destroy" - Ada Louise Huxtable


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Template Caching

Posted by Peter Romianowski <me...@gmx.de>.
> I had a similar problem, did a private workaround, but can put in the 1.4
> tree if it's useful.
> 
> The idea is just to add something along the lines of
> 
>   public Template makeTemplate(Reader);
> 
> So that you can create and cache your own templates, getting the benefit of
> the cache....

+1 for that. I think there are enough use cases for that.
 
> I am not sure if that is better than your own resource loader - with your
> own loader, that extracts the <template> from the doc, you could keep the
> 'standard model' of
> 
>   Template t = getResource("foobar.xml");
> 
> And get all of Velocity's cache management for free...

Idea #1 would work better for me, since I process the XML-file in another
part of my application that has fairly nothing to do with velocity (In fact
I use a pluggable "template-renderer-framework", where velocity is just
one choice among others).

Another question: I saw the latest release is 1.3rc1. The development is
1.4 - what will be the next release? 1.3 or 1.4. And is there any schedule
for a release?

Thanks,
Peter

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Template Caching

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 4/16/02 8:23 AM, "Peter Romianowski" <me...@gmx.de> wrote:

> Hi (again for a second topic :),
> 
> I use velocity the "standard"-way with .vm-Files and another
> way with XML-templates that look like this:
> 
> <root>
> <something>
> ...
> </something>
> 
> <template>
> #set ($velocity = "great velocity")
> here comes some $velocity-stuff
> </template>
> </root>
> 
> Now that my application gets under heavy load I want
> to use the template (grammar)-caching, that is used
> by velocity working with files.
> During the processing of the XML-file I extract the
> content of the node "template" and pass it to
> Velocity.evaluate (...) which is recreating the grammar
> upon every call, right?
> 
> Is there a way to use grammar-caching within my approach?
> Will I have to implement my own ResourceLoader?
> 
> Thanks in advance,

I had a similar problem, did a private workaround, but can put in the 1.4
tree if it's useful.

The idea is just to add something along the lines of

  public Template makeTemplate(Reader);

So that you can create and cache your own templates, getting the benefit of
the cache....

I am not sure if that is better than your own resource loader - with your
own loader, that extracts the <template> from the doc, you could keep the
'standard model' of

  Template t = getResource("foobar.xml");

And get all of Velocity's cache management for free...


-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting

Maven & Gump are friends


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Template Caching

Posted by Peter Romianowski <me...@gmx.de>.
Hi (again for a second topic :),

I use velocity the "standard"-way with .vm-Files and another 
way with XML-templates that look like this:

<root>
	<something>
		...
	</something>

	<template>
		#set ($velocity = "great velocity")
		here comes some $velocity-stuff
	</template>
</root>

Now that my application gets under heavy load I want
to use the template (grammar)-caching, that is used 
by velocity working with files.
During the processing of the XML-file I extract the 
content of the node "template" and pass it to
Velocity.evaluate (...) which is recreating the grammar
upon every call, right?

Is there a way to use grammar-caching within my approach?
Will I have to implement my own ResourceLoader?

Thanks in advance,

Peter

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Problem passing parameter

Posted by Peter Romianowski <me...@gmx.de>.
Hi,

I have a weird problem. I want to do the following:

$obj.getSomething( "param1", $obj2.getALongValue())

whereas $obj2.getALongValue() returns a value of 
type long (primitive). The result is that velocity
renders this as text instead of evaluating it.
When I put $obj2.getALongValue() somewhere in my 
template, it renders correctly to the value of
the method-call. If I do something like:

#set ($value = 2) <-- Note: NOT a long
$obj.getSomething( "param1", $value)

it renders correctly. Does velocity have a 
problem with long parameters? I think I remember
a maildiscussion about that, but I am not sure
(and I was not able to find something in the
archives).

Am I missing something? If this is a bug - is there
a workaround? BTW: I use velocity-1.2.

Peter


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: forumdemo & tomcat problems

Posted by Emyr James <em...@OrbisUK.com>.
Dear all,

I think I may have discovered the cause of my problems.
I was using a binary version of tomcat3.2.4, a binary version of velocity, and I was
using JDK1.4.
I don't think the class loader in tomcat likes it when components have been built
using various versions of the JDK.
I tried using Tomcat4 (which had been built with java1.4) and the problems went away.
Does this make any sense ?

Regards,
Emyr

Emyr James wrote:

> I'm using the Velocity1.3 release.
> I have velocity-dep-1.3-rc1.jar in the $TOMCAT_HOME/webapps/forumdemo/WEB-INF/lib
> directory.
>
> "Geir Magnusson Jr." wrote:
>
> > On 4/15/02 11:08 AM, "Emyr James" <em...@OrbisUK.com> wrote:
> >
> > > Dear all,
> > >
> > > I've been using velocity in java apps without any problems. I now want
> > > to start using it within servlets.
> > > I built the forumdemo example, put forumdemo.war in the webapps
> > > directory, and fired up my browser.
> > > The fromt page appears fine, but when I click on 'Today's blab topic' I
> > > get...
> > >
> >
> > Is the velocity-dep-XX.jar in the WAR?  There was a report of that.
> >
> > Also, are you using a Velocity distribution, a nightly, or getting from CVS?
> >
> > geir
> >
> > > Error: 500
> > > Location: /forumdemo/servlet/forum
> > > Internal Servlet Error:
> > >
> > > java.lang.NullPointerException
> > > at java.lang.ClassLoader.resolveClass0(Native Method)
> > > at java.lang.ClassLoader.resolveClass(ClassLoader.java:641)
> > > at
> > > org.apache.tomcat.loader.AdaptiveClassLoader.loadClass(AdaptiveClassLoader.jav
> > > a:430)
> > >
> > > at
> > > org.apache.tomcat.loader.AdaptiveServletLoader.loadClass(AdaptiveServletLoader
> > > .java:174)
> > >
> > > at
> > > org.apache.tomcat.core.ServletWrapper.loadServlet(ServletWrapper.java:265)
> > >
> > > at org.apache.tomcat.core.ServletWrapper.init(ServletWrapper.java:289)
> > > at org.apache.tomcat.core.Handler.service(Handler.java:254)
> > > at
> > > org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
> > > at
> > > org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:806)
> > >
> > > at
> > > org.apache.tomcat.core.ContextManager.service(ContextManager.java:752)
> > > at
> > > org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpCon
> > > nectionHandler.java:213)
> > >
> > > at
> > > org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
> > >
> > > at
> > > org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
> > >
> > > at java.lang.Thread.run(Thread.java:536)
> > >
> > > I get very similar problems when I try to do very simple stuff that uses
> > > VelocityServlet.
> > >
> > > Can anyone give me any hints / pointers as to where I'm going wrong?
> > >
> > > Many Thanks,
> > > Emyr James
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > > <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> > > <ma...@jakarta.apache.org>
> > >
> >
> > --
> > Geir Magnusson Jr.                                     geirm@optonline.net
> > System and Software Consulting
> > Be a giant.  Take giant steps.  Do giant things...
> >
> > --
> > To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> > For additional commands, e-mail: <ma...@jakarta.apache.org>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: forumdemo & tomcat problems

Posted by Emyr James <em...@OrbisUK.com>.
I'm using the Velocity1.3 release.
I have velocity-dep-1.3-rc1.jar in the $TOMCAT_HOME/webapps/forumdemo/WEB-INF/lib
directory.

"Geir Magnusson Jr." wrote:

> On 4/15/02 11:08 AM, "Emyr James" <em...@OrbisUK.com> wrote:
>
> > Dear all,
> >
> > I've been using velocity in java apps without any problems. I now want
> > to start using it within servlets.
> > I built the forumdemo example, put forumdemo.war in the webapps
> > directory, and fired up my browser.
> > The fromt page appears fine, but when I click on 'Today's blab topic' I
> > get...
> >
>
> Is the velocity-dep-XX.jar in the WAR?  There was a report of that.
>
> Also, are you using a Velocity distribution, a nightly, or getting from CVS?
>
> geir
>
> > Error: 500
> > Location: /forumdemo/servlet/forum
> > Internal Servlet Error:
> >
> > java.lang.NullPointerException
> > at java.lang.ClassLoader.resolveClass0(Native Method)
> > at java.lang.ClassLoader.resolveClass(ClassLoader.java:641)
> > at
> > org.apache.tomcat.loader.AdaptiveClassLoader.loadClass(AdaptiveClassLoader.jav
> > a:430)
> >
> > at
> > org.apache.tomcat.loader.AdaptiveServletLoader.loadClass(AdaptiveServletLoader
> > .java:174)
> >
> > at
> > org.apache.tomcat.core.ServletWrapper.loadServlet(ServletWrapper.java:265)
> >
> > at org.apache.tomcat.core.ServletWrapper.init(ServletWrapper.java:289)
> > at org.apache.tomcat.core.Handler.service(Handler.java:254)
> > at
> > org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
> > at
> > org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:806)
> >
> > at
> > org.apache.tomcat.core.ContextManager.service(ContextManager.java:752)
> > at
> > org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpCon
> > nectionHandler.java:213)
> >
> > at
> > org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
> >
> > at
> > org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
> >
> > at java.lang.Thread.run(Thread.java:536)
> >
> > I get very similar problems when I try to do very simple stuff that uses
> > VelocityServlet.
> >
> > Can anyone give me any hints / pointers as to where I'm going wrong?
> >
> > Many Thanks,
> > Emyr James
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> >
>
> --
> Geir Magnusson Jr.                                     geirm@optonline.net
> System and Software Consulting
> Be a giant.  Take giant steps.  Do giant things...
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: forumdemo & tomcat problems

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 4/15/02 11:08 AM, "Emyr James" <em...@OrbisUK.com> wrote:

> Dear all,
> 
> I've been using velocity in java apps without any problems. I now want
> to start using it within servlets.
> I built the forumdemo example, put forumdemo.war in the webapps
> directory, and fired up my browser.
> The fromt page appears fine, but when I click on 'Today's blab topic' I
> get...
> 

Is the velocity-dep-XX.jar in the WAR?  There was a report of that.

Also, are you using a Velocity distribution, a nightly, or getting from CVS?

geir

> Error: 500
> Location: /forumdemo/servlet/forum
> Internal Servlet Error:
> 
> java.lang.NullPointerException
> at java.lang.ClassLoader.resolveClass0(Native Method)
> at java.lang.ClassLoader.resolveClass(ClassLoader.java:641)
> at
> org.apache.tomcat.loader.AdaptiveClassLoader.loadClass(AdaptiveClassLoader.jav
> a:430)
> 
> at
> org.apache.tomcat.loader.AdaptiveServletLoader.loadClass(AdaptiveServletLoader
> .java:174)
> 
> at
> org.apache.tomcat.core.ServletWrapper.loadServlet(ServletWrapper.java:265)
> 
> at org.apache.tomcat.core.ServletWrapper.init(ServletWrapper.java:289)
> at org.apache.tomcat.core.Handler.service(Handler.java:254)
> at
> org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
> at
> org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:806)
> 
> at
> org.apache.tomcat.core.ContextManager.service(ContextManager.java:752)
> at
> org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpCon
> nectionHandler.java:213)
> 
> at
> org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
> 
> at
> org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
> 
> at java.lang.Thread.run(Thread.java:536)
> 
> I get very similar problems when I try to do very simple stuff that uses
> VelocityServlet.
> 
> Can anyone give me any hints / pointers as to where I'm going wrong?
> 
> Many Thanks,
> Emyr James
> 
> 
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 

-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
Be a giant.  Take giant steps.  Do giant things...


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>