Ok, after spending a couple more hours playing around with this, here's what I've found:

I can use the FileResourceLoader or the WebappLoader and they both appear to work fine.
I can get either web-app running with either loader just fine.
I can even configure the web-apps with different loaders and they work fine as long as the other isn't loaded. When i turn on both web-apps, the second loader is totally ignored. Even if they are different (webapploader vs fileloader). The only thing in the logs to indicate Velocity recognizes something fishy is going on is:

007-01-12 17:32:28,484 - Introspector : detected classloader change. Dumping cache.

The log file clearly shows the FileResourceLoader starting up, but there is no log of the WebappLoader starting (setup on the other servlet).

I really thought I had this thing licked when i used a different loader for each web-app, but no dice. :(

foo1 config:
runtime.log.logsystem.class = org.apache.velocity.runtime.log.SimpleLog4JLogSystem
 resource.loader = file
file.resource.loader.class = org.apache.velocity.runtime.resource.loader.FileResourceLoader
  file.resource.loader.path = C:\\sites\\foo2\\web
  file.resource.loader.cache = true
  file.resource.loader.modificationCheckInterval = 2
   runtime.log.invalid.reference = true
runtime.log.error.stacktrace = true
runtime.log.warn.stacktrace = true
runtime.log.info.stacktrace = true

foo2 config:

runtime.log.logsystem.class = org.apache.velocity.runtime.log.SimpleLog4JLogSystem
 resource.loader = webapp
webapp.resource.loader.class = org.apache.velocity.tools.view.servlet.WebappLoader
 webapp.resource.loader.path = web/templates/, web/, /
 webapp.resource.loader.cache = true
 webapp.resource.loader.modificationCheckInterval = 2
   runtime.log.invalid.reference = true
runtime.log.error.stacktrace = true
runtime.log.warn.stacktrace = true
runtime.log.info.stacktrace = true

Here's the log that I get:

2007-01-12 17:53:20,718 - **************************************************************
2007-01-12 17:53:20,718 - Starting Jakarta Velocity v1.4
2007-01-12 17:53:20,718 - RuntimeInstance initializing.
2007-01-12 17:53:20,718 - Default Properties File: org\apache\velocity\runtime\defaults\velocity.properties 2007-01-12 17:53:20,718 - Trying to use logger class org.apache.velocity.runtime.log.SimpleLog4JLogSystem 2007-01-12 17:53:20,718 - Using logger class org.apache.velocity.runtime.log.SimpleLog4JLogSystem 2007-01-12 17:53:20,718 - Default ResourceManager initializing. (class org.apache.velocity.runtime.resource.ResourceManagerImpl) 2007-01-12 17:53:20,718 - Resource Loader Instantiated: org.apache.velocity.runtime.resource.loader.FileResourceLoader
2007-01-12 17:53:20,718 - FileResourceLoader : initialization starting.
2007-01-12 17:53:20,718 - FileResourceLoader : adding path 'C:\\sites\\foo1\\web'
2007-01-12 17:53:20,718 - FileResourceLoader : initialization complete.
2007-01-12 17:53:20,718 - ResourceCache : initialized. (class org.apache.velocity.runtime.resource.ResourceCacheImpl)
2007-01-12 17:53:20,718 - Default ResourceManager initialization complete.
2007-01-12 17:53:20,718 - Loaded System Directive: org.apache.velocity.runtime.directive.Literal 2007-01-12 17:53:20,734 - Loaded System Directive: org.apache.velocity.runtime.directive.Macro 2007-01-12 17:53:20,734 - Loaded System Directive: org.apache.velocity.runtime.directive.Parse 2007-01-12 17:53:20,734 - Loaded System Directive: org.apache.velocity.runtime.directive.Include 2007-01-12 17:53:20,734 - Loaded System Directive: org.apache.velocity.runtime.directive.Foreach
2007-01-12 17:53:20,937 - Created: 20 parsers.
2007-01-12 17:31:45,921 - Velocimacro : initialization starting.
2007-01-12 17:31:59,187 - VelocityViewServlet: Default content-type is: text/html 2007-01-12 17:32:11,062 - ResourceManager : found /templates/index.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader 2007-01-12 17:32:11,062 - ResourceManager : found templates/includes/head.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader 2007-01-12 17:32:11,062 - ResourceManager : found templates/includes/header.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader 2007-01-12 17:32:11,062 - ResourceManager : found templates/includes/footer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader 2007-01-12 17:32:11,078 - ResourceManager : found templates/includes/left_nav.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader 2007-01-12 17:32:28,484 - Introspector : detected classloader change. Dumping cache. ==> here is where i hit reload on the other webapp, but the config doesn't run again.

Nathan Bubna wrote:
Ok, here's a few questions:

Is there any particular reason that you are using the
FileResourceLoader?  Have you tried getting this to work with the
WebappLoader that the VVS uses by default?

Can you show us some log output for both apps?

On 1/12/07, Ryan Clifton <[EMAIL PROTECTED]> wrote:

Well, I had thought this would be an easy problem to fix, but it turns out that I am using the VelocityViewServlet. I also followed the directions for
configuring the resource loader within each web-app through
velocity.properties. The file definitely works for the first app loaded (I can make the path invalid and the whole thing breaks), but the second app in
my  servlet container config does not load it's path correctly.  So both
sites run off the same set of templates from the foo1 site.

 Again, if i remove foo1 from the container, foo2 works perfectly.

 Any ideas?
 Thanks everyone.

 (velocity.properties : foo1)
  resource.loader = file
   file.resource.loader.class =
org.apache.velocity.runtime.resource.loader.FileResourceLoader
   file.resource.loader.path = C:\\sites\\foo1\\web
   file.resource.loader.cache = true
   file.resource.loader.modificationCheckInterval = 2

 (velocity.properties : foo2)
  resource.loader = file
   file.resource.loader.class =
org.apache.velocity.runtime.resource.loader.FileResourceLoader
   file.resource.loader.path = C:\\sites\\foo2\\web
   file.resource.loader.cache = true
   file.resource.loader.modificationCheckInterval = 2

 Both web.xml files are essentially the same.

 (from web.xml)
   <servlet>
       <servlet-name>action</servlet-name>

<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>

       <init-param>
          <param-name>application</param-name>
          <param-value>resources.application</param-value>
       </init-param>

       <init-param>
          <param-name>config</param-name>
          <param-value>/WEB-INF/struts-config.xml</param-value>
       </init-param>

       <init-param>
          <param-name>debug</param-name>
          <param-value>2</param-value>
       </init-param>

       <init-param>
          <param-name>detail</param-name>
          <param-value>2</param-value>
       </init-param>

       <init-param>
          <param-name>validate</param-name>
          <param-value>true</param-value>
       </init-param>

       <load-on-startup>1</load-on-startup>
    </servlet>

 <!-- Define Velocity template compiler -->
 <servlet>
   <servlet-name>velocity</servlet-name>

<servlet-class>org.apache.velocity.tools.view.servlet.VelocityViewServlet</servlet-class>

   <init-param>
     <param-name>org.apache.velocity.toolbox</param-name>
     <param-value>/WEB-INF/toolbox.xml</param-value>
  </init-param>

   <init-param>
     <param-name>org.apache.velocity.properties</param-name>

<param-value>/WEB-INF/classes/resources/velocity.properties</param-value>
  </init-param>

  <load-on-startup>10</load-on-startup>
 </servlet>


 Claude Brisson wrote:
 Hi.

What kind of servlet are you using?

If you use servlets of your own, just be sure to use different
VelocityEngine objects, they should be totally independant.

If you use the VelocityServlet class, then drop it and use the
VelocityViewServlet of the Tools subproject.

If you already use the VelocityViewServlet, then this is quite weird...


 Claude

Le vendredi 12 janvier 2007 à 12:35 -0800, Ryan Clifton a écrit :


 Hello,

I am trying to run multiple web-apps under a single JVM that are
concurrently running their own velocity engines. When I start
everything up, the web-apps appear to use the template directory from
the first web-app that is loaded into the JVM.

IE. if i have www.foo1.com and www.foo2.com and foo1 is loaded first,
foo2 will only get templates from foo1.

So it seems that Velocity statically loads the templates folder across
the whole JVM. Is there any way around this other than running multple
JVMs on different ports?

thanks.

Ryan

---------------------------------------------------------------------
To unsubscribe, e-mail:
[EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail:
[EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail:
[EMAIL PROTECTED] For additional
commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
Ryan Clifton
CTO, CoutureCandy.com
805-377-4585


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to