StringTemplate getInstanceOf returns null
Asked Answered
A

0

6

Good Day!

I started using StringTemplate and I encountered a pretty annoying problem. I have a simple Template "T.st"

T(name, email, passwort) ::= << ... >>

It is saved in a directory "templates" which is part of my source folder "src/main/resources". When i execute following lines

STGroup group = new STGroupDir("templates");
ST st = group.getInstanceOf("T");

the root field of the group variable has the value "jar:file:/D:/path/to/apache-tomcat-8.0.21/wtpwebapps/application/WEB-INF/lib/service.jar!/templates/"

But st will be null, even though the groupdir was apparently found, because it exists within the given service.jar and when I change the dir name to something non-existent I get an exception that the directory doesn't exist. But i'm not sure why I can't get an instance of my T template.

Let's say i save my templates in "C:/templates" and use this to get the STGroup I will eventually get a valid instance and can render a correct string. Why is there a difference if my template is stored in a normal directory (working) or a directory within my service.jar (not working)?

regards

Arenaceous answered 23/9, 2015 at 7:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.