-
Notifications
You must be signed in to change notification settings - Fork 394
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
FileNotFoundException: JAR entry templates/index.gtpl not found in jar #1293
Comments
Seems like issue doesn't depends on ratpack, I face with very same problem here But anyway, I would be glad, If anybody previously solve this problem and can share -- |
Hello, I have quick update, regarding posted issue: seems like resources should be loaded using input stream. with spring context I can inject val resource = resources.getResource("classpath:templates/index.gtpl")
InputStreamReader(resource.inputStream).use {
return it.readText()
} but I cannot use it with ratpack.groovy.Groovy.groovyMarkupTemplate - that method expects the id/name of the template, not content... I debug a little bit more and found that application fails on resolveTemplate - maybe it's ok for files from file system, but not for files from jar? at this moment templatesDir is pointing as absolute path to templates dir, so it couldn't be resolved in jar |
there is your *.tpl file in the project (relative path) and your |
hello, @SlyDen .ratpack file is inside *.gtpl files are inside instead of .tpl im's using .gtpl, but It shouldn't be an issue as far I'm explicitly telling Groovy.groovyMarkupTemplate a name, (not id): Blocking.get(() -> {
final HashMap<String, Object> model = new HashMap<String, Object>();
model.put("message", "This is a groovy template engine from ratpack!");
model.put("users", userRepository.findAll()
.stream()
.map(User::toString)
.collect(toList()));
return model;
}).then(model -> context.render(
Groovy.groovyMarkupTemplate(model, "index.gtpl", "text/html;charset=UTF-8")
)); in my previous post I mentioned that in another spring-boot project I faced with very same problem when I've tried get resource like it can be done from regular file system and this isn't work with jar, so I think Groovy.groovyMarkupTemplate in this case is doing same, that is why it's working with filesystem resources, but not with resources from bundled jar file note 1 jar execution also won't work even if I copied templates folder and .ratpack file in current directory: gradle build
cp -Rf src/main/resources/templates ./
cp src/main/resources/.ratpack ./
java -jar build/libs/groovy-template-engine.jar
http :5050 # response 500 note 2 and again, with Regards, |
Hi @daggerok I've spent a little time looking at this. The problem is clearly in I don't think there's anything Ratpack can do here. As such, I'm going to close this issue. |
Hello @ldaley, I was facing with similar issues previously (it depends on class loader), and all the time I was able fix it by lookup file resources using right class loader. With current API i can't apply such fix. Does anybody knows something similar for Groovy.groovyMarkupTemplate? Something like resource = getClass().getClassLoader().getResourceAsStream("index.gtpl")...
Groovy.groovyMarkupTemplate(model, resource);
it definitely can, because I'm using ratpack API for: import ratpack.groovy.Groovy;
import ratpack.groovy.template.MarkupTemplateModule; I think it shouldn't be very hard add method with such functionality which takes resource from classloader and after (during render processing) will able find file in jar. All problem is accessng to file from jar, otherwise it work f wine if application is unbundled.. Regards |
The better fix would be for the Spring Boot team to fix their custom JAR URL loader to find the file that is there. Then this would just work. If you would like to submit a patch to have the |
Hello,
I'm building application using
io.ratpack:ratpack-spring-boot:1.5.0
source code for reproduce located here
when I running application using gradle (
./gradlew bootRun
) or from idea all works finehttp :5050 06:20:59 HTTP/1.1 200 OK # skipped...
but as if I'm building jar and executing it
./gradlew assemble java -jar build/libs/*.jar
groovyMarkupTemplate is failing on line 46
with error:
Caused by: java.io.FileNotFoundException: JAR entry templates/index.gtpl not found in /Users/mak/Documents/code/test/ratpack/ratpack-examples/groovy-template-engine/build/libs/groovy-template-engine.jar
full stack trace log:
I've checked bundled jar and index.gtpl exists
so it should be available in runtime by path template/index.gtpl
note: spring mvc in all cases renders template successfully (
http :8080
)Regards,
Maksim
The text was updated successfully, but these errors were encountered: