You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by rgm <st...@rgm.nu> on 2013/12/12 18:21:39 UTC

Diagnosing problem loading "theme.properties" on JBoss 7 with Struts 2.3.16

I'm trying to figure out why "theme.properties" isn't loaded from the
filesystem on my JBoss 7 system and believe that this is a useful change to
BaseTemplateEngine.java:

    private InputStream createFileInputStream(File propFile) throws
FileNotFoundException {
        InputStream is = null;
        if (propFile.exists()) {
            is = new FileInputStream(propFile);
+        } else {
+          throw new FileNotFoundException(propFile.toString());
+        }
        return is;
    }

This change allows the following message to be seen from the calling method:
  LOG.warn("Unable to find file in filesystem [" +
propFile.getAbsolutePath() + "]");

Without this change, no warning is printed (unless there's a problem
creating the FileInputStream).

Alternately, one could remove the check for "propFile.exists()" entirely
and allow the constructor for FileInputStream to throw the exception itself.

-rgm

Re: Diagnosing problem loading "theme.properties" on JBoss 7 with Struts 2.3.16

Posted by Lukasz Lenart <lu...@apache.org>.
Hi,

I see the problem,

BaseTemplateEngine#getThemeProps(Template template) doesn't use
ServletContext to resolve possible paths where theme.properties can be
found.

The solution is easy - move theme.properties under classpath and the
reset can lay where it is right now. The second option is to modify
BaseTemplateEngine to use also ServletContext (or somehow tell
BaseTemplateEngine to use ServletContext)


Regards
-- 
Ɓukasz
+ 48 606 323 122 http://www.lenart.org.pl/

2013/12/12 rgm <st...@rgm.nu>:
> I'm trying to figure out why "theme.properties" isn't loaded from the
> filesystem on my JBoss 7 system and believe that this is a useful change to
> BaseTemplateEngine.java:
>
>     private InputStream createFileInputStream(File propFile) throws
> FileNotFoundException {
>         InputStream is = null;
>         if (propFile.exists()) {
>             is = new FileInputStream(propFile);
> +        } else {
> +          throw new FileNotFoundException(propFile.toString());
> +        }
>         return is;
>     }
>
> This change allows the following message to be seen from the calling method:
>   LOG.warn("Unable to find file in filesystem [" +
> propFile.getAbsolutePath() + "]");
>
> Without this change, no warning is printed (unless there's a problem
> creating the FileInputStream).
>
> Alternately, one could remove the check for "propFile.exists()" entirely
> and allow the constructor for FileInputStream to throw the exception itself.
>
> -rgm

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org