You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Nick Bauman <ni...@cortexity.com> on 2001/09/05 07:00:26 UTC

IllegalAccessException ??

I have a Velocity Template that can't seem to render attributes from a 
request dispacher's forward. What am I missing here?

04Sep-23:50:22.588[nnection-6802-0] INFO  
|pache.velocity.VelocityContext|   [info] ResourceManager : 
found /diagnostic.vtl with loader 
org.apache.velocity.runtime.resource.loader.FileResourceLoader
ASTMethod.execute() : exception invoking method 'getParameterNames' in 
class com.caucho.server.http.DispatchRequest : 
java.lang.IllegalAccessException
ASTMethod.execute() : exception invoking method 'getAttributeNames' in 
class com.caucho.server.http.DispatchRequest : 
java.lang.IllegalAccessException

Thanks for the clue.

-- 
Nick Bauman
3600 N. Dupont
Minneapolis, MN 55412
Mobile: (612) 232-7120
Home: (612) 522-0165


Re: IllegalAccessException ??

Posted by Bill Burton <bi...@progress.com>.
"Geir Magnusson Jr." wrote:
> > Only question remains is how can I detect the encoding of a page written in
> > velocity at runtime? I have it hardcoded now for 8859-1.
> 
> You can't.  It is something that you have to know, just like you have to
> know what template you want to render to show a page.
> 
> I think that the majority of people will be using only one encoding.  Maybe
> we should undeprecate the merge call that assumes the encoding default?

Yes, please do.  If the encoding has already been configured via
properties, it shouldn't be a requirement to also specify it when calling
mergeTemplate.  I ran into this and was wondering why using the default
wasn't acceptable.

Thanks,
-Bill

Re: Page encoding

Posted by Nick Bauman <ni...@cortexity.com>.
> On 9/7/01 12:59 PM, "Nick Bauman" <ni...@cortexity.com> wrote:
> 
>>>  
>>>> Only question remains is how can I detect the encoding of a page
>>>> written in velocity at runtime? I have it hardcoded now for 8859-1.
>>> 
>>> You can't.  It is something that you have to know, just like you have
>>> to know what template you want to render to show a page.
>> 
>> So it's something I have to set on a webapp-level basis with an
>> init-param. Maybe I can figure out how to map certain file extenstions
>> to certain accept-language headers  or something...? I'll rub on it a
>> bit more and report back.
> 
> Yes, it would be something like that - because there is no way for
> velocity to tell automatically what the character representation of
> your bytestreams (files) are...
>> 
>> JSP has this kind of thing set in the page directive (although it
>> never seemed to work in Jasper, but that was a while ago) so you
>> could, according to the spec, set the encoding on a per-page basis.
> 
> Isn't that output encoding?

Well, you'd think that was the case, otherwise they'd have to do strange
things like read the file as unicode to find the encoding header, then
switch encodings and convert the file... 

>>> I think that the majority of people will be using only one encoding.
>>> Maybe we should undeprecate the merge call that assumes the encoding
>>> default?
>> 
>> I have no strong opinion on this one way or the other. I only wish I'd
>> found Velocity sooner. I'm going to be teaching 2 newbies how to write
>> templates for Velocity using my framework this weekend. I taught 1
>> newbie already and he got it in 10 minutes. "It's fun, it's fast, it's
>> furry!" (okay, I have to come up with some other "f" word there...)
> 
> That's great!
> 
> I personally don't mix encodings, and I would be your average site, in
> whatever locale, does the same.   Of course, there are sites that
> support mixing based on user, for example, but I would assume that the
> template encoding is only part of their worries - other things such as
> string resources, date/currency format, idioms, etc matter just as, or
> even more.
> 

I have gotten requests before to make multilingual sites that autodetect the
language preference of the user's browser and serve up appropriately. (We do
it at work with our sites webhelp.fr in Mauritus, webhelp.de in Czeck
Republic and webhelp.com in Montreal using redirects, but its similar)
Apache can do that with static HTML and file extensions (Content
negotiation), but of course doing it with Velocity without some kind of
dynamic detection using file extensions mapped to accept-language headers,
there's no way I can think of to do that. 

> geir
> 
> -- 
> Geir Magnusson Jr.     geirm@optonline.net
> System and Software Consulting
> Developing for the web?  See http://jakarta.apache.org/velocity/
> If you look up, there are no limits - Japanese Proverb

Thanks again.

-- 
Nick Bauman
3600 N. Dupont
Minneapolis, MN 55412
Mobile: (612) 232-7120
Home: (612) 522-0165


Re: Page encoding (was IllegalAccessException ??)

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 9/7/01 12:59 PM, "Nick Bauman" <ni...@cortexity.com> wrote:

>>  
>>> Only question remains is how can I detect the encoding of a page
>>> written in velocity at runtime? I have it hardcoded now for 8859-1.
>> 
>> You can't.  It is something that you have to know, just like you have
>> to know what template you want to render to show a page.
> 
> So it's something I have to set on a webapp-level basis with an init-param.
> Maybe I can figure out how to map certain file extenstions to certain
> accept-language headers  or something...? I'll rub on it a bit more and
> report back.

Yes, it would be something like that - because there is no way for velocity
to tell automatically what the character representation of your bytestreams
(files) are...
> 
> JSP has this kind of thing set in the page directive (although it never
> seemed to work in Jasper, but that was a while ago) so you could, according
> to the spec, set the encoding on a per-page basis.

Isn't that output encoding?
 
>> I think that the majority of people will be using only one encoding.
>> Maybe we should undeprecate the merge call that assumes the encoding
>> default?
> 
> I have no strong opinion on this one way or the other. I only wish I'd found
> Velocity sooner. I'm going to be teaching 2 newbies how to write templates
> for Velocity using my framework this weekend. I taught 1 newbie already and
> he got it in 10 minutes. "It's fun, it's fast, it's furry!" (okay, I have to
> come up with some other "f" word there...)

That's great!

I personally don't mix encodings, and I would be your average site, in
whatever locale, does the same.   Of course, there are sites that support
mixing based on user, for example, but I would assume that the template
encoding is only part of their worries - other things such as string
resources, date/currency format, idioms, etc matter just as, or even more.

geir


-- 
Geir Magnusson Jr.     geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
If you look up, there are no limits - Japanese Proverb


Page encoding (was IllegalAccessException ??)

Posted by Nick Bauman <ni...@cortexity.com>.
>  
>> Only question remains is how can I detect the encoding of a page
>> written in velocity at runtime? I have it hardcoded now for 8859-1.
> 
> You can't.  It is something that you have to know, just like you have
> to know what template you want to render to show a page.

So it's something I have to set on a webapp-level basis with an init-param.
Maybe I can figure out how to map certain file extenstions to certain
accept-language headers  or something...? I'll rub on it a bit more and
report back.

JSP has this kind of thing set in the page directive (although it never
seemed to work in Jasper, but that was a while ago) so you could, according
to the spec, set the encoding on a per-page basis.

> I think that the majority of people will be using only one encoding. 
> Maybe we should undeprecate the merge call that assumes the encoding
> default?

I have no strong opinion on this one way or the other. I only wish I'd found
Velocity sooner. I'm going to be teaching 2 newbies how to write templates
for Velocity using my framework this weekend. I taught 1 newbie already and
he got it in 10 minutes. "It's fun, it's fast, it's furry!" (okay, I have to
come up with some other "f" word there...)

> geir
> 
> -- 
> Geir Magnusson Jr.     geirm@optonline.net
> System and Software Consulting
> Developing for the web?  See http://jakarta.apache.org/velocity/
> If you look up, there are no limits - Japanese Proverb



-- 
Nick Bauman
3600 N. Dupont
Minneapolis, MN 55412
Mobile: (612) 232-7120
Home: (612) 522-0165


Re: IllegalAccessException ??

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 9/6/01 3:19 PM, "Nick Bauman" <ni...@cortexity.com> wrote:

> Geir,
> 
> I have since updated to yesterday's nightly and this has totally fixed the
> problem. I no longer see the exception and I can freely access request
> parameters and attributes and session variables from pages that were
> forwarded. CooooOOOOooooOOOOooooOOOOL!!!
> 
> The only thing I had to do was add the init() method to my LoggingSystem
> impl and change my merge() call to pass the encoding. (deprecated API
> warnings)

Great.  This is good validation of 1.2
 
> Only question remains is how can I detect the encoding of a page written in
> velocity at runtime? I have it hardcoded now for 8859-1.

You can't.  It is something that you have to know, just like you have to
know what template you want to render to show a page.

I think that the majority of people will be using only one encoding.  Maybe
we should undeprecate the merge call that assumes the encoding default?

geir

-- 
Geir Magnusson Jr.     geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
If you look up, there are no limits - Japanese Proverb


Re: IllegalAccessException ??

Posted by Nick Bauman <ni...@cortexity.com>.
Geir,

I have since updated to yesterday's nightly and this has totally fixed the 
problem. I no longer see the exception and I can freely access request 
parameters and attributes and session variables from pages that were 
forwarded. CooooOOOOooooOOOOooooOOOOL!!!

The only thing I had to do was add the init() method to my LoggingSystem 
impl and change my merge() call to pass the encoding. (deprecated API 
warnings)

Only question remains is how can I detect the encoding of a page written in 
velocity at runtime? I have it hardcoded now for 8859-1.

> On 9/5/01 1:00 AM, "Nick Bauman" <ni...@cortexity.com> wrote:
> 
>> I have a Velocity Template that can't seem to render attributes from a
>> request dispacher's forward. What am I missing here?
>> 
>> 04Sep-23:50:22.588[nnection-6802-0] INFO
>> |pache.velocity.VelocityContext|   [info] ResourceManager :
>> found /diagnostic.vtl with loader
>> org.apache.velocity.runtime.resource.loader.FileResourceLoader
>> ASTMethod.execute() : exception invoking method 'getParameterNames' in
>> class com.caucho.server.http.DispatchRequest :
>> java.lang.IllegalAccessException
>> ASTMethod.execute() : exception invoking method 'getAttributeNames' in
>> class com.caucho.server.http.DispatchRequest :
>> java.lang.IllegalAccessException
>> 
>> Thanks for the clue.
> 
> Are you using 1.2-dev ?  Looks like an introspector issue.
> 
> Geir
> 
> -- 
> Geir Magnusson Jr.     geirm@optonline.net
> System and Software Consulting
> Developing for the web?  See http://jakarta.apache.org/velocity/
> If you look up, there are no limits - Japanese Proverb


-- 
Nick Bauman
3600 N. Dupont
Minneapolis, MN 55412
Mobile: (612) 232-7120
SMS: 6122327120@voicestream.net
Home: (612) 522-0165


Re: IllegalAccessException ?? LogSystem changed in 1.2

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 9/5/01 11:15 PM, "Nick Bauman" <ni...@cortexity.com> wrote:

> OK Geir, upgrading to 1.2-dev, I see the interface to LogSystem has
> changed...
> 
> [javac] /home/nick/projects/ttmor/src/com/cortexity/util/VelocityLoggerAdapt
> er.java:27: com.cortexity.util.VelocityLoggerAdapter should be declared
> abstract; it does not define init
> (org.apache.velocity.runtime.RuntimeServices) in
> com.cortexity.util.VelocityLoggerAdapter
>   [javac] public final class VelocityLoggerAdapter implements LogSystem {
>   [javac]              ^
>   [javac] 
> Note: /home/nick/projects/ttmor/src/com/cortexity/servlet/VTLDispatcher.java
> uses or overrides a deprecated API.
>   [javac] Note: Recompile with -deprecation for details.
>   [javac] 1 error
> 
> So I need to implement RuntimeServices interface in my LogSystem impl. and
> make my logging interface consume that so that initializing Velocity
> logging and my app's logging is done the same way? Sorry if this comes
> across as Thick As A Whale Omlette (tm) as usual.

Not sure about how you phrased it, but you simply must add an init method
that takes a RuntimeServices argument.

Your logger has no responsibilities re that, just that the interface has to
have it for others that may want access to the runtime instance they are
running in.

Hope it isn't too much trouble.  This is the obvious downside to using
interfaces rather than base classes...

geir



Re: IllegalAccessException ?? LogSystem changed in 1.2

Posted by Nick Bauman <ni...@cortexity.com>.
OK Geir, upgrading to 1.2-dev, I see the interface to LogSystem has 
changed...

[javac] /home/nick/projects/ttmor/src/com/cortexity/util/VelocityLoggerAdapt
er.java:27: com.cortexity.util.VelocityLoggerAdapter should be declared 
abstract; it does not define init
(org.apache.velocity.runtime.RuntimeServices) in 
com.cortexity.util.VelocityLoggerAdapter
    [javac] public final class VelocityLoggerAdapter implements LogSystem {
    [javac]              ^
    [javac] 
Note: /home/nick/projects/ttmor/src/com/cortexity/servlet/VTLDispatcher.java
 uses or overrides a deprecated API.
    [javac] Note: Recompile with -deprecation for details.
    [javac] 1 error

So I need to implement RuntimeServices interface in my LogSystem impl. and 
make my logging interface consume that so that initializing Velocity 
logging and my app's logging is done the same way? Sorry if this comes 
across as Thick As A Whale Omlette (tm) as usual.
 

> On 9/5/01 1:00 AM, "Nick Bauman" <ni...@cortexity.com> wrote:
> 
>> I have a Velocity Template that can't seem to render attributes from a
>> request dispacher's forward. What am I missing here?
>> 
>> 04Sep-23:50:22.588[nnection-6802-0] INFO
>> |pache.velocity.VelocityContext|   [info] ResourceManager :
>> found /diagnostic.vtl with loader
>> org.apache.velocity.runtime.resource.loader.FileResourceLoader
>> ASTMethod.execute() : exception invoking method 'getParameterNames' in
>> class com.caucho.server.http.DispatchRequest :
>> java.lang.IllegalAccessException
>> ASTMethod.execute() : exception invoking method 'getAttributeNames' in
>> class com.caucho.server.http.DispatchRequest :
>> java.lang.IllegalAccessException
>> 
>> Thanks for the clue.
> 
> Are you using 1.2-dev ?  Looks like an introspector issue.
> 
> Geir
> 
> -- 
> Geir Magnusson Jr.     geirm@optonline.net
> System and Software Consulting
> Developing for the web?  See http://jakarta.apache.org/velocity/
> If you look up, there are no limits - Japanese Proverb


-- 
Nick Bauman
3600 N. Dupont
Minneapolis, MN 55412
Mobile: (612) 232-7120
Home: (612) 522-0165


Re: IllegalAccessException ??

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 9/5/01 4:44 PM, "Nick Bauman" <ni...@cortexity.com> wrote:

>> On 9/5/01 1:00 AM, "Nick Bauman" <ni...@cortexity.com> wrote:
>> 
>>> I have a Velocity Template that can't seem to render attributes from a
>>> request dispacher's forward. What am I missing here?
>>> 
>>> 04Sep-23:50:22.588[nnection-6802-0] INFO
>>> |pache.velocity.VelocityContext|   [info] ResourceManager :
>>> found /diagnostic.vtl with loader
>>> org.apache.velocity.runtime.resource.loader.FileResourceLoader
>>> ASTMethod.execute() : exception invoking method 'getParameterNames' in
>>> class com.caucho.server.http.DispatchRequest :
>>> java.lang.IllegalAccessException
>>> ASTMethod.execute() : exception invoking method 'getAttributeNames' in
>>> class com.caucho.server.http.DispatchRequest :
>>> java.lang.IllegalAccessException
>>> 
>>> Thanks for the clue.
>> 
>> Are you using 1.2-dev ?  Looks like an introspector issue.
>> 
>> Geir
>> 
>> -- 
>> Geir Magnusson Jr.     geirm@optonline.net
>> System and Software Consulting
>> Developing for the web?  See http://jakarta.apache.org/velocity/
>> If you look up, there are no limits - Japanese Proverb
> 
> 
> I'm using 1.1 final. Do I have to upgrade to a nightly build to get around
> this?

Yes.  I bet then it is the introspector issue - try the 1.2-dev.  It's very
stable.  There will be a release Real Soon Now as soon as I get the last
bits in...

geir



Re: IllegalAccessException ??

Posted by Nick Bauman <ni...@cortexity.com>.
> On 9/5/01 1:00 AM, "Nick Bauman" <ni...@cortexity.com> wrote:
> 
>> I have a Velocity Template that can't seem to render attributes from a
>> request dispacher's forward. What am I missing here?
>> 
>> 04Sep-23:50:22.588[nnection-6802-0] INFO
>> |pache.velocity.VelocityContext|   [info] ResourceManager :
>> found /diagnostic.vtl with loader
>> org.apache.velocity.runtime.resource.loader.FileResourceLoader
>> ASTMethod.execute() : exception invoking method 'getParameterNames' in
>> class com.caucho.server.http.DispatchRequest :
>> java.lang.IllegalAccessException
>> ASTMethod.execute() : exception invoking method 'getAttributeNames' in
>> class com.caucho.server.http.DispatchRequest :
>> java.lang.IllegalAccessException
>> 
>> Thanks for the clue.
> 
> Are you using 1.2-dev ?  Looks like an introspector issue.
> 
> Geir
> 
> -- 
> Geir Magnusson Jr.     geirm@optonline.net
> System and Software Consulting
> Developing for the web?  See http://jakarta.apache.org/velocity/
> If you look up, there are no limits - Japanese Proverb


I'm using 1.1 final. Do I have to upgrade to a nightly build to get around this?

-- 
Nick Bauman
3600 N. Dupont
Minneapolis, MN 55412
Mobile: (612) 232-7120
Home: (612) 522-0165


Re: IllegalAccessException ??

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 9/5/01 1:00 AM, "Nick Bauman" <ni...@cortexity.com> wrote:

> I have a Velocity Template that can't seem to render attributes from a
> request dispacher's forward. What am I missing here?
> 
> 04Sep-23:50:22.588[nnection-6802-0] INFO
> |pache.velocity.VelocityContext|   [info] ResourceManager :
> found /diagnostic.vtl with loader
> org.apache.velocity.runtime.resource.loader.FileResourceLoader
> ASTMethod.execute() : exception invoking method 'getParameterNames' in
> class com.caucho.server.http.DispatchRequest :
> java.lang.IllegalAccessException
> ASTMethod.execute() : exception invoking method 'getAttributeNames' in
> class com.caucho.server.http.DispatchRequest :
> java.lang.IllegalAccessException
> 
> Thanks for the clue.

Are you using 1.2-dev ?  Looks like an introspector issue.

Geir

-- 
Geir Magnusson Jr.     geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
If you look up, there are no limits - Japanese Proverb