Questions tagged [javalin]

Use this tag for programming questions about the Javalin web framework for Java and Kotlin.

Overview

Javalin is a lightweight web framework built on the Jetty web server.

The framework can be integrated into Java and Kotlin projects.

Javalin supports several template engines including Thymeleaf and Velocity. It has built-in support for WebSockets, HTTP2, static file serving, exception mapping, server-sent events, asynchronous mode, as well as a variety of common tasks such as validation, access control, logging, and server configuration.

An OpenAPI (Swagger) plugin is also provided, as well as a GraphQL plugin.


Resources


Hello World

Java:

import io.javalin.Javalin;

public class HelloWorld {
    public static void main(String[] args) {
        Javalin app = Javalin.create().start(7070);
        app.get("/", ctx -> ctx.result("Hello World"));
    }
}

Kotlin:

import io.javalin.Javalin

fun main() {
    val app = Javalin.create().start(7070)
    app.get("/") { ctx -> ctx.result("Hello World") }
}
86 questions
0
votes
1 answer

read ENVIRONMENT_VARIABLE from application-env.yml in plain java

I have a simple java web service that uses javalin framework. I want to deploy it in multiple environments, so the env variables are different for each deployment. I basically want to read application-env.yml keystore: path: ${KEY_STORE_PATH} …
0
votes
0 answers

How do you use a yaml file with Javalin framework?

public static final String JDBC_DRIVER = value from yml; public static final String DB_URL = value from yml; public static final String DB_NAME = value from yml; public static final String USER = value from yml; public static…
Hiep Huynh
  • 21
  • 1
  • 2
0
votes
2 answers

Can't run Javalin backend and Apache web host at the same time

I've made a Javalin backend host that I've been starting on 0.0.0.0:7000 for a while now, but I recently began using Apache2 for the frontend content-serving. I was able to get apache set up, and it's running great, but now my backend won't start,…
LetsdothisEpic
  • 126
  • 1
  • 6
0
votes
1 answer

Adding Javalin dependencies

I'm trying to use Javalin in my project and I can't seem to understand how to add the needed dependencies in order to work with Javalin without compliation errors. The project i'm working on is not a Maven project, it is a simple Java project so it…
0
votes
1 answer

Javalin Ratelimit in 3.0

We are trying to implement the no.of request to the API using below syntax from the documentation for our API handler val app = Javalin.create { it.defaultContentType = "application/json" it.enableWebjars() …
Maverick
  • 397
  • 1
  • 4
  • 18
0
votes
1 answer

Disabling Options method in Javalin 3.0

We are using Javalin in our kotlin application and we want to disable the options method from the handlers, We want to keep only get,post methods. below is the config code of Javalin val app = Javalin.create { it.defaultContentType =…
Maverick
  • 397
  • 1
  • 4
  • 18
0
votes
1 answer

Javalin Migration

I am new to Kotlin and Javalin. While migrating from Javalin 3 to 4, Javalinjackson.configure() function is deprecated. Below is the part of the code import io.javalin.plugin.json.JavalinJackson import…
Maverick
  • 397
  • 1
  • 4
  • 18
0
votes
1 answer

Way to create a simple Java HttpServer

I have an old application with Spring MVC on Tomcat in which I want to start a server on a different port. I usually use the handy Javalin for such cases. But in this case it doesn't suit me because it is loaded using Jetty which loads…
SnejOK
  • 75
  • 7
0
votes
1 answer

Thymeleaf: "Exception evaluating OGNL expression" in a simple for loop

I have this controller: it.render( "my-list.html", mapOf( "votes-positive" to repo.votesOf("x"), ) ) //... data class Vote( val name: String, val type: Type, ) { enum class Type { POS, NEG } } my template file…
Luís Soares
  • 5,726
  • 4
  • 39
  • 66
0
votes
1 answer

Strange problem while migrating to javalin 4.0.0

I have strange problem after migrating to javalin 4.0.0. After starting javalin listening on specified port, but doesn't process any requests. This is response from curl command. * Trying ::1... * TCP_NODELAY set * Connected to localhost (::1)…
0
votes
2 answers

Swagger is not recognizing my OpenApi annotation

I'm trying to build a swaggerUI for my API and I'd like to specify pathParameters for my POST method. My code is setup as follows: app.routes { post("/cameras") { context -> postCamera(context) } } @OpenApi( summary = "Create Camera", …
mooglin
  • 500
  • 5
  • 17
0
votes
1 answer

Hibernate with PostgreSQL on Heroku error creating table

I'm getting this error when building a Javalin app that uses Hibernate with PostgreSQL. All the other tables are being created normally but this one gives me this error and I can't figure out why. I have seen this error but it happens when using the…
Dreamy
  • 5
  • 2
0
votes
1 answer

Possible ways to encrypt database password in Javalin framework

Update password configs to store encrypted passwords (instead of plain-texts) for Ignite DB One type I know is AES,Is there any different techniques for encryption with pros and cons will be helpful.
Epp
  • 1
0
votes
1 answer

Javalin IO (Java): Path parameter 'id' with value 'list' is not a valid Long

Coming across a problem in Javalin where the Console output in my IntelliJ Idea IDE, is outputting a 400 HTTP error code, where it has a problem trying to have a: List id parameter, which is being called as just a: Long id in other classes…
0
votes
2 answers

Using webjars with Javalin and Vue

I am aware that Javalin supports Vue and I use it without problems. It is easy to set up, I only had to call the config.enableWebjars() and using Vue is quite out of box and simple. However, I would like to use other tools, which are not deeply…
Balage1551
  • 1,037
  • 1
  • 10
  • 28