You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Ra...@lntinfotech.com on 2002/03/12 08:50:49 UTC

Problem in TOMCAT... URGENT

Hi all,


I have the servlet application using TOMCAT-IIS AND VELOCITY Template. My
OS is WIN2K SERVER.


I have the login.html page, in that on submitting the request from the
Login page, the servlet "LoginVerify" for verifying the Login information
is called,

In that servlet i have to verify the login information, if it is successful
i have to display the next screen using the template file. Actual problem
is when I call

"getTemplate("FunctionSelection.vm " ) " in my servlet that loads the
template file, i am getting the error message as

"org.apache.velocity.exception.ResourceNotFoundException: Unable to find
resource 'FunctionSelection.vm' "


Note : Here "FunctionSelection.vm" is my template file ( It is present
under /WEB-INF/templates folder as specified in velocity.properties file)

Please find the web.xml, velocity.properties file below.


web.xml file
************

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
    "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
<servlet>
    <servlet-name>LoginVerify</servlet-name>
    <servlet-class>cife.servlets.LoginVerify</servlet-class>
    <init-param>
         <param-name>properties</param-name>
         <param-value>/WEB-INF/velocity.properties</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
    </servlet>
</web-app>


velocity.properties file
********************

#
# we are taking advantage of the fact that the file
# resource loader is the default loader
#
file.resource.loader.path = WEB-INF/templates
runtime.log = WEB-INF/velocity.log


---------------------

Could anyone help me on how to do the configuration for web.xml and
velocity.properties file?

Thanks in advance.


With Regards,
Rangaraj



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


Re: Problem in TOMCAT... URGENT

Posted by James You <jy...@hywy.com>.
Hi, Rangaraj:
You may try to change the value of the properties for
"file.resource.loader.path"
to the differnt format in the velocity.properties file, such as:
     ---  file.resource.loader.path=./WEB-INF/templates
     --- 
file.resource.loader.path=c:\\tomcat\\webapp\\myApplication\\WEB-INF\\templates
You may need to test your currrent working directory using the following
code, then you can
determine how you can set the value for the properties of
"file.resource.loader.path".
     File file = new File(".");
     System.out.println(" The current working directory is -> " +
file.getAbsolutePath());

Or you may put your template file in the diffenet location to test your
application.

I hope the above suggestion can help you to find the problem.


James You
Hywy Software Inc.
Canada





Rangaraj.T@lntinfotech.com wrote:
> 
> Hi all,
> 
> I have the servlet application using TOMCAT-IIS AND VELOCITY Template. My
> OS is WIN2K SERVER.
> 
> I have the login.html page, in that on submitting the request from the
> Login page, the servlet "LoginVerify" for verifying the Login information
> is called,
> 
> In that servlet i have to verify the login information, if it is successful
> i have to display the next screen using the template file. Actual problem
> is when I call
> 
> "getTemplate("FunctionSelection.vm " ) " in my servlet that loads the
> template file, i am getting the error message as
> 
> "org.apache.velocity.exception.ResourceNotFoundException: Unable to find
> resource 'FunctionSelection.vm' "
> 
> Note : Here "FunctionSelection.vm" is my template file ( It is present
> under /WEB-INF/templates folder as specified in velocity.properties file)
> 
> Please find the web.xml, velocity.properties file below.
> 
> web.xml file
> ************
> 
> <?xml version="1.0" encoding="ISO-8859-1"?>
> 
> <!DOCTYPE web-app
>     PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
>     "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
> <web-app>
> <servlet>
>     <servlet-name>LoginVerify</servlet-name>
>     <servlet-class>cife.servlets.LoginVerify</servlet-class>
>     <init-param>
>          <param-name>properties</param-name>
>          <param-value>/WEB-INF/velocity.properties</param-value>
>     </init-param>
>     <load-on-startup>1</load-on-startup>
>     </servlet>
> </web-app>
> 
> velocity.properties file
> ********************
> 
> #
> # we are taking advantage of the fact that the file
> # resource loader is the default loader
> #
> file.resource.loader.path = WEB-INF/templates
> runtime.log = WEB-INF/velocity.log
> 
> ---------------------
> 
> Could anyone help me on how to do the configuration for web.xml and
> velocity.properties file?
> 
> Thanks in advance.
> 
> With Regards,
> Rangaraj
> 
> --
> 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: Problem in TOMCAT... URGENT

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 3/12/02 2:50 AM, "Rangaraj.T@lntinfotech.com"
<Ra...@lntinfotech.com> wrote:

[SNIP]
> 
> velocity.properties file
> ********************
> 
> #
> # we are taking advantage of the fact that the file
> # resource loader is the default loader
> #
> file.resource.loader.path = WEB-INF/templates
> runtime.log = WEB-INF/velocity.log
> 
> 
> ---------------------
> 
> Could anyone help me on how to do the configuration for web.xml and
> velocity.properties file?
> 

First thing is to make sure that the properties file is getting read - you
can look at the log output at the beginning to see what template path it is
using.

Assuming that all is well, my guess is that your servlet is setting that
path directly, and that is the root of the problem.  Velocity, being a
general purpose template engine, doesn't know about webapps or tomcat, so
when you configure Velocity for use in Tomcat, you need to do a little work.
If you are using the file resource loader, this means that you have to
convert from the relative path to an absolute path - take a look at the
examples/servlet_example2 code for a hint on how to do it.

Other alternatives include using the classpath resource loader - which
allows you to put your templates in a jar, drop that jar into WEB-INF/lib
and not have to worry about any configuration after that.  Or take a look at
the WebappResourceLoader in the jakarta-velocity-tools/view project...

geir


-- 
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: Problem in TOMCAT... URGENT

Posted by Barbara Baughman <ba...@utdallas.edu>.
I have runtime.log=/WEB-INF/velocity.log  (note the beginning "/")

Also, you need to have a override of the loadConfiguration() method of
VelocityServlet to get the paths set right.  See servlet example2.

Barbara Baughman
X2157

On Tue, 12 Mar 2002 Rangaraj.T@lntinfotech.com wrote:

> Hi all,
> 
> 
> I have the servlet application using TOMCAT-IIS AND VELOCITY Template. My
> OS is WIN2K SERVER.
> 
> 
> I have the login.html page, in that on submitting the request from the
> Login page, the servlet "LoginVerify" for verifying the Login information
> is called,
> 
> In that servlet i have to verify the login information, if it is successful
> i have to display the next screen using the template file. Actual problem
> is when I call
> 
> "getTemplate("FunctionSelection.vm " ) " in my servlet that loads the
> template file, i am getting the error message as
> 
> "org.apache.velocity.exception.ResourceNotFoundException: Unable to find
> resource 'FunctionSelection.vm' "
> 
> 
> Note : Here "FunctionSelection.vm" is my template file ( It is present
> under /WEB-INF/templates folder as specified in velocity.properties file)
> 
> Please find the web.xml, velocity.properties file below.
> 
> 
> web.xml file
> ************
> 
> <?xml version="1.0" encoding="ISO-8859-1"?>
> 
> <!DOCTYPE web-app
>     PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
>     "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
> <web-app>
> <servlet>
>     <servlet-name>LoginVerify</servlet-name>
>     <servlet-class>cife.servlets.LoginVerify</servlet-class>
>     <init-param>
>          <param-name>properties</param-name>
>          <param-value>/WEB-INF/velocity.properties</param-value>
>     </init-param>
>     <load-on-startup>1</load-on-startup>
>     </servlet>
> </web-app>
> 
> 
> velocity.properties file
> ********************
> 
> #
> # we are taking advantage of the fact that the file
> # resource loader is the default loader
> #
> file.resource.loader.path = WEB-INF/templates
> runtime.log = WEB-INF/velocity.log
> 
> 
> ---------------------
> 
> Could anyone help me on how to do the configuration for web.xml and
> velocity.properties file?
> 
> Thanks in advance.
> 
> 
> With Regards,
> Rangaraj
> 
> 
> 
> --
> 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>