Skip to content

GeeCON 2018: Marcus Fihlon - Kotlin EE: Boost your Productivity

Marcus Fihlon

Communitygeecon conference51 minOpen on YouTube ↗

GeeCON 2018: Marcus Fihlon - Kotlin EE: Boost your Productivity.

Summary

### Overview In this GeeCON 2018 presentation, Marcus Fihlon explores how combining the Kotlin programming language with Jakarta EE (formerly Java EE) and Docker containers can create lightweight, productive microservices. Addressing common criticisms that Java EE is inherently bloated, Fihlon argues that modern enterprise APIs combined with containerization offer a streamlined development model that delegates transitive dependency management to server runtimes while leveraging Kotlin's concise, modern syntax.

### Key Topics - **Kotlin Language Features**: Statically typed, interoperable with Java bytecode, transpiles to JavaScript, and compiles to native code (supporting Android and iOS). Kotlin reduces Java boilerplate via features like immutability (`val` vs. `var`), null-safety types, data classes, string templates, built-in singletons (`object`), and co-routines. - **Jakarta EE and Dependency Management**: Rather than managing complex dependency trees and transitive version conflicts (e.g., conflicting Guava versions) in Maven or Gradle, Jakarta EE offers "library management as a service." Standard APIs (JAX-RS, JPA, CDI, Bean Validation) are provided by the runtime application server (e.g., Payara Micro). - **Thin Docker Images**: By separating application logic into a tiny `.war` file layered over pre-configured vendor application server images, developers maintain minimal Docker build times and small deployment artifacts. - **Kotlin & Enterprise Runtime Pitfalls**: Standard Java EE application servers rely on proxies and reflection, requiring non-final classes and zero-argument constructors. Because Kotlin classes are final by default and generate parameterized constructors, builds must configure compiler plugins: `kotlin-allopen` and `kotlin-noarg`.

### Technical Details Fihlon demonstrates a live implementation of two microservices using Gradle and JAX-RS running inside Payara Micro Docker images: - **Time Service**: An internal REST endpoint that outputs plain-text timestamps using `java.time.LocalDateTime.now()`. It is mapped to the internal Docker network and not exposed externally. - **Hello Service**: An externally accessible REST endpoint accepting dynamic path parameters via `@PathParam("name")`. It uses the JAX-RS `ClientBuilder` to query the internal `time-service` using Docker's built-in DNS service discovery and round-robin load balancing (`http://time-service:8080/api/time`). - **Container Orchestration with Docker Swarm**: Using `docker-machine` with VirtualBox drivers, Fihlon provisions a local four-node Swarm cluster (one manager and three worker nodes). He creates an overlay network (`geekcon`), deploys the visualizer tool to track nodes, launches services using `docker service create`, and scales both services across the cluster to three replicas using `docker service update --replicas 3`.

### Takeaways - Combining Kotlin with Jakarta EE avoids verbose enterprise boilerplate while keeping business logic clean and expressive. - Utilizing build-time compiler plugins (`allopen` and `noarg`) seamlessly resolves reflection and proxying constraints imposed by EE application servers. - Packaging enterprise applications into thin Docker layers deployed on container orchestration tools like Docker Swarm provides reproducible, easily scalable, and testable microservice architectures.

Related talks