[forge-users] Using template files from Jar

forge-users at lists.jboss.org forge-users at lists.jboss.org
Tue Feb 17 05:36:28 EST 2015

Hello George,
Thank you

Indeed there is no need to use File or FileResource even if its a file after all (I'm a disciple of intuitive programming {emoticon:class=jive_macro jive_emote|src=https://static.jboss.org/developer/|__jive_emoticon_name=happy} ).
That leads to a problem (project root appended before an ok full file path).  (should I create a TestCase ?)

Resource<URL> templateResource = rfactory.create(getClass().getResource("voila.txt"));
  brings null in templateResource although this syntax is used in the angular-js addon for example (FreemarkerClientTest.java)

For future reference, a working code is :
|  |  | Resource<URL> templateResource = rfactory.create(getClass().getClassLoader().getResource("voila.txt")); |
|  |  | Template template = tfactory.create(templateResource, FreemarkerTemplate.class); |

I'm using Java 7.0.40 on w7 64 and it works on my machine, today {emoticon:class=jive_macro jive_emote|src=https://static.jboss.org/developer/|__jive_emoticon_name=happy}

As I plan to have a quantity of templates I prefer to put them in resources, separated from java sources.
I'll file an improvement request about that because what's the point of having the maven tree if a part of it is not used by default.



Posted by forums
Original post: https://developer.jboss.org/message/918971#918971

More information about the forge-users mailing list