You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by "E.R. van Es" <er...@cdls.nl> on 2006/01/06 13:24:50 UTC
configuration conflicts
Hi All,
I have a small problem when deploying two .war files on jboss-4.0.1.
Both .war files contain a servlet (velocity version used: 1.4) like this
(in very short):
--- code ---
public class blahservlet extends VelocityServlet {
public void init(ServletConfig servletConfig) throws ServletException {
super.init(servletConfig);
}
public Properties loadConfiguration(ServletConfig servletConfig) {
Properties p = new Properties();
p.put(Velocity.FILE_RESOURCE_LOADER_PATH,
servletConfig.getServletContext().getRealPath("/"));
return p;
}
}
--- end code ---
and a basic handleRequest method of course. Following the developer
guide I've put velocity-1.4.jar in the WEB-INF/lib directory of each
application to seperate the configurations. I've put some
System.out.println(...) debugging output in the init(),
loadConfiguration() and handleRequest() methods, wich puzzles me. When
I access the first servlet I get:
--- debug servlet 1 ---
[STDOUT] servlet1.loadConfiguration() called, set template path to
"<jboss-dir>/app1.war/"
[STDOUT] servlet1.init() called
[STDOUT] servlet1.handleRequest() template: <jboss-dir>/war1.war/index.vm
--- end debug servlet 1 ---
This seems correct. The path is correct. The page is rendered
correct. However, after this I access the second servlet. The
following debug output puzzles me:
--- debug servlet 2 ---
[STDOUT] servlet1.loadConfiguration() called, set template path to
"<jboss-dir>/app2.war/"
[STDOUT] servlet2.init() called
[STDOUT] servlet2.handleRequest() template: <jboss-dir>/war1.war/index.vm
--- end debug servlet 2 ---
As you can see, on accessing the second servlet, it calls
loadConfiguration of the FIRST servlet, while settings the path to the
CORRECT value for the second template (this means the servletContext is
correct, jboss is calling the correct servlet with the correct context I
guess?). Then the handleRequest() method debug tells me that whilst the
file_resource_loader_path value is correct (though set through the wrong
servlet) the template is retreived from the app1.war/ directory. I can
assure that velocity is nowhere to be found in the classpath of the
server itself, it only exists in the WEB-INF/lib directories of
app1.war/ and app2.war/. Can there be some caching mechanism issue
here? Or anything else? Any help is greatly appreciated,
Thanks in advance,
Eric
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: configuration conflicts
Posted by "E.R. van Es" <er...@cdls.nl>.
Hi,
Ah that's what I was looking for, though the download link seems broken...
Regards,
Eric
Will Glass-Husain wrote:
> Hi Eric,
>
> First obligatory note -- you might want to try VelocityViewServlet
> (from the Velocity Tools project). It's the descendant of
> VelocityServlet and is actively supported and being developed. (We're
> deprecating the original VelocityServlet) in the upcoming Velocity 1.5
> release.
>
> The problem is that VelocityServlet uses the singleton method of
> configuring Velocity. (e.g. using the Velocity object instead of
> VelocityEngine). This means that both servlets share the same
> configuration and hence the same template path.
>
> If you download the latest VelocityViewServlet from Velocity Tools
> this uses the VelocityEngine approach (e.g. non singleton) so the two
> servlets can have separate configuration settings.
>
> Best, WILL
>
> ----- Original Message ----- From: "E.R. van Es" <er...@cdls.nl>
> To: "Velocity Users List" <ve...@jakarta.apache.org>
> Sent: Monday, January 09, 2006 7:44 AM
> Subject: Re: configuration conflicts
>
>
>> Sorry to bump this thread but is there really no one who can help me
>> with this? Someone able to reproduce this maybe? I just saw I made
>> a little mistake writing the log files here: this must be
>> --- debug servlet 1 ---
>> [STDOUT] servlet1.loadConfiguration() called, set template path to
>> "<jboss-dir>/app1.war/"
>> [STDOUT] servlet1.init() called
>> [STDOUT] servlet1.handleRequest() template:
>> <jboss-dir>/app1.war/index.vm
>> --- end debug servlet 1 ---
>> This seems correct. The path is correct. The page is rendered
>> correct. However, after this I access the second servlet. The
>> following debug output puzzles me:
>> --- debug servlet 2 ---
>> [STDOUT] servlet1.loadConfiguration() called, set template path to
>> "<jboss-dir>/app2.war/"
>> [STDOUT] servlet2.init() called
>> [STDOUT] servlet2.handleRequest() template:
>> <jboss-dir>/app1.war/index.vm
>> --- end debug servlet 2 ---
>> so it's "handleRequest() template: <jboss-dir>/app1.war/index.vm" in
>> both cases. Anyone can confirm this behaviour at least? Thanks...
>>
>> Regards,
>> Eric
>>
>> E.R. van Es wrote:
>>
>>> Hi All,
>>>
>>> I have a small problem when deploying two .war files on
>>> jboss-4.0.1. Both .war files contain a servlet (velocity version
>>> used: 1.4) like this (in very short):
>>> --- code ---
>>> public class blahservlet extends VelocityServlet {
>>> public void init(ServletConfig servletConfig) throws
>>> ServletException {
>>> super.init(servletConfig);
>>> }
>>>
>>> public Properties loadConfiguration(ServletConfig servletConfig) {
>>> Properties p = new Properties();
>>> p.put(Velocity.FILE_RESOURCE_LOADER_PATH,
>>> servletConfig.getServletContext().getRealPath("/"));
>>> return p;
>>> }
>>> }
>>> --- end code ---
>>> and a basic handleRequest method of course. Following the developer
>>> guide I've put velocity-1.4.jar in the WEB-INF/lib directory of each
>>> application to seperate the configurations. I've put some
>>> System.out.println(...) debugging output in the init(),
>>> loadConfiguration() and handleRequest() methods, wich puzzles me.
>>> When I access the first servlet I get:
>>> --- debug servlet 1 ---
>>> [STDOUT] servlet1.loadConfiguration() called, set template path to
>>> "<jboss-dir>/app1.war/"
>>> [STDOUT] servlet1.init() called
>>> [STDOUT] servlet1.handleRequest() template:
>>> <jboss-dir>/war1.war/index.vm
>>> --- end debug servlet 1 ---
>>> This seems correct. The path is correct. The page is rendered
>>> correct. However, after this I access the second servlet. The
>>> following debug output puzzles me:
>>> --- debug servlet 2 ---
>>> [STDOUT] servlet1.loadConfiguration() called, set template path to
>>> "<jboss-dir>/app2.war/"
>>> [STDOUT] servlet2.init() called
>>> [STDOUT] servlet2.handleRequest() template:
>>> <jboss-dir>/war1.war/index.vm
>>> --- end debug servlet 2 ---
>>> As you can see, on accessing the second servlet, it calls
>>> loadConfiguration of the FIRST servlet, while settings the path to
>>> the CORRECT value for the second template (this means the
>>> servletContext is correct, jboss is calling the correct servlet with
>>> the correct context I guess?). Then the handleRequest() method
>>> debug tells me that whilst the file_resource_loader_path value is
>>> correct (though set through the wrong servlet) the template is
>>> retreived from the app1.war/ directory. I can assure that velocity
>>> is nowhere to be found in the classpath of the server itself, it
>>> only exists in the WEB-INF/lib directories of app1.war/ and
>>> app2.war/. Can there be some caching mechanism issue here? Or
>>> anything else? Any help is greatly appreciated,
>>>
>>> Thanks in advance,
>>> Eric
>>>
>>> ---------------------------------------------------------------------
>>> 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
>
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: configuration conflicts
Posted by Will Glass-Husain <wg...@forio.com>.
Hi Eric,
First obligatory note -- you might want to try VelocityViewServlet (from the
Velocity Tools project). It's the descendant of VelocityServlet and is
actively supported and being developed. (We're deprecating the original
VelocityServlet) in the upcoming Velocity 1.5 release.
The problem is that VelocityServlet uses the singleton method of configuring
Velocity. (e.g. using the Velocity object instead of VelocityEngine). This
means that both servlets share the same configuration and hence the same
template path.
If you download the latest VelocityViewServlet from Velocity Tools this uses
the VelocityEngine approach (e.g. non singleton) so the two servlets can
have separate configuration settings.
Best, WILL
----- Original Message -----
From: "E.R. van Es" <er...@cdls.nl>
To: "Velocity Users List" <ve...@jakarta.apache.org>
Sent: Monday, January 09, 2006 7:44 AM
Subject: Re: configuration conflicts
> Sorry to bump this thread but is there really no one who can help me with
> this? Someone able to reproduce this maybe? I just saw I made a little
> mistake writing the log files here: this must be
> --- debug servlet 1 ---
> [STDOUT] servlet1.loadConfiguration() called, set template path to
> "<jboss-dir>/app1.war/"
> [STDOUT] servlet1.init() called
> [STDOUT] servlet1.handleRequest() template: <jboss-dir>/app1.war/index.vm
> --- end debug servlet 1 ---
> This seems correct. The path is correct. The page is rendered correct.
> However, after this I access the second servlet. The following debug
> output puzzles me:
> --- debug servlet 2 ---
> [STDOUT] servlet1.loadConfiguration() called, set template path to
> "<jboss-dir>/app2.war/"
> [STDOUT] servlet2.init() called
> [STDOUT] servlet2.handleRequest() template: <jboss-dir>/app1.war/index.vm
> --- end debug servlet 2 ---
> so it's "handleRequest() template: <jboss-dir>/app1.war/index.vm" in both
> cases. Anyone can confirm this behaviour at least? Thanks...
>
> Regards,
> Eric
>
> E.R. van Es wrote:
>
>> Hi All,
>>
>> I have a small problem when deploying two .war files on jboss-4.0.1.
>> Both .war files contain a servlet (velocity version used: 1.4) like this
>> (in very short):
>> --- code ---
>> public class blahservlet extends VelocityServlet {
>> public void init(ServletConfig servletConfig) throws ServletException
>> {
>> super.init(servletConfig);
>> }
>>
>> public Properties loadConfiguration(ServletConfig servletConfig) {
>> Properties p = new Properties();
>> p.put(Velocity.FILE_RESOURCE_LOADER_PATH,
>> servletConfig.getServletContext().getRealPath("/"));
>> return p;
>> }
>> }
>> --- end code ---
>> and a basic handleRequest method of course. Following the developer
>> guide I've put velocity-1.4.jar in the WEB-INF/lib directory of each
>> application to seperate the configurations. I've put some
>> System.out.println(...) debugging output in the init(),
>> loadConfiguration() and handleRequest() methods, wich puzzles me. When I
>> access the first servlet I get:
>> --- debug servlet 1 ---
>> [STDOUT] servlet1.loadConfiguration() called, set template path to
>> "<jboss-dir>/app1.war/"
>> [STDOUT] servlet1.init() called
>> [STDOUT] servlet1.handleRequest() template: <jboss-dir>/war1.war/index.vm
>> --- end debug servlet 1 ---
>> This seems correct. The path is correct. The page is rendered correct.
>> However, after this I access the second servlet. The following debug
>> output puzzles me:
>> --- debug servlet 2 ---
>> [STDOUT] servlet1.loadConfiguration() called, set template path to
>> "<jboss-dir>/app2.war/"
>> [STDOUT] servlet2.init() called
>> [STDOUT] servlet2.handleRequest() template: <jboss-dir>/war1.war/index.vm
>> --- end debug servlet 2 ---
>> As you can see, on accessing the second servlet, it calls
>> loadConfiguration of the FIRST servlet, while settings the path to the
>> CORRECT value for the second template (this means the servletContext is
>> correct, jboss is calling the correct servlet with the correct context I
>> guess?). Then the handleRequest() method debug tells me that whilst the
>> file_resource_loader_path value is correct (though set through the wrong
>> servlet) the template is retreived from the app1.war/ directory. I can
>> assure that velocity is nowhere to be found in the classpath of the
>> server itself, it only exists in the WEB-INF/lib directories of app1.war/
>> and app2.war/. Can there be some caching mechanism issue here? Or
>> anything else? Any help is greatly appreciated,
>>
>> Thanks in advance,
>> Eric
>>
>> ---------------------------------------------------------------------
>> 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: configuration conflicts
Posted by "E.R. van Es" <er...@cdls.nl>.
Sorry to bump this thread but is there really no one who can help me
with this? Someone able to reproduce this maybe? I just saw I made a
little mistake writing the log files here: this must be
--- debug servlet 1 ---
[STDOUT] servlet1.loadConfiguration() called, set template path to
"<jboss-dir>/app1.war/"
[STDOUT] servlet1.init() called
[STDOUT] servlet1.handleRequest() template: <jboss-dir>/app1.war/index.vm
--- end debug servlet 1 ---
This seems correct. The path is correct. The page is rendered
correct. However, after this I access the second servlet. The
following debug output puzzles me:
--- debug servlet 2 ---
[STDOUT] servlet1.loadConfiguration() called, set template path to
"<jboss-dir>/app2.war/"
[STDOUT] servlet2.init() called
[STDOUT] servlet2.handleRequest() template: <jboss-dir>/app1.war/index.vm
--- end debug servlet 2 ---
so it's "handleRequest() template: <jboss-dir>/app1.war/index.vm" in
both cases. Anyone can confirm this behaviour at least? Thanks...
Regards,
Eric
E.R. van Es wrote:
> Hi All,
>
> I have a small problem when deploying two .war files on jboss-4.0.1.
> Both .war files contain a servlet (velocity version used: 1.4) like
> this (in very short):
> --- code ---
> public class blahservlet extends VelocityServlet {
> public void init(ServletConfig servletConfig) throws
> ServletException {
> super.init(servletConfig);
> }
>
> public Properties loadConfiguration(ServletConfig servletConfig) {
> Properties p = new Properties();
> p.put(Velocity.FILE_RESOURCE_LOADER_PATH,
> servletConfig.getServletContext().getRealPath("/"));
> return p;
> }
> }
> --- end code ---
> and a basic handleRequest method of course. Following the developer
> guide I've put velocity-1.4.jar in the WEB-INF/lib directory of each
> application to seperate the configurations. I've put some
> System.out.println(...) debugging output in the init(),
> loadConfiguration() and handleRequest() methods, wich puzzles me.
> When I access the first servlet I get:
> --- debug servlet 1 ---
> [STDOUT] servlet1.loadConfiguration() called, set template path to
> "<jboss-dir>/app1.war/"
> [STDOUT] servlet1.init() called
> [STDOUT] servlet1.handleRequest() template: <jboss-dir>/war1.war/index.vm
> --- end debug servlet 1 ---
> This seems correct. The path is correct. The page is rendered
> correct. However, after this I access the second servlet. The
> following debug output puzzles me:
> --- debug servlet 2 ---
> [STDOUT] servlet1.loadConfiguration() called, set template path to
> "<jboss-dir>/app2.war/"
> [STDOUT] servlet2.init() called
> [STDOUT] servlet2.handleRequest() template: <jboss-dir>/war1.war/index.vm
> --- end debug servlet 2 ---
> As you can see, on accessing the second servlet, it calls
> loadConfiguration of the FIRST servlet, while settings the path to the
> CORRECT value for the second template (this means the servletContext
> is correct, jboss is calling the correct servlet with the correct
> context I guess?). Then the handleRequest() method debug tells me
> that whilst the file_resource_loader_path value is correct (though set
> through the wrong servlet) the template is retreived from the
> app1.war/ directory. I can assure that velocity is nowhere to be
> found in the classpath of the server itself, it only exists in the
> WEB-INF/lib directories of app1.war/ and app2.war/. Can there be some
> caching mechanism issue here? Or anything else? Any help is greatly
> appreciated,
>
> Thanks in advance,
> Eric
>
> ---------------------------------------------------------------------
> 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