You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Tim Colson <tc...@cisco.com> on 2002/05/03 01:56:33 UTC

[Veltools] WebappLoader not loading

Say folks - 

  I have the velstruts demo running just fine. I then managed to pull
the necessary bits from the demo into an existing app and get that
running. Next I extended VelocityViewServlet into a version that does a
two-pass render (aka LayoutVelocityViewServlet) and that ran (source
copied at the bottom).

But now I can't seem to get veltools working in another app. What's
worse, the original veltools app won't run either. Aaaaack. (I honestly
don't know what I changed that caused the working app to go bad, I have
tried to step back, but without success.)

The only thing I can find that looks wrong is that the WebappLoader is
not initializing in my app.

I'm using Tomcat 3.2.1 supplemented with JAXP1.1, crimson.jar -- started
up from inside my IDE (tomcat startup shown directly below).

I also included the error I get when the view attempts to render my *.vm
file, and a snippet from the WORKING velstruts demo app log.

Helpful suggestions are appreciated. ;-)

Cheers,
Tim
-----------------

Tomcat Startup:
D:\java\jdk1.3.1_02\bin\javaw.exe 
-classpath "D:\java\jdk1.3.1_02\jre\lib\rt.jar;
D:\java\jdk1.3.1_02\lib\tools.jar;
<APP_ROOT>\WEB-INF\classes;
<APP_ROOT>\WEB-INF\properties;
<APP_ROOT>\WEB-INF\lib\velocity-dep-1.3-dev.jar;
<APP_ROOT>\WEB-INF\lib\commons-beanutils.jar;
<APP_ROOT>\WEB-INF\lib\commons-collections.jar;
<APP_ROOT>\WEB-INF\lib\commons-digester.jar;
<APP_ROOT>\WEB-INF\lib\dom4j.jar;
<APP_ROOT>\WEB-INF\lib\velocity-tools-library-0.1.jar;
<APP_ROOT>\WEB-INF\lib\velocity-tools-struts-0.7.jar;
<APP_ROOT>\WEB-INF\lib\velocity-tools-view-0.6.jar;
<APP_ROOT>\WEB-INF\lib\veltag-0.01-dev.jar;
<APP_ROOT>\WEB-INF\lib\jakarta-regexp-1.2.jar;
<APP_ROOT>\WEB-INF\lib\jakarta-oro-2.0.5.jar;
<APP_ROOT>\WEB-INF\lib\jivefw.jar;
<APP_ROOT>\WEB-INF\lib\log4j.jar;
<APP_ROOT>\WEB-INF\lib\struts.jar;
<APP_ROOT>\WEB-INF\lib\Struts_Validator-20010702.jar;
D:\java\lib\junit.jar;
D:\java\lib\activation.jar;
D:\java\lib\mail.jar;
D:\java\jakarta-tomcat-3.2.1\lib\servlet.jar;
D:\Java\jakarta-tomcat-3.2.1\lib\webserver.jar;
D:\Java\jakarta-tomcat-3.2.1\lib\jaxp.jar;
D:\Java\jakarta-tomcat-3.2.1\lib\jasper.jar;
D:\java\jakarta-tomcat-3.2.1\lib\crimson.jar;
C:\Oracle\Ora81\jdbc\lib\classes12.zip" 
org.apache.tomcat.startup.Tomcat 
-config <APP_ROOT>\conf\server.xml



VELSTRUTS DEMO - WORKING
2002-05-02 02:34:00 - path="/velstruts" : Velocity   [info]
************************************************************** 
2002-05-02 02:34:00 - path="/velstruts" : Velocity   [info] Starting
Jakarta Velocity v1.3-dev
2002-05-02 02:34:00 - path="/velstruts" : Velocity   [info]
RuntimeInstance initializing.
2002-05-02 02:34:00 - path="/velstruts" : Velocity   [info] Default
Properties File:
org\apache\velocity\runtime\defaults\velocity.properties
2002-05-02 02:34:00 - path="/velstruts" : Velocity   [info] Default
ResourceManager initializing. (class
org.apache.velocity.runtime.resource.ResourceManagerImpl)
2002-05-02 02:34:00 - path="/velstruts" : Velocity   [info] Resource
Loader Instantiated: org.apache.velocity.tools.view.servlet.WebappLoader
2002-05-02 02:34:00 - path="/velstruts" : Velocity   [info] WebappLoader
: initialization starting.
2002-05-02 02:34:00 - path="/velstruts" : Velocity   [info] WebappLoader
: initialization complete.
2002-05-02 02:34:00 - path="/velstruts" : Velocity   [info]
ResourceCache : initialized. (class
org.apache.velocity.runtime.resource.ResourceCacheImpl)
2002-05-02 02:34:00 - path="/velstruts" : Velocity   [info] Default
ResourceManager initialization complete.
2002-05-02 02:34:00 - path="/velstruts" : Velocity   [info] Loaded
System Directive: org.apache.velocity.runtime.directive.Literal
2002-05-02 02:34:00 - path="/velstruts" : Velocity   [info] Loaded
System Directive: org.apache.velocity.runtime.directive.Macro
2002-05-02 02:34:00 - path="/velstruts" : Velocity   [info] Loaded
System Directive: org.apache.velocity.runtime.directive.Parse
2002-05-02 02:34:00 - path="/velstruts" : Velocity   [info] Loaded
System Directive: org.apache.velocity.runtime.directive.Include
2002-05-02 02:34:00 - path="/velstruts" : Velocity   [info] Loaded
System Directive: org.apache.velocity.runtime.directive.Foreach
2002-05-02 02:34:01 - path="/velstruts" : Velocity   [info] Created: 20
parsers.
2002-05-02 02:34:01 - path="/velstruts" : Velocity   [info] Velocimacro
: initialization starting.
2002-05-02 02:34:01 - path="/velstruts" : Velocity   [info] Velocimacro
: adding VMs from VM library template : /WEB-INF/VM_global_library.vm
2002-05-02 02:34:01 - path="/velstruts" : Velocity   [info] Velocimacro
: added new VM : #errorMarkup( ) : source =
/WEB-INF/VM_global_library.vm
2002-05-02 02:34:01 - path="/velstruts" : Velocity   [info] Velocimacro
: added new VM : #errorMarkupForProperty( property ) : source =
/WEB-INF/VM_global_library.vm
2002-05-02 02:34:01 - path="/velstruts" : Velocity   [info]
ResourceManager : found /WEB-INF/VM_global_library.vm with loader
org.apache.velocity.tools.view.servlet.WebappLoader
2002-05-02 02:34:01 - path="/velstruts" : Velocity   [info] Velocimacro
:  VM library template macro registration complete.
2002-05-02 02:34:01 - path="/velstruts" : Velocity   [info] Velocimacro
: allowInline = true : VMs can be defined inline in templates
2002-05-02 02:34:01 - path="/velstruts" : Velocity   [info] Velocimacro
: allowInlineToOverride = false : VMs defined inline may NOT replace
previous VM definitions
2002-05-02 02:34:01 - path="/velstruts" : Velocity   [info] Velocimacro
: allowInlineLocal = false : VMs defined inline will be  global in scope
if allowed.
2002-05-02 02:34:01 - path="/velstruts" : Velocity   [info] Velocimacro
: messages on  : VM system will output logging messages
2002-05-02 02:34:01 - path="/velstruts" : Velocity   [info] Velocimacro
: autoload off  : VM system will not automatically reload global library
macros
2002-05-02 02:34:01 - path="/velstruts" : Velocity   [info] Velocimacro
: initialization complete.
2002-05-02 02:34:01 - path="/velstruts" : Velocity   [info] Velocity
successfully started.
2002-05-02 02:34:01 - path="/velstruts" : Velocity   [info] Using
toolbox configuration file '/WEB-INF/toolbox.xml'
2002-05-02 02:34:01 - path="/velstruts" :ServletToolboxManager:
Initializing the toolbox...
2002-05-02 02:34:02 - path="/velstruts" :ServletToolboxManager: Loading
tool
2002-05-02 02:34:02 - path="/velstruts" :ServletToolboxManager:
Context key: toolLoader
2002-05-02 02:34:02 - path="/velstruts" :ServletToolboxManager:   Class:
org.apache.velocity.tools.tools.ToolLoader
2002-05-02 02:34:02 - path="/velstruts" :ServletToolboxManager:   Life
cycle: 
2002-05-02 02:34:02 - path="/velstruts" :ServletToolboxManager:   Known
interface: LogEnabledViewTool
----

Resource not found Error when trying to process the action forward.

VelocityServlet : Error processing the template
org.apache.velocity.exception.ResourceNotFoundException: Unable to find
resource
'/vm/SearchResults.vm'org.apache.velocity.exception.ResourceNotFoundExce
ption: Unable to find resource '/vm/SearchResults.vm'
	at
org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(Re
sourceManagerImpl.java:502)
	at
org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(Res
ourceManagerImpl.java:386)
	at
org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.
java:812)
	at
org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.
java:794)
	at
org.apache.velocity.runtime.RuntimeSingleton.getTemplate(RuntimeSingleto
n.java:337)
	at
org.apache.velocity.servlet.VelocityServlet.getTemplate(VelocityServlet.
java:524)
	at
org.apache.velocity.tools.view.servlet.VelocityViewServlet.handleRequest
(VelocityViewServlet.java:272)
	at
org.apache.velocity.servlet.VelocityServlet.doRequest(VelocityServlet.ja
va:356)
	at
org.apache.velocity.servlet.VelocityServlet.doPost(VelocityServlet.java:
326)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
	at org.apache.tomcat.core.Handler.service(Handler.java:286)
	at
org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
	at
org.apache.tomcat.facade.RequestDispatcherImpl.forward(RequestDispatcher
Impl.java:194)
	at
org.apache.struts.action.ActionServlet.processActionForward(ActionServle
t.java:1758)
	at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1595)
	at
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:491)
	at
com.cisco.hrit.core.servlet.ServletBase.doGet(ServletBase.java:78)
	at
com.cisco.hrit.core.servlet.ServletBase.doPost(ServletBase.java:70)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
	at
com.cisco.hrit.core.servlet.ServletBase.service(ServletBase.java:177)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
	at org.apache.tomcat.core.Handler.service(Handler.java:286)
	at
org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
	at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.jav
a:797)
	at
org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
	at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(H
ttpConnectionHandler.java:210)
	at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416
)
	at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:49
8)

---

velocity.log file contents... notice that WebappLoader isn't present.

Thu May 02 15:23:34 PDT 2002  [debug] AvalonLogSystem initialized using
logfile 'velocity.log'
Thu May 02 15:23:34 PDT 2002   [info]
************************************************************** 
Thu May 02 15:23:34 PDT 2002   [info] Starting Jakarta Velocity v1.3-dev
Thu May 02 15:23:34 PDT 2002   [info] RuntimeInstance initializing.
Thu May 02 15:23:34 PDT 2002   [info] Default Properties File:
org\apache\velocity\runtime\defaults\velocity.properties
Thu May 02 15:23:34 PDT 2002   [info] Trying to use logger class
org.apache.velocity.runtime.log.AvalonLogSystem
Thu May 02 15:23:34 PDT 2002   [info] Using logger class
org.apache.velocity.runtime.log.AvalonLogSystem
Thu May 02 15:23:34 PDT 2002   [info] Default ResourceManager
initializing. (class
org.apache.velocity.runtime.resource.ResourceManagerImpl)
Thu May 02 15:23:34 PDT 2002   [info] Resource Loader Instantiated:
org.apache.velocity.runtime.resource.loader.FileResourceLoader
Thu May 02 15:23:34 PDT 2002   [info] FileResourceLoader :
initialization starting.
Thu May 02 15:23:34 PDT 2002   [info] FileResourceLoader : adding path
'.'
Thu May 02 15:23:34 PDT 2002   [info] FileResourceLoader :
initialization complete.
Thu May 02 15:23:34 PDT 2002   [info] ResourceCache : initialized.
(class org.apache.velocity.runtime.resource.ResourceCacheImpl)
Thu May 02 15:23:34 PDT 2002   [info] Default ResourceManager
initialization complete.
Thu May 02 15:23:34 PDT 2002   [info] Loaded System Directive:
org.apache.velocity.runtime.directive.Literal
Thu May 02 15:23:34 PDT 2002   [info] Loaded System Directive:
org.apache.velocity.runtime.directive.Macro
Thu May 02 15:23:34 PDT 2002   [info] Loaded System Directive:
org.apache.velocity.runtime.directive.Parse
Thu May 02 15:23:34 PDT 2002   [info] Loaded System Directive:
org.apache.velocity.runtime.directive.Include
Thu May 02 15:23:34 PDT 2002   [info] Loaded System Directive:
org.apache.velocity.runtime.directive.Foreach
Thu May 02 15:23:34 PDT 2002   [info] Created: 20 parsers.
Thu May 02 15:23:34 PDT 2002   [info] Velocimacro : initialization
starting.
Thu May 02 15:23:34 PDT 2002   [info] Velocimacro : adding VMs from VM
library template : VM_global_library.vm
Thu May 02 15:23:34 PDT 2002  [error] ResourceManager : unable to find
resource 'VM_global_library.vm' in any resource loader.
Thu May 02 15:23:34 PDT 2002   [info] Velocimacro : error using  VM
library template VM_global_library.vm :
org.apache.velocity.exception.ResourceNotFoundException: Unable to find
resource 'VM_global_library.vm'
Thu May 02 15:23:34 PDT 2002   [info] Velocimacro :  VM library template
macro registration complete.
Thu May 02 15:23:34 PDT 2002   [info] Velocimacro : allowInline = true :
VMs can be defined inline in templates
Thu May 02 15:23:34 PDT 2002   [info] Velocimacro :
allowInlineToOverride = false : VMs defined inline may NOT replace
previous VM definitions
Thu May 02 15:23:34 PDT 2002   [info] Velocimacro : allowInlineLocal =
false : VMs defined inline will be  global in scope if allowed.
Thu May 02 15:23:34 PDT 2002   [info] Velocimacro : messages on  : VM
system will output logging messages
Thu May 02 15:23:34 PDT 2002   [info] Velocimacro : autoload off  : VM
system will not automatically reload global library macros
Thu May 02 15:23:34 PDT 2002   [info] Velocimacro : initialization
complete.
Thu May 02 15:23:34 PDT 2002   [info] Velocity successfully started.
Thu May 02 15:23:34 PDT 2002   [info] Using toolbox configuration file
'/WEB-INF/toolbox.xml'
Thu May 02 15:23:34 PDT 2002   [info] Toolbox setup complete.

---
// LayoutVelocityViewServlet 

package com.cisco.hrit;

import org.apache.velocity.Template;
import org.apache.velocity.context.Context;
import org.apache.velocity.exception.MethodInvocationException;
import org.apache.velocity.exception.ParseErrorException;
import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.tools.view.servlet.VelocityViewServlet;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;

public class LayoutVelocityViewServlet extends VelocityViewServlet {

    protected void mergeTemplate (Template template, Context context,
HttpServletResponse response)
            throws ResourceNotFoundException, ParseErrorException,
            MethodInvocationException, IOException,
UnsupportedEncodingException, Exception {

        // Check for a layout
        String layoutFile = (String) context.get("LAYOUT");

        if (layoutFile != null) {
            // Load up the layout template
            Template layoutTemplate = null;

            try {
                layoutTemplate = getTemplate(layoutFile);
            } catch (ResourceNotFoundException rnfe) {
                // couldn't find the template
                System.out.println("rnfe = " + rnfe);
            } catch (ParseErrorException pee) {
                // syntax error : problem parsing the template
                System.out.println("pee = " + pee);
            } catch (MethodInvocationException mie) {
                // something invoked in the template threw an exception
                System.out.println("mie = " + mie);
            } catch (Exception e) {
                System.out.println("e = " + e);
            }

            // Render the first pass, i.e. body content
            StringWriter sw = new StringWriter();
            template.merge(context, sw);
            // Add the resulting content to the context
            context.put("CONTENT", sw.toString());
            // Render the second pass, i.e. layout
            super.mergeTemplate(layoutTemplate, context, response);
        } else {
            // no layout specified, so just send the template specified
directly to the user.
            super.mergeTemplate(template, context, response);
        }

    }
}


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


Re: [Veltools] WebappLoader not loading

Posted by "Geir Magnusson Jr." <ge...@adeptra.com>.
On 5/3/02 10:26 AM, "Tim Colson" <tc...@cisco.com> wrote:

> Gabe -
> 
> [Gabriel wrote]
>> Your mail contains the output of velocity.log. Actually our
>> VelocityViewServlet implementation does not produce any
>> velocity.log. Instead the log output is redirected to the log
>> of the servlet container.
> 
> I guarantee, it does produce the "velocity.log" file. This is running in
> tomcat, but note that it is started up slightly differently than a
> standalone server. It is run as a cmd line app, with a specific
> classpath, and a specific server.xml config that sets the context path
> to the project 'content' directory.
> 
> Incidentally(?) I've also noticed that sometimes AvalonKit is used, and
> sometimes log4j. Log4J is always in the classpath, so I can only guess
> that this is because of trying different versions of the VelocityXXX.jar
> w/ and w/o dependancies.

Yes - that makes sense.

> 
> And I've also noticed that while the init mesg. are sent to
> velocity.log, the toolbox startup mesgs. appear to be going to stdout.
> 

This is strange.  (Not the stdout - that might be just interim lazyness...)

If the config is right, then it should be going to servlet log.  It uses the
ServletLogger (or whatever) and I know that works very well.  I use it a
lot.

Can you send us the velocity.log to show us what is going on?

> 
>> Now, this leads me to the
>> conclusion that you modified/overwrote method initVelocity()
>> of VelocityViewServlet.
> Nope. The full text of the LayoutVelocityViewServlet was included - I
> only overrode mergeTemplate(). That's all, truly.
> 
>> That is not a problem per se, but in
>> that same method is the code to load the WebAppLoader. Please
>> verify that this code is still there.
> The code is still there. But I also stepped back and tried using just
> the VelocityViewServlet and still had the same problem with webappLoader
> not initializing.
> 
>> If the WebAppLoader is successfully loaded, it produces the
>> following log output:
> Yeah...I've been trying to figure out what magic it takes to get that
> back. The weird thing is that I did have it running, but I've tried
> quite a few combinations without success.
> 
> I've tried using the jars from the velstruts/WEB-INF/lib as well as
> nightly builds from both velocity and velocity-tools. I noticed that the
> velocity-1.3XX.jar is different between the two.

-- 
Geir Magnusson Jr.
Research & Development, Adeptra Inc.
geirm@adeptra.com
+1-203-247-1713



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


Re: [Veltools] WebappLoader not loading

Posted by "Geir Magnusson Jr." <ge...@adeptra.com>.
On 5/6/02 2:40 PM, "Tim Colson" <tc...@cisco.com> wrote:

> Aside - reading/deleting/gritting-my-teeth over 180 posts from the last
> 48 hours proved only that some people can be such choads, and despite
> being a fan of free uncensored speech, I wonder if this list can
> automagically filter out any post with a short-list of 4 letter words?

Like 'XSLT'? 

:)

> 
> Anyway - on to the thread I started :-) It's mostly just an FYI trail in
> case others find themselves with the same odd situation.
> 
>> I now have the 'old' version of my app running again
>> using Veltools and webappLoader, so I'll start going piece by
>> piece to see what's different between this app and the one
>> that isn't loading correctly.
> 
> I pulled my hair out on this one for quite a while, and finally decided
> to change web.xml to load the Velocity servlet FIRST, before our custom
> extended Struts servlet. That did the trick -- the log WebappLoader
> loads, logging happens, but 'velocity.log' file is NOT created.

I can't understand why that would make a difference....
 
> I'm not sure of the real culprit, but I'll reply again if I do find it.
> 
> Cheers,
> Tim
> Oh, and I still like '&' for concat <grin>

:P

-- 
Geir Magnusson Jr.
Research & Development, Adeptra Inc.
geirm@adeptra.com
+1-203-247-1713



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


RE: [Veltools] WebappLoader not loading

Posted by Tim Colson <tc...@cisco.com>.
Aside - reading/deleting/gritting-my-teeth over 180 posts from the last
48 hours proved only that some people can be such choads, and despite
being a fan of free uncensored speech, I wonder if this list can
automagically filter out any post with a short-list of 4 letter words?

Anyway - on to the thread I started :-) It's mostly just an FYI trail in
case others find themselves with the same odd situation.

> I now have the 'old' version of my app running again 
> using Veltools and webappLoader, so I'll start going piece by 
> piece to see what's different between this app and the one 
> that isn't loading correctly.

I pulled my hair out on this one for quite a while, and finally decided
to change web.xml to load the Velocity servlet FIRST, before our custom
extended Struts servlet. That did the trick -- the log WebappLoader
loads, logging happens, but 'velocity.log' file is NOT created.

I'm not sure of the real culprit, but I'll reply again if I do find it. 

Cheers,
Tim
Oh, and I still like '&' for concat <grin>


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


RE: [Veltools] WebappLoader not loading

Posted by Tim Colson <tc...@cisco.com>.
FYI - I now have the 'old' version of my app running again using
Veltools and webappLoader, so I'll start going piece by piece to see
what's different between this app and the one that isn't loading
correctly.

Tim


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


RE: [Veltools] WebappLoader not loading

Posted by Tim Colson <tc...@cisco.com>.
Gabe -

[Gabriel wrote]
> Your mail contains the output of velocity.log. Actually our 
> VelocityViewServlet implementation does not produce any 
> velocity.log. Instead the log output is redirected to the log 
> of the servlet container. 

I guarantee, it does produce the "velocity.log" file. This is running in
tomcat, but note that it is started up slightly differently than a
standalone server. It is run as a cmd line app, with a specific
classpath, and a specific server.xml config that sets the context path
to the project 'content' directory.

Incidentally(?) I've also noticed that sometimes AvalonKit is used, and
sometimes log4j. Log4J is always in the classpath, so I can only guess
that this is because of trying different versions of the VelocityXXX.jar
w/ and w/o dependancies.

And I've also noticed that while the init mesg. are sent to
velocity.log, the toolbox startup mesgs. appear to be going to stdout.


> Now, this leads me to the 
> conclusion that you modified/overwrote method initVelocity() 
> of VelocityViewServlet. 
Nope. The full text of the LayoutVelocityViewServlet was included - I
only overrode mergeTemplate(). That's all, truly.

> That is not a problem per se, but in 
> that same method is the code to load the WebAppLoader. Please 
> verify that this code is still there.
The code is still there. But I also stepped back and tried using just
the VelocityViewServlet and still had the same problem with webappLoader
not initializing.

> If the WebAppLoader is successfully loaded, it produces the 
> following log output:
Yeah...I've been trying to figure out what magic it takes to get that
back. The weird thing is that I did have it running, but I've tried
quite a few combinations without success.

I've tried using the jars from the velstruts/WEB-INF/lib as well as
nightly builds from both velocity and velocity-tools. I noticed that the
velocity-1.3XX.jar is different between the two.

Cheers,
Tim




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


Re: [Veltools] WebappLoader not loading

Posted by Gabriel Sidler <si...@teamup.ch>.
Tim,
here a few guesses:

Your mail contains the output of velocity.log. Actually our VelocityViewServlet
implementation does not produce any velocity.log. Instead the log output
is redirected to the log of the servlet container. Now, this leads me to
the conclusion that you modified/overwrote method initVelocity() of
VelocityViewServlet. That is not a problem per se, but in that same method
is the code to load the WebAppLoader. Please verify that this code is still
there.

If the WebAppLoader is successfully loaded, it produces the following
log output:

[2002/04/04 14:57:47]  Velocity   [info] Resource Loader Instantiated: org.apache.velocity.tools.view.servlet.WebappLoader
[2002/04/04 14:57:47]  Velocity   [info] WebappLoader : initialization starting.
[2002/04/04 14:57:47]  Velocity   [info] WebappLoader : initialization complete.


Gabe



Tim Colson wrote:

> Say folks - 
> 
>   I have the velstruts demo running just fine. I then managed to pull
> the necessary bits from the demo into an existing app and get that
> running. Next I extended VelocityViewServlet into a version that does a
> two-pass render (aka LayoutVelocityViewServlet) and that ran (source
> copied at the bottom).
> 
> But now I can't seem to get veltools working in another app. What's
> worse, the original veltools app won't run either. Aaaaack. (I honestly
> don't know what I changed that caused the working app to go bad, I have
> tried to step back, but without success.)
> 
> The only thing I can find that looks wrong is that the WebappLoader is
> not initializing in my app.
> 
> I'm using Tomcat 3.2.1 supplemented with JAXP1.1, crimson.jar -- started
> up from inside my IDE (tomcat startup shown directly below).
> 
> I also included the error I get when the view attempts to render my *.vm
> file, and a snippet from the WORKING velstruts demo app log.
> 
> Helpful suggestions are appreciated. ;-)
> 
> Cheers,
> Tim
> -----------------
> 
> Tomcat Startup:
> D:\java\jdk1.3.1_02\bin\javaw.exe 
> -classpath "D:\java\jdk1.3.1_02\jre\lib\rt.jar;
> D:\java\jdk1.3.1_02\lib\tools.jar;
> <APP_ROOT>\WEB-INF\classes;
> <APP_ROOT>\WEB-INF\properties;
> <APP_ROOT>\WEB-INF\lib\velocity-dep-1.3-dev.jar;
> <APP_ROOT>\WEB-INF\lib\commons-beanutils.jar;
> <APP_ROOT>\WEB-INF\lib\commons-collections.jar;
> <APP_ROOT>\WEB-INF\lib\commons-digester.jar;
> <APP_ROOT>\WEB-INF\lib\dom4j.jar;
> <APP_ROOT>\WEB-INF\lib\velocity-tools-library-0.1.jar;
> <APP_ROOT>\WEB-INF\lib\velocity-tools-struts-0.7.jar;
> <APP_ROOT>\WEB-INF\lib\velocity-tools-view-0.6.jar;
> <APP_ROOT>\WEB-INF\lib\veltag-0.01-dev.jar;
> <APP_ROOT>\WEB-INF\lib\jakarta-regexp-1.2.jar;
> <APP_ROOT>\WEB-INF\lib\jakarta-oro-2.0.5.jar;
> <APP_ROOT>\WEB-INF\lib\jivefw.jar;
> <APP_ROOT>\WEB-INF\lib\log4j.jar;
> <APP_ROOT>\WEB-INF\lib\struts.jar;
> <APP_ROOT>\WEB-INF\lib\Struts_Validator-20010702.jar;
> D:\java\lib\junit.jar;
> D:\java\lib\activation.jar;
> D:\java\lib\mail.jar;
> D:\java\jakarta-tomcat-3.2.1\lib\servlet.jar;
> D:\Java\jakarta-tomcat-3.2.1\lib\webserver.jar;
> D:\Java\jakarta-tomcat-3.2.1\lib\jaxp.jar;
> D:\Java\jakarta-tomcat-3.2.1\lib\jasper.jar;
> D:\java\jakarta-tomcat-3.2.1\lib\crimson.jar;
> C:\Oracle\Ora81\jdbc\lib\classes12.zip" 
> org.apache.tomcat.startup.Tomcat 
> -config <APP_ROOT>\conf\server.xml
> 
> 
> 
> VELSTRUTS DEMO - WORKING
> 2002-05-02 02:34:00 - path="/velstruts" : Velocity   [info]
> ************************************************************** 
> 2002-05-02 02:34:00 - path="/velstruts" : Velocity   [info] Starting
> Jakarta Velocity v1.3-dev
> 2002-05-02 02:34:00 - path="/velstruts" : Velocity   [info]
> RuntimeInstance initializing.
> 2002-05-02 02:34:00 - path="/velstruts" : Velocity   [info] Default
> Properties File:
> org\apache\velocity\runtime\defaults\velocity.properties
> 2002-05-02 02:34:00 - path="/velstruts" : Velocity   [info] Default
> ResourceManager initializing. (class
> org.apache.velocity.runtime.resource.ResourceManagerImpl)
> 2002-05-02 02:34:00 - path="/velstruts" : Velocity   [info] Resource
> Loader Instantiated: org.apache.velocity.tools.view.servlet.WebappLoader
> 2002-05-02 02:34:00 - path="/velstruts" : Velocity   [info] WebappLoader
> : initialization starting.
> 2002-05-02 02:34:00 - path="/velstruts" : Velocity   [info] WebappLoader
> : initialization complete.
> 2002-05-02 02:34:00 - path="/velstruts" : Velocity   [info]
> ResourceCache : initialized. (class
> org.apache.velocity.runtime.resource.ResourceCacheImpl)
> 2002-05-02 02:34:00 - path="/velstruts" : Velocity   [info] Default
> ResourceManager initialization complete.
> 2002-05-02 02:34:00 - path="/velstruts" : Velocity   [info] Loaded
> System Directive: org.apache.velocity.runtime.directive.Literal
> 2002-05-02 02:34:00 - path="/velstruts" : Velocity   [info] Loaded
> System Directive: org.apache.velocity.runtime.directive.Macro
> 2002-05-02 02:34:00 - path="/velstruts" : Velocity   [info] Loaded
> System Directive: org.apache.velocity.runtime.directive.Parse
> 2002-05-02 02:34:00 - path="/velstruts" : Velocity   [info] Loaded
> System Directive: org.apache.velocity.runtime.directive.Include
> 2002-05-02 02:34:00 - path="/velstruts" : Velocity   [info] Loaded
> System Directive: org.apache.velocity.runtime.directive.Foreach
> 2002-05-02 02:34:01 - path="/velstruts" : Velocity   [info] Created: 20
> parsers.
> 2002-05-02 02:34:01 - path="/velstruts" : Velocity   [info] Velocimacro
> : initialization starting.
> 2002-05-02 02:34:01 - path="/velstruts" : Velocity   [info] Velocimacro
> : adding VMs from VM library template : /WEB-INF/VM_global_library.vm
> 2002-05-02 02:34:01 - path="/velstruts" : Velocity   [info] Velocimacro
> : added new VM : #errorMarkup( ) : source =
> /WEB-INF/VM_global_library.vm
> 2002-05-02 02:34:01 - path="/velstruts" : Velocity   [info] Velocimacro
> : added new VM : #errorMarkupForProperty( property ) : source =
> /WEB-INF/VM_global_library.vm
> 2002-05-02 02:34:01 - path="/velstruts" : Velocity   [info]
> ResourceManager : found /WEB-INF/VM_global_library.vm with loader
> org.apache.velocity.tools.view.servlet.WebappLoader
> 2002-05-02 02:34:01 - path="/velstruts" : Velocity   [info] Velocimacro
> :  VM library template macro registration complete.
> 2002-05-02 02:34:01 - path="/velstruts" : Velocity   [info] Velocimacro
> : allowInline = true : VMs can be defined inline in templates
> 2002-05-02 02:34:01 - path="/velstruts" : Velocity   [info] Velocimacro
> : allowInlineToOverride = false : VMs defined inline may NOT replace
> previous VM definitions
> 2002-05-02 02:34:01 - path="/velstruts" : Velocity   [info] Velocimacro
> : allowInlineLocal = false : VMs defined inline will be  global in scope
> if allowed.
> 2002-05-02 02:34:01 - path="/velstruts" : Velocity   [info] Velocimacro
> : messages on  : VM system will output logging messages
> 2002-05-02 02:34:01 - path="/velstruts" : Velocity   [info] Velocimacro
> : autoload off  : VM system will not automatically reload global library
> macros
> 2002-05-02 02:34:01 - path="/velstruts" : Velocity   [info] Velocimacro
> : initialization complete.
> 2002-05-02 02:34:01 - path="/velstruts" : Velocity   [info] Velocity
> successfully started.
> 2002-05-02 02:34:01 - path="/velstruts" : Velocity   [info] Using
> toolbox configuration file '/WEB-INF/toolbox.xml'
> 2002-05-02 02:34:01 - path="/velstruts" :ServletToolboxManager:
> Initializing the toolbox...
> 2002-05-02 02:34:02 - path="/velstruts" :ServletToolboxManager: Loading
> tool
> 2002-05-02 02:34:02 - path="/velstruts" :ServletToolboxManager:
> Context key: toolLoader
> 2002-05-02 02:34:02 - path="/velstruts" :ServletToolboxManager:   Class:
> org.apache.velocity.tools.tools.ToolLoader
> 2002-05-02 02:34:02 - path="/velstruts" :ServletToolboxManager:   Life
> cycle: 
> 2002-05-02 02:34:02 - path="/velstruts" :ServletToolboxManager:   Known
> interface: LogEnabledViewTool
> ----
> 
> Resource not found Error when trying to process the action forward.
> 
> VelocityServlet : Error processing the template
> org.apache.velocity.exception.ResourceNotFoundException: Unable to find
> resource
> '/vm/SearchResults.vm'org.apache.velocity.exception.ResourceNotFoundExce
> ption: Unable to find resource '/vm/SearchResults.vm'
> 	at
> org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(Re
> sourceManagerImpl.java:502)
> 	at
> org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(Res
> ourceManagerImpl.java:386)
> 	at
> org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.
> java:812)
> 	at
> org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.
> java:794)
> 	at
> org.apache.velocity.runtime.RuntimeSingleton.getTemplate(RuntimeSingleto
> n.java:337)
> 	at
> org.apache.velocity.servlet.VelocityServlet.getTemplate(VelocityServlet.
> java:524)
> 	at
> org.apache.velocity.tools.view.servlet.VelocityViewServlet.handleRequest
> (VelocityViewServlet.java:272)
> 	at
> org.apache.velocity.servlet.VelocityServlet.doRequest(VelocityServlet.ja
> va:356)
> 	at
> org.apache.velocity.servlet.VelocityServlet.doPost(VelocityServlet.java:
> 326)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> 	at
> org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
> 	at org.apache.tomcat.core.Handler.service(Handler.java:286)
> 	at
> org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
> 	at
> org.apache.tomcat.facade.RequestDispatcherImpl.forward(RequestDispatcher
> Impl.java:194)
> 	at
> org.apache.struts.action.ActionServlet.processActionForward(ActionServle
> t.java:1758)
> 	at
> org.apache.struts.action.ActionServlet.process(ActionServlet.java:1595)
> 	at
> org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:491)
> 	at
> com.cisco.hrit.core.servlet.ServletBase.doGet(ServletBase.java:78)
> 	at
> com.cisco.hrit.core.servlet.ServletBase.doPost(ServletBase.java:70)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
> 	at
> com.cisco.hrit.core.servlet.ServletBase.service(ServletBase.java:177)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> 	at
> org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
> 	at org.apache.tomcat.core.Handler.service(Handler.java:286)
> 	at
> org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
> 	at
> org.apache.tomcat.core.ContextManager.internalService(ContextManager.jav
> a:797)
> 	at
> org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
> 	at
> org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(H
> ttpConnectionHandler.java:210)
> 	at
> org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416
> )
> 	at
> org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:49
> 8)
> 
> ---
> 
> velocity.log file contents... notice that WebappLoader isn't present.
> 
> Thu May 02 15:23:34 PDT 2002  [debug] AvalonLogSystem initialized using
> logfile 'velocity.log'
> Thu May 02 15:23:34 PDT 2002   [info]
> ************************************************************** 
> Thu May 02 15:23:34 PDT 2002   [info] Starting Jakarta Velocity v1.3-dev
> Thu May 02 15:23:34 PDT 2002   [info] RuntimeInstance initializing.
> Thu May 02 15:23:34 PDT 2002   [info] Default Properties File:
> org\apache\velocity\runtime\defaults\velocity.properties
> Thu May 02 15:23:34 PDT 2002   [info] Trying to use logger class
> org.apache.velocity.runtime.log.AvalonLogSystem
> Thu May 02 15:23:34 PDT 2002   [info] Using logger class
> org.apache.velocity.runtime.log.AvalonLogSystem
> Thu May 02 15:23:34 PDT 2002   [info] Default ResourceManager
> initializing. (class
> org.apache.velocity.runtime.resource.ResourceManagerImpl)
> Thu May 02 15:23:34 PDT 2002   [info] Resource Loader Instantiated:
> org.apache.velocity.runtime.resource.loader.FileResourceLoader
> Thu May 02 15:23:34 PDT 2002   [info] FileResourceLoader :
> initialization starting.
> Thu May 02 15:23:34 PDT 2002   [info] FileResourceLoader : adding path
> '.'
> Thu May 02 15:23:34 PDT 2002   [info] FileResourceLoader :
> initialization complete.
> Thu May 02 15:23:34 PDT 2002   [info] ResourceCache : initialized.
> (class org.apache.velocity.runtime.resource.ResourceCacheImpl)
> Thu May 02 15:23:34 PDT 2002   [info] Default ResourceManager
> initialization complete.
> Thu May 02 15:23:34 PDT 2002   [info] Loaded System Directive:
> org.apache.velocity.runtime.directive.Literal
> Thu May 02 15:23:34 PDT 2002   [info] Loaded System Directive:
> org.apache.velocity.runtime.directive.Macro
> Thu May 02 15:23:34 PDT 2002   [info] Loaded System Directive:
> org.apache.velocity.runtime.directive.Parse
> Thu May 02 15:23:34 PDT 2002   [info] Loaded System Directive:
> org.apache.velocity.runtime.directive.Include
> Thu May 02 15:23:34 PDT 2002   [info] Loaded System Directive:
> org.apache.velocity.runtime.directive.Foreach
> Thu May 02 15:23:34 PDT 2002   [info] Created: 20 parsers.
> Thu May 02 15:23:34 PDT 2002   [info] Velocimacro : initialization
> starting.
> Thu May 02 15:23:34 PDT 2002   [info] Velocimacro : adding VMs from VM
> library template : VM_global_library.vm
> Thu May 02 15:23:34 PDT 2002  [error] ResourceManager : unable to find
> resource 'VM_global_library.vm' in any resource loader.
> Thu May 02 15:23:34 PDT 2002   [info] Velocimacro : error using  VM
> library template VM_global_library.vm :
> org.apache.velocity.exception.ResourceNotFoundException: Unable to find
> resource 'VM_global_library.vm'
> Thu May 02 15:23:34 PDT 2002   [info] Velocimacro :  VM library template
> macro registration complete.
> Thu May 02 15:23:34 PDT 2002   [info] Velocimacro : allowInline = true :
> VMs can be defined inline in templates
> Thu May 02 15:23:34 PDT 2002   [info] Velocimacro :
> allowInlineToOverride = false : VMs defined inline may NOT replace
> previous VM definitions
> Thu May 02 15:23:34 PDT 2002   [info] Velocimacro : allowInlineLocal =
> false : VMs defined inline will be  global in scope if allowed.
> Thu May 02 15:23:34 PDT 2002   [info] Velocimacro : messages on  : VM
> system will output logging messages
> Thu May 02 15:23:34 PDT 2002   [info] Velocimacro : autoload off  : VM
> system will not automatically reload global library macros
> Thu May 02 15:23:34 PDT 2002   [info] Velocimacro : initialization
> complete.
> Thu May 02 15:23:34 PDT 2002   [info] Velocity successfully started.
> Thu May 02 15:23:34 PDT 2002   [info] Using toolbox configuration file
> '/WEB-INF/toolbox.xml'
> Thu May 02 15:23:34 PDT 2002   [info] Toolbox setup complete.
> 
> ---
> // LayoutVelocityViewServlet 
> 
> package com.cisco.hrit;
> 
> import org.apache.velocity.Template;
> import org.apache.velocity.context.Context;
> import org.apache.velocity.exception.MethodInvocationException;
> import org.apache.velocity.exception.ParseErrorException;
> import org.apache.velocity.exception.ResourceNotFoundException;
> import org.apache.velocity.tools.view.servlet.VelocityViewServlet;
> 
> import javax.servlet.http.HttpServletResponse;
> import java.io.IOException;
> import java.io.StringWriter;
> import java.io.UnsupportedEncodingException;
> 
> public class LayoutVelocityViewServlet extends VelocityViewServlet {
> 
>     protected void mergeTemplate (Template template, Context context,
> HttpServletResponse response)
>             throws ResourceNotFoundException, ParseErrorException,
>             MethodInvocationException, IOException,
> UnsupportedEncodingException, Exception {
> 
>         // Check for a layout
>         String layoutFile = (String) context.get("LAYOUT");
> 
>         if (layoutFile != null) {
>             // Load up the layout template
>             Template layoutTemplate = null;
> 
>             try {
>                 layoutTemplate = getTemplate(layoutFile);
>             } catch (ResourceNotFoundException rnfe) {
>                 // couldn't find the template
>                 System.out.println("rnfe = " + rnfe);
>             } catch (ParseErrorException pee) {
>                 // syntax error : problem parsing the template
>                 System.out.println("pee = " + pee);
>             } catch (MethodInvocationException mie) {
>                 // something invoked in the template threw an exception
>                 System.out.println("mie = " + mie);
>             } catch (Exception e) {
>                 System.out.println("e = " + e);
>             }
> 
>             // Render the first pass, i.e. body content
>             StringWriter sw = new StringWriter();
>             template.merge(context, sw);
>             // Add the resulting content to the context
>             context.put("CONTENT", sw.toString());
>             // Render the second pass, i.e. layout
>             super.mergeTemplate(layoutTemplate, context, response);
>         } else {
>             // no layout specified, so just send the template specified
> directly to the user.
>             super.mergeTemplate(template, context, response);
>         }
> 
>     }
> }
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 


-- 
--
Gabriel Sidler
Software Engineer, Eivycom GmbH, Zurich, Switzerland


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