You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by otisg <ot...@ureach.com> on 2003/05/01 05:20:48 UTC
ResourceManager : unable to find resource ...
Hello,
I am trying to use the regular Struts Action servlet along
VelocityViewServlet. The former mapped to *.do, the latter to
*.vm requests. I am observing some strange behaviour:
1. Request to http://.../Action.vm give me an error:
VelocityServlet : Error processing the template
org.apache.velocity.exception.ResourceNotFoundException: Unable
to find resource '/Home.vm'
....
And I see this in the error log:
Velocity [error] ResourceManager : unable to find resource
'/Home.vm' in any resource loader.
2. Request to http://.../Action.do _does_ work _but_ seems to
use Velocity classes. That is strange, because I have .do
mapped to Struts Action servlet, and _not_ VelocityViewServlet.
Weird, no?
The reason I see that .do is handled by Velocity classes is this
log message:
[2003/04/30 23:04:09] Velocity [info] ResourceManager : found
/WEB-INF/view/Home.vm with loader
org.apache.velocity.tools.view.servlet.WebappLoader
To show you that I'm not on crack, here is relevant stuff from
web.xml (I hope the XML does not get gobbled up by my or your
mailer):
<servlet-mapping>
<servlet-name>SimpyStrutsActionServlet</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>SimpyVelocityViewServlet</servlet-name>
<url-pattern>*.vm</url-pattern>
</servlet-mapping>
The 2 servlet-names _do_ point to correct classes:
org.apache.struts.action.ActionServlet
and
org.apache.velocity.tools.view.servlet.VelocityViewServlet
My action mapping in Struts config looks like this:
<action path= "/Action"
type= "com.simpy.webapp.actions.HomeAction"
scope= "request"
validate= "false">
<forward name= "success" path="/WEB-INF/view/Home.vm"/>
</action>
And in my .war file, this Home.vm really is there, in the
correct place:
WEB-INF/view/Home.vm
So, what I am wondering is:
1) How come .do requests are still going to Struts Action
servlet?
2) What does VVServlet need in order to find my Home.vm file?
Thank you,
Otis
________________________________________________
Get your own "800" number
Voicemail, fax, email, and a lot more
http://www.ureach.com/reg/tag
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: ResourceManager : unable to find resource ...
Posted by Nathan Bubna <na...@esha.com>.
otisg said:
...
> I am trying to use the regular Struts Action servlet along
> VelocityViewServlet. The former mapped to *.do, the latter to
> *.vm requests. I am observing some strange behaviour:
>
> 1. Request to http://.../Action.vm give me an error:
>
> VelocityServlet : Error processing the template
> org.apache.velocity.exception.ResourceNotFoundException: Unable
> to find resource '/Home.vm'
...
?? You are asking the servlet for 'Action.vm' and it tries to find
'Home.vm'? I'm guessing you just typed that wrong...
Anyway, two things:
1. You aren't using the latest CVS of velocity-tools. I can tell by the
error message text :-). Since we haven't had a release yet, updating your
code to the latest should be one of your first debugging steps. That way I
know you're on the same page as me.
2. In your velocity.properties, what is the path you have set for the
WebappLoader? It should be a line something like:
webapp.resource.loader.path = blah blah blah
> 2. Request to http://.../Action.do _does_ work _but_ seems to
> use Velocity classes. That is strange, because I have .do
> mapped to Struts Action servlet, and _not_ VelocityViewServlet.
> Weird, no?
Not weird at all. Your Struts actions *should* forward to a velocity
template once they are done processing. The action is the controller and
the template is the *view.* That's the whole point. :-)
...
> My action mapping in Struts config looks like this:
>
> <action path= "/Action"
> type= "com.simpy.webapp.actions.HomeAction"
> scope= "request"
> validate= "false">
> <forward name= "success" path="/WEB-INF/view/Home.vm"/>
> </action>
>
> And in my .war file, this Home.vm really is there, in the
> correct place:
> WEB-INF/view/Home.vm
Ah ha! I'm betting you don't have a webapp.resource.loader.path set, and
that the URL you are hitting to access the Home.vm or Action.vm template
directly does not include the full /WEB-INF/view/ path, right?
my recommendation is this:
1. update your velocity-tools code from CVS.
2. in your velocity.properties, set
webapp.resource.loader.path = /WEB-INF/view
3. in your struts-config.xml, remove the /WEB-INF/view portion of your
template paths and trim them down to just the template name. e.g.
<forward name="success" path="Home.vm" />
If that doesn't work, take two aspirin and call me in the morning.
Nathan Bubna
nathan@esha.com
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org