Failed to compile template: constant string too long
See original GitHub issueSteps to reproduce:
- a long file in
tag/something.jte
- include in another jte file with
@tag.something()
- render
Long templates should be somehow split up to stay under the Java length limit.
Failed to compile template, error at tag/content/samples.jte:6156
<snip>/jte-classes/gg/jte/generated/tag/content/JtesamplesGenerated.java:6: error: constant string too long
jteOutput.writeContent("\n <div class=\"row\">\n ...................");
^\n1 error
\n\n\tat gg.jte.internal.ClassFilesCompiler.runCompiler(ClassFilesCompiler.java:35)
\n\tat gg.jte.internal.ClassFilesCompiler.compile(ClassFilesCompiler.java:23)
\n\tat gg.jte.internal.TemplateCompiler.precompile(TemplateCompiler.java:77)
\n\tat gg.jte.internal.TemplateCompiler.load(TemplateCompiler.java:40)
\n\tat gg.jte.TemplateEngine.resolveTemplate(TemplateEngine.java:267)
\n\tat gg.jte.TemplateEngine.render(TemplateEngine.java:151)
\n\tat io.javalin.plugin.rendering.template.JavalinJte.render(JavalinJte.kt:33)
\n\tat io.javalin.plugin.rendering.JavalinRenderer.renderBasedOnExtension(JavalinRenderer.kt:34)
\n\tat io.javalin.http.Context.render(Context.kt:480)\n\tat com.flowcrypt.server.controller.webapp.TestPanelKt.testPanel(TestPanel.kt:16)
\n\tat com.flowcrypt.server.WebApp$4.invoke(WebApp.kt:37)
\n\tat com.flowcrypt.server.WebApp$4.invoke(WebApp.kt:20)
\n\tat com.flowcrypt.server.WebApp$sam$io_javalin_http_Handler$0.handle(WebApp.kt)
\n\tat com.flowcrypt.commands.Server$getAccessManager$1.manage(Server.kt:120)
\n\tat io.javalin.http.JavalinServlet$addHandler$protectedHandler$1.handle(JavalinServlet.kt:121)
\n\tat io.javalin.http.JavalinServlet$service$2$1.invoke(JavalinServlet.kt:45)
\n\tat io.javalin.http.JavalinServlet$service$2$1.invoke(JavalinServlet.kt:24)
\n\tat io.javalin.http.JavalinServlet$service$1.invoke(JavalinServlet.kt:129)
\n\tat io.javalin.http.JavalinServlet$service$2.invoke(JavalinServlet.kt:40)\n\tat io.javalin.http.JavalinServlet.service(JavalinServlet.kt:81)
\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
\n\tat io.javalin.websocket.JavalinWsServlet.service(JavalinWsServlet.kt:51)
\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
\n\tat org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:763)
\n\tat org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:569)
\n\tat org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)\n\tat org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1610)\n\tat org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)\n\tat io.javalin.core.JavalinServer$start$wsAndHttpHandler$1.doHandle(JavalinServer.kt:49)\n\tat org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)\n\tat org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:507)\n\tat org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1580)\n\tat org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)\n\tat org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1292)\n\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)\n\tat org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)\n\tat org.eclipse.jetty.server.Server.handle(Server.java:501)\n\tat org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:383)\n\tat org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:556)\n\tat org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:375)\n\tat org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:273)\n\tat org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)\n\tat org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)\n\tat org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104)\n\tat org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336)\n\tat org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313)\n\tat org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171)\n\tat org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:135)\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:806)\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:938)\n\tat java.base/java.lang.Thread.run(Thread.java:834)\n
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Fixing “constant string too long” Build Error - Baeldung
When we try to use a variable that is too long for the Java compiler (larger than 64 KB) we receive a “constant...
Read more >Java "constant string too long" compile error. Only happens ...
Whenever I compile the same class with ant, I get the "constant string too long" compile error. I've tried a number of ways...
Read more >Compiler messages - IBM
Unable to create pdf file because the specified file name is too long. CCN2468 Unable to open file "&1", ... String literal is...
Read more >String literal - cppreference.com
If a valid hex digit follows a hex escape in a string literal, it would fail to compile as an invalid escape sequence....
Read more >Parser messages - Free Pascal
Error : Wrong number of parameters specified for call to ”arg1” ... to initialize the array; Error: String constant too long while ansistrings...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@casid This isn’t about methods or class files being too long, but rather the constant string size limit of Java, which is 65535 bytes, which is quite low for larger templates that don’t contain variables.
I’ve implemented a fix in #26 and classified this as a bug rather than an enhancement.
Alright, will do that. Good luck and let me know if you run into any problems with this approach.