Re: Configuration object - filepermission issue

Daniel Dekany <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
Friday, July 29, 2011, 6:03:05 PM, the real mckoy wrote:

> Hi:
>
> when creating an instance of Configuration, it tries to read the default runtime directory.
>
> Would it be possible to explicitly set that directory for the
> Configuration object because the classloader that is creating the
> Configuration should not have access to that directory (the default
> runtime directory, in my Webserver context anyway).
>
> java.security.AccessControlException: access denied
> (java.io.FilePermission C:\Users\admin\workspace\appserver read)
>     at java.security.AccessControlContext.checkPermission(Unknown Source)
>     at java.security.AccessController.checkPermission(Unknown Source)
>     at java.lang.SecurityManager.checkPermission(Unknown Source)
>     at java.lang.SecurityManager.checkRead(Unknown Source)
>     at java.io.File.exists(Unknown Source)
>     at
> freemarker.cache.FileTemplateLoader$1.run(FileTemplateLoader.java:124)
>
> I set template directory  later with:
>
>  cfg.setDirectoryForTemplateLoading(context.getDocumentsDirectory());
>
> but its too late the exception is thrown at the creation of the Configuration object.

It's just a warning in your logs, isn't it? So then it doesn't
interrupt anything.

But indeed, choosing system property "user.dir" as the default
template directory is a unfortunate legacy, that haven't noticed until
now (thanks). By default the Configuration should use some kind of
dummy TemplateLoader that just says "not found" for everything. It
would be easy to implement that, only, it's not 100% backward
compatible, so it should only appear in 2.4. (Unless, you say it's an
urgent mater, in which case it's always possible to introduce a static
method and/or system property to control this.)

-- 
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
Got Input?   Slashdot Needs You.
Take our quick survey online.  Come on, we don't ask for help often.
Plus, you'll get a chance to win $100 to spend on ThinkGeek.
http://p.sf.net/sfu/slashdot-survey
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.