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
Javalin + JTE Hot reload doesn't work #63
Comments
Hey @IvanPizhenko, do you maybe generate jte sources to produce a self-contained JAR? If so, can you try to clean your generated sources and retry the hot reload? I had a similar issue and switched to precompiled templates after that .-) |
Yes, I am generating such JAR, but I do run my application just via Gradle using |
May it happen because precompilation puts classes into some "location 1" and on-demand compilation puts classes into "location2" which may be later on the classpath and so classes, even if on-demand compiled correctly, are loaded from location 1? Is there a way to tell JTE where to output classes during on-demand compilation? |
Here's what I noticed - I have precompilation output in the |
Found overloaded |
Specified that directory and checked that source and class generated in it are updated when I change JTE template. Still seeing the old one. What else this can be? |
Those precompiled class files are instantly available to the application class loader, since I guess The only solution I can think of is to place on demand generated templates in a different package than precompiled ones. This way there is no chance they conflict with each other. |
Well, now classes really go to the same package. Is it possible to make that depending on Template Mode, package name will differ - i.e for example (in Kotlin notation): |
… also sets different packages for on-demand or precompiled templates, so that hot reload works even if there are still old precompiled templates around.
@IvanPizhenko I made the package for template classes fully configurable and set defaults as you suggested. Precompiled templates are generated to package I've written a test that resembles your situation (just with generated code, since that was easier to set-up): Would you like to give it a try if this works for your project? You'd need to clone the jte repo and build
To use the locally built gradle plugin you'd need to temporarily add this to your project's settings.gradle file:
|
Great! Yes, I will try it and let you know. |
Doing it now... UPDATE Found a way to do it on Windows - read the full story here TLDR: # Run in the git-bash on Windows:
git update-index --chmod=+x 'name-of-shell-script'
git commit -m "....." |
Hmm... Still doesn't work. I can see that sources and classes in the |
Did one more test, and it started to work. The problem was that I've previously pointed class directory to the location on the classpath, i.e. return TemplateEngine.create(codeResolver, Path.of("build", "jte-classes-dev-hot-reload"), ContentType.Html) Please reflect this point in the documentation. |
So when do you plan to publish 1.8.0? |
I made mvnw executable, good suggestion :-) Glad you got it working. Yeah, whatever you put on the classpath will be picked up by the application class loader and won't be able to change, even with another classloader. Would you like to create a PR for the documentation adjustment? I'm not sure where to put it, maybe you have a location in mind where it would've been helpful to you. Will probably release 1.8.0 this weekend. This version will mainly add an optional Kotlin module, that allows to have Kotlin instead of Java as expression language in templates (#59). The IntelliJ plugin needs some more adjustments to support it, but I think I'm ready to release Kotlin support as a beta feature this weekend. |
Posted PR #64 |
@IvanPizhenko I just released version 1.8.0 👍 |
Thanks! |
I've set up things for the hot reload in the my Javalin + JTE based application as follows:
But hot reload just doesn't work. When I change JTE file and referesh page in browser, it just doesn't change.
I've create descendant class from the
DirectoryCodeResolver
and overridden interface methods to output stuff to log and forcibly report that file has changed even if it is not.But still even with forced "always changed" file it still doesn't work.
According to log outputs, this part works correctly - when I change JTE file and refresh browser, method from
DirectoryCodeResolver
reports file as changed, and my customresolve()
shows different file size.However, rendering result still as if old version is used. Actually, rendering result corresponds to JTE template content faced on the first rendering - no matter how much times I change page and refresh browser, the page is always as it was first time, before any changes.
Please fix.
The text was updated successfully, but these errors were encountered: