velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Markos Charatzas <x...@forthnet.gr>
Subject Re: Using a standalone app in a servlet environment
Date Tue, 13 Jul 2004 07:07:14 GMT
Right, I see. Thanx for that!

You say "stick the files in the 'classes' directory, or in ...". When 
you say files do u mean just the templates?
Remember that this is a standalone application, packed in a jar, that 
makes use of the velocity engine to generate templates.
All I want is to take that functionality and use it within a servlet.

Do u think its a better idea to specify a JarResourceLoader in the 
properties of the servlet with the full path to the jar of the 
standalone app?

Will Glass-Husain wrote:

>The lib directory is not in the class path.  Each of the individual jars
>are, but not the directory itself.  This is different than the "classes"
>directory.
>
>Bottom line: stick the files in the "classes" directory, or stick them in a
>directory with an arbitrary name (e.g. templates) and use the
>FileResourceLoader.
>
>Just to clarify the classpath issue, here's the quote from the Java servlet
>spec.  Note that it does not say the class loader should load from the
>lib directory, just from the jar files in the lib directory.
>
>*****
>The contents of the WEB-INF directory are:
>
>. The /WEB-INF/web.xml deployment descriptor.
>. The /WEB-INF/classes/ directory for servlet and utility classes. The
>classes
>in this directory must be available to the application class loader.
>. The /WEB-INF/lib/*.jar area for Java ARchive files. These files contain
>servlets, beans, and other utility classes useful to the web application.
>
>The web application class loader must be able to load classes from any of
>these
>archive files.
>
>The web application classloader must load classes from the WEB-INF/ classes
>directory first, and then from library JARs in the WEB-INF/lib directory.
>
>
>
>
>----- Original Message ----- 
>From: "Markos Charatzas" <xarm@forthnet.gr>
>To: "Velocity Users List" <velocity-user@jakarta.apache.org>
>Sent: Monday, July 12, 2004 11:25 PM
>Subject: Re: Using a standalone app in a servlet environment
>
>
>  
>
>>Hey, thanx for the prompt response.
>>
>>I think I see what you mean and I will give it a shot, but considering
>>that /WEB-INF/lib *is* in the class path (since all libraries for the
>>web app reside there) why is there a problem?
>>
>>Also i think you wanted to say .getRealPath("/WEB-INF/lib") right?
>>
>>Markos
>>
>>Will Glass-Husain wrote:
>>
>>    
>>
>>>Hi,
>>>
>>>I suspect that "lib" is not actually in the class path.  (jar file in lib
>>>are, but not lib itself).
>>>
>>>I've had better luck with the the File resource loader.  If you
>>>      
>>>
>initialize
>  
>
>>>the properties in code you can set this to be within your web app
>>>automatically.
>>>
>>>Quoting Mike Curwen of a couple weeks ago:
>>>
>>>p.setProperty("file.resource.loader.path",
>>>app.getRealPath("/WEB-INF/templates"));
>>>
>>>WILL
>>>
>>>----- Original Message ----- 
>>>From: "Markos Charatzas" <xarm@forthnet.gr>
>>>To: "Velocity Users List" <velocity-user@jakarta.apache.org>
>>>Sent: Monday, July 12, 2004 5:46 AM
>>>Subject: Using a standalone app in a servlet environment
>>>
>>>
>>>
>>>
>>>      
>>>
>>>>Hi there,
>>>>
>>>>I'm into the following despair.
>>>>
>>>>I have a standalone application with the following directory structure
>>>>
>>>>/classes
>>>>/resources/templates/
>>>>
>>>>
>>>>a velocity.properties file resides in the /resources directory with the
>>>>following:
>>>>
>>>>resource.loader = OpenseasService
>>>>
>>>>OpenseasService.loader.description = "Openseas Service Resource Loader"
>>>>OpenseasService.resource.loader.class =
>>>>org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
>>>>
>>>>
>>>>a simple class that has a template attached to it is using the path
>>>>"/resources/templates/test.vm" for example
>>>>
>>>>I pack the application into a jar file retaining the directory structure
>>>>mentioned above (of course classes dir is removed)
>>>>and deploy it in the WEB-INF\lib of a webapp.
>>>>
>>>>However the resource loader is unable to locate the template in
>>>>"/resources/templates/test.vm" within that jar.
>>>>I assume that's since the ClasspathLoader is different since Tomcat is
>>>>the container now.
>>>>
>>>>Is there a workaround in this? :(
>>>>
>>>>Thx in advance,
>>>>Markos Charatzas
>>>>
>>>>---------------------------------------------------------------------
>>>>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
>
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message