-
Notifications
You must be signed in to change notification settings - Fork 233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Loading template group from STGroupDir in app running on Tomcat 8 fails #293
Comments
oh wow. Sorry about that. I'm probably not joining paths correctly. I'm currently focused on 1 billion other things but I would welcome a PR if you have time. |
I see that |
line 128 in STGroupDir is the issue:
which looks to be what you are fixing in your PR. I wonder if we can just use a proper URL or file path "join" to avoid the extra code with the special tests that you've created. |
There is no simple URL/URI path join API in Java 1.6. The first line of I've updated the PR to be more general, moving the logic to |
I would imagine we can move to Java 7 or 8 at this point. Is there something we can rely on in the new versions of Java? |
I tried a Java 7 implementation using NIO at https://github.com/Mooninaut/stringtemplate4/tree/java1.7 , but it causes several dozen tests to fail on Windows. I don't know that it's worth it. |
I didn't see any changes in that fork of yours but have you seen this that was linked to from the documentation? I'm going to look in there as well |
What if we simply removed '//' from any URL string? @Mooninaut |
I just pushed a new snapshot of 4.3.2 via maven. can you give it a try? |
Works great! |
hooray! |
StringTemplate version: 4.3.1
I'm migrating a web application from Tomcat 7 to Tomcat 8. It appears something in the class loader behavior has changed between the versions.
My app calls
STGroupDir group = new STGroupDir("com/example/app/path/to/templates");
When running on Tomcat 7, after the line
root = cl.getResource(dirName);
atSTGroupDir.java:72
the variableroot
has the valuejar:file:/path/to/exploded/app/WEB-INF/lib/my-component.jar!/com/example/app/path/to/templates
Running on Tomcat 8,
root
has the valuejar:file:/path/to/exploded/app/WEB-INF/lib/my-component.jar!/com/example/app/path/to/templates/
My app then calls
ST st = group.getInstanceOf("/TemplateGroup/someTemplate");
to loadsomeTemplate
from...path/to/templates/TemplateGroup.stg
.When
load()
calculatesgroupFileURL
on lineSTGroupDir.java:128
, the value isjar:file:/path/to/exploded/app/WEB-INF/lib/my-component.jar!/com/example/app/path/to/templates//TemplateName.stg
The double slash prevents it from successfully loading the template group file, and
getInstanceOf()
returnsnull
.The text was updated successfully, but these errors were encountered: