Hi all,
I used Velocity as template engine but when I execute my application
it threw run-time security errors.
Here is my source:
------------------
public class velocity_tmpl extends HttpServlet{
        public void doGet(HttpServletRequest req, HttpServletResponse res)
        {
                try {
                Properties properties = new Properties();
                properties.setProperty ("runtime.log.logsystem.class",
"org.apache.velocity.runtime.log.NullLogSystem");
                properties.setProperty("file.resource.loader.path","../
velocity_example");
                properties.setProperty("resource.loader", "file");
                properties.setProperty
( 
RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,"org.apache.velocity.runtime.log.Log4JLogChute"
 );
                Velocity.init(properties);

                } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }



        VelocityContext context = new VelocityContext();
        Template t = new Template();
        context.put("name", "Velocity");
        context.put("project", "Jakarta");

        StringWriter w = new StringWriter();

        try {
                t = Velocity.getTemplate("template.vm");
                //Velocity.mergeTemplate("template.vm", context, w);
                        //Velocity.mergeTemplate("template.vm", context, w );
                t.merge(context, w);
        } catch (ResourceNotFoundException e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                } catch (ParseErrorException e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                } catch (MethodInvocationException e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                } catch (Exception e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                }
        System.out.println("template: " + w);
        }
}
------------------
and this is error:
------------------
 [error] ResourceManager.getResource() load exception
access denied (java.io.FilePermission ..\velocity_example\template.vm
read)
java.security.AccessControlException: access denied
(java.io.FilePermission ..\velocity_example\template.vm read)
        at java.security.AccessControlContext.checkPermission
(AccessControlContext.java:323)
------------------
Is it possible to solve this.

Thank all,
J

On Oct 13, 6:46 pm, "K.Honsali" <[email protected]> wrote:
> thanks for response, sorry for ambiguity
>
> [It doesn't work] meant [velocity view servlet didn't parse the vm],
> besides crashes.
>
> the problem was actually solved, by adding mapping in appengine-
> web.xml using the following (beta):
>
>   <resource-files>
>         <include path="/**/*.properties" />
>         <include path="/*.properties" />
>         <include path="/**/*.vm" />
>         <include path="/*.vm" />
>    </resource-files>
>   <static-files>
>                 <exclude path="/**/*.vm" />
>                 <exclude path="*.vm" />
>
> Also, we noticed that appengine.jetty was mapping urls slightly
> differently from tomcat (i.e., no use of appname)
>
> salaam >> regards,
> K. Honsali
>
> On 12 oct, 21:07, "Jason (Google)" <[email protected]> wrote:
>
> > When you say that it doesn't work, what do you mean exactly? Are you seeing
> > a blank page, a stack trace, or something entirely different? Does your
> > web.xml file have a mime-mapping element for the vm extension, which I
> > assume should be displayed as text/html?
>
> > - Jason
>
> > On Fri, Oct 9, 2009 at 4:27 AM, K.Honsali <[email protected]> wrote:
>
> > > Greetings all;
>
> > > I haven't found much blob on this,
>
> > > Velocity worked almost fine on google app engine, local (eclipse) and
> > > remote excutions have some issues, but first here are the web.xml &
> > > site structure :
>
> > > - Web.xml
> > > ________________________________________________________
> > >   velocity       <>   /*.vm
> > >   xxxServlet  <>    /xxxCtrl
> > >   welcome-file <>  index.vm
>
> > > - Site
> > > Structure________________________________________________________
> > > war/
> > >     layouts
> > >     templates
> > >                 index.vm
> > >                 xxx-1
> > >                 xxx-n
> > >     resources { img ; css }
> > >     WEB-INF
> > >                  web.xml  ; appengine-web.xml
> > >                  classes
> > >     index.vm
>
> > > ________________________________________________________
> > > Now, the following issues were noticed under this setting:
>
> > > [works-both]   -www.domain.net/xxxServlet                 Request
>
> > >                        [container] >>> xxxServlet >>> request
> > > dispatch >>>Velocity(/index.vm )-
> > >                      www.domain.net/xxxServlet
> > > Request >>>
> > >                        [container] >>> xxxServlet >>> request
> > > dispatch >>>Velocity( /templates/xxxshow.vm)
>
> > > [local-only]    -www.domain.net
> > > Request .>>>
> > >                         [container] >>> Velocity( /index.vm )
> > >                    -www.domain.net/templates/
> > > Request .>>>
> > >                         [container] >>> Velocity( /index.vm )
>
> > > [neither]   -www.domain.net/index.vm Request  >>>
> > >                         [container] >>> Velocity( /index.vm  )
> > >                         -www.domain.net/templates/index.vm
> > > Request  >>>
> > >                         [container] >>> Velocity( /templates/
> > > index.vm  )
> > >                       -  www.domain.net/xxxServlet
> > > Request >>>
> > >                         [container] >>> xxxServlet >>> response
> > > sendRedirect >>>Velocity( /index.vm)
>
> > > Any comments please?

--

You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.


Reply via email to