-
Notifications
You must be signed in to change notification settings - Fork 59
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
java.lang.NoClassDefFoundError: gg/jte/html/HtmlTemplateOutput #280
Comments
Hi, from the stacktrace I assume the error happens in the When this happens with Spring Boot it usually is a classloader problem. Can you try to pass the Spring Boot classloader like this? |
With this change it is working. Want to know the best practice in managing "jte-classes" code.
|
Glad it is working! Personally, I put the jte source files in something like src/main/jte (like we do it with Java files) If you want a self contained jar, you can use the generate Gradle task as described here: https://github.com/casid/jte/blob/main/DOCUMENTATION.md#using-the-application-class-loader-since-120. This way the Gradle task only generates a Java file for each jte file and leaves compilation to the regular Java compiler. You can specify which package the jte templates be located in, but you don't have to. With the default config, you would just create the template engine like this: |
Thank you very much @casid both the suggestions worked fine. Able to include jte generated classes inside jar file using the gradle task. |
Handler dispatch failed: java.lang.NoClassDefFoundError: gg/jte/html/HtmlTemplateOutput] with root cause
java.lang.ClassNotFoundException: gg.jte.html.HtmlTemplateOutput
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445) ~[na:na]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:592) ~[na:na]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525) ~[na:na]
at java.base/java.lang.Class.getDeclaredMethods0(Native Method) ~[na:na]
at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3402) ~[na:na]
at java.base/java.lang.Class.getDeclaredMethods(Class.java:2504) ~[na:na]
at gg.jte.runtime.Template.findRenderMethods(Template.java:69) ~[jte-runtime-3.1.0.jar!/:na]
at gg.jte.runtime.Template.(Template.java:26) ~[jte-runtime-3.1.0.jar!/:na]
at gg.jte.runtime.TemplateLoader.load(TemplateLoader.java:26) ~[jte-runtime-3.1.0.jar!/:na]
at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708) ~[na:na]
at gg.jte.TemplateEngine.resolveTemplate(TemplateEngine.java:339) ~[jte-runtime-3.1.0.jar!/:na]
at gg.jte.TemplateEngine.render(TemplateEngine.java:228) ~[jte-runtime-3.1.0.jar!/:na]
private static Path JTE_FILE_PATH = Path.of("src", "main", "resources", "jte");
private static Path JTE_PRECOMPILED_FILE_PATH = Path.of("jte-classes");
I can see the dependent libraries in the jar file.
inflated: META-INF/build-info.properties
created: BOOT-INF/classes/jte/
inflated: BOOT-INF/classes/jte/hello.jte
inflated: BOOT-INF/classes/application.properties
extracted: BOOT-INF/lib/jte-extension-api-3.1.0.jar
extracted: BOOT-INF/lib/jte-runtime-3.1.0.jar
extracted: BOOT-INF/lib/jte-3.1.0.jar
build.gradle file
The text was updated successfully, but these errors were encountered: