I'm trying to build small Web application based on Javalin framework. I've selected javalin-website-example (https://github.com/tipsy/javalin-website-example.git) as application template with following changes in setup:
- Javalin version changed to 5.6.3
- Google guava version changed to 32.1.3-jre
- package app replaced with longer one ending with org.xxxxx.yyyyy.app
My development environment is Eclipse version 2023-09, project is configured to use Java 11 (BellSoft JDK 11.0.15.1+2-LTS)
Javalin project was successfully created, i.e. there is no build errors in Eclipse. Application code is below:
package org.nsorokin.tools.taskcontroller.clientweb.app;
import org.nsorokin.tools.taskcontroller.clientweb.app.util.Filters;
import org.nsorokin.tools.taskcontroller.clientweb.app.util.Path;
import org.nsorokin.tools.taskcontroller.clientweb.app.login.LoginController;
import org.nsorokin.tools.taskcontroller.clientweb.app.index.IndexController;
import org.nsorokin.tools.taskcontroller.clientweb.app.user.UserDao;
import org.nsorokin.tools.taskcontroller.clientweb.app.util.Filters;
import io.javalin.plugin.bundled.RouteOverviewPlugin;
//import io.javalin.rendering.JavalinRenderer;
import static io.javalin.apibuilder.ApiBuilder.before;
import static io.javalin.apibuilder.ApiBuilder.get;
import static io.javalin.apibuilder.ApiBuilder.post;
import io.javalin.Javalin;
import io.javalin.http.staticfiles.Location;
public class ClientWeb {
public static UserDao userDao;
public static void main(String[] args) {
userDao = new UserDao();
Javalin clientWebApp = Javalin.create(config -> {
config.staticFiles.add("/public", Location.CLASSPATH);
config.plugins.register(new RouteOverviewPlugin("/routes"));
}).start(7000);
clientWebApp.routes(() -> {
before(Filters.handleLocaleChange);
before(LoginController.ensureLoginBeforeViewingBooks);
get(Path.Web.INDEX, IndexController.serveIndexPage);
get(Path.Web.LOGIN, LoginController.serveLoginPage);
post(Path.Web.LOGIN, LoginController.handleLoginPost);
post(Path.Web.LOGOUT, LoginController.handleLogoutPost);
});
//ClientWeb cWeb = new ClientWeb();
//cWeb.process(args);
}
protected void process(String[] args) {
}
}
IndexController code is below:
package org.nsorokin.tools.taskcontroller.clientweb.app.index;
import static org.nsorokin.tools.taskcontroller.clientweb.app.ClientWeb.*;
import java.util.Map;
import org.nsorokin.tools.taskcontroller.clientweb.app.util.Path;
import org.nsorokin.tools.taskcontroller.clientweb.app.util.ViewUtil;
import io.javalin.http.Handler;
public class IndexController {
public static Handler serveIndexPage = ctx -> {
Map<String, Object> model = ViewUtil.baseModel(ctx);
model.put("users", userDao.getAllUserNames());
//model.put("book", bookDao.getRandomBook());
ctx.render(Path.Template.INDEX, model);
};
}
I can start it as Java application and initial startup is completed without errors. However, when I try to get any configured page - login or index - the error java.lang.IllegalArgumentException: No Renderer registered for extension '.vm' is thrown; the statement in error appeared to be the call ctx.render(), the trace log is below
Dec 14, 2023 10:47:40 AM io.javalin.util.JavalinLogger warn
WARNING: Uncaught exception
java.lang.IllegalArgumentException: No Renderer registered for extension '.vm'.
at io.javalin.rendering.JavalinRenderer.renderBasedOnExtension(JavalinRenderer.kt:32)
at io.javalin.rendering.LegacyFileRenderer.render(JavalinRenderer.kt:20)
at io.javalin.http.Context.render(Context.kt:452)
at org.nsorokin.tools.taskcontroller.clientweb.app.index.IndexController.lambda$0(IndexController.java:18)
at io.javalin.routing.HandlerEntry.handle(HandlerEntry.kt:19)
at io.javalin.http.servlet.DefaultTasks.HTTP$lambda$8$lambda$6$lambda$5(DefaultTasks.kt:39)
at io.javalin.http.servlet.JavalinServlet.handleTask(JavalinServlet.kt:88)
at io.javalin.http.servlet.JavalinServlet.handleSync(JavalinServlet.kt:53)
at io.javalin.http.servlet.JavalinServlet.service(JavalinServlet.kt:41)
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:587)
at io.javalin.jetty.JavalinJettyServlet.service(JavalinJettyServlet.kt:58)
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:587)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:764)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:529)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:221)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1570)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:221)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1381)
at io.javalin.jetty.JettyServer$start$wsAndHttpHandler$1.doHandle(JettyServer.kt:61)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:176)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:484)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1543)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:174)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1303)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:129)
at org.eclipse.jetty.server.handler.StatisticsHandler.handle(StatisticsHandler.java:173)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:122)
at org.eclipse.jetty.server.Server.handle(Server.java:563)
at org.eclipse.jetty.server.HttpChannel$RequestDispatchable.dispatch(HttpChannel.java:1598)
at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:753)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:501)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:287)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:314)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:100)
at org.eclipse.jetty.io.SelectableChannelEndPoint$1.run(SelectableChannelEndPoint.java:53)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:969)
at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.doRunJob(QueuedThreadPool.java:1194)
at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1149)
at java.base/java.lang.Thread.run(Thread.java:829)
The original example (https://github.com/tipsy/javalin-website-example.git) was executed correctly without problems. I wander what may cause my error and how I can fix it.
With best regards, Nick
The problem was caused by missing Javalin dependency io.javalin:javalin-rendering version 5.6.3 (that actually was not deployed to Maven Central repo.
After contacting with developers the artefact was uploaded to Maven Central and after application re-build the problem was resolved.
Thanks to Javalin developers for quick responce.
Regards, Nick