Important: This news article covers an old version of Javalin (v4.0.0 (ALPHA)). The current version is v6.3.0.
See the documentation page for up-to-date information.

4.0 discussion

Please write your feature requests on GitHub.

4.0.0.ALPHA4 (15th of July)

  • New routing! Path parms have been changed from :param to {param}, and a new syntax has been introduced to allow path params with slashes (<param>). This also makes it possible to create paths like /{p1}AND{p2}, or /{filename}.{extension}.
  • All reified methods on Context have been brought back with the asClass suffix (ex. ctx.queryParamAsClass<Int>("key"))
  • Static JavalinJson is gone, replaced by config.jsonMapper(jsonMapper)
  • Added streaming methods to JsonMapper, these are optional methods for reducing memory usage
  • The sessionAttribute("key" consume = true) method has been renamed to consumeSessionAttribute("key")
  • Added a Plugin for setting security headers
  • You can now set custom errors for async timeouts
  • Fixed context-path bug in MicroMeter plugin
  • Added missing @JvmOverloads to HttpResponseException
  • The Context argument is now optional in FileRenderer
  • A ton of internal refactoring

ALPHA4 is intended to be the last alpha release of Javalin 4, next up is RC0!

4.0.0.ALPHA3 (22nd of June)

  • Added cachedSessionAttribute method to Context, which caches session-attributes as request-attributes.
  • The removeCookie method in Context now uses / as the default path
  • the HandlerType of a handler is now available in the Context
  • Validation has been completely reworked
  • Route declarations now take Role... instead of Set<Role
  • Attributes on Javalin now have the same signature as attributes on Context
  • The Context#result(Future) and Context#json(Future) methods have been replace by Context#future(Future) and Context#future(Future, Consumer). The consumer runs after the future has completed and accepts the result of the future as an argument. There is a default Consumer which makes Context#future work identical to both Context#result(Future) and Context#json(Future) from Javalin 3
  • Fixed a bug in OpenAPI with schema annotations for Instant not working
  • Fixed wrong error message if there was a port collision between a custom Jetty Server and a default Jetty server
  • Jetty’s TimeoutExceptions are now ignored instead of logged as error
  • The CorsPlugin now sets the Vary header
  • The default port is now 8080 to align with other JVM frameworks
  • The default server no longer sends the Server header

4.0.0.ALPHA2 (26th of May)

  • A new module with test tools has been added (javalin-testtools) - see API in PR
  • A Loom ThreadPool (virtual threads) is now used by default (if runtime has Loom)
  • Kotlin has been bumped to 1.5.0, and tests now run against JDK 15
  • Static-files config has been reworked. All global config options have been removed, and it’s now possible to set headers per handler. The “immutable” folder convention has been removed
  • You can now consume a session attribute by passing a boolean (ctx.sessionAttribute(key = "key", consume = true))
  • JavalinVue’s configuration has been reworked, it’s no longer possible to set things in the wrong order
  • Added a JavalinLogger to easily enable/disable all of Javalin’s logging
  • GraphQL now supports operation names
  • The cookie(name, value) method will now set instead of add (meaning you can no longer end up with two cookies with the same name)
  • The included rate-limiter has been renamed to NaiveRateLimiter, to further underline its limits
  • The Javalin version is now logged on startup
  • Javalin#config has been renamed to Javalin#_conf to avoid people accidentally using it

4.0.0.ALPHA1 (18th of April)

  • You can now validate empty strings in Validator
  • Content-Type can now be null for UploadedFile
  • WsHandler is now WsConfig
  • Context extensions (Context#register/Context#use) have been removed
  • JavalinVue now supports Vue3
  • Exceptions while writing responses in async mode are now handled gracefully
  • Can now set explicit “includes” in OpenAPI (ex: .includePath("/api")
  • Added option to log Jetty info during startup
  • Removed dependency on Jetty from OpenAPI plugin

4.0.0.ALPHA0 (17th of February)

This version is very similar to 3.13.3 (the last 3x version).

There is one breaking change, which is the extraction of inline reified functions from Context and WsContext. These functions lead to non-deterministic behavior in Mockk and Mockito, which made it hard to write mock tests.

Jackson has been bumped to 2.12.1, which actually required bumping to Kotlin 1.4 too.

The HttpResponseException class now properly serializes the details map to an object, rather than an array of key/value pairs.