Simplest Possible WebComponent with JAX-RS Backend

A Java class:

public class Hello {

    public String greeting;

    public Hello(String greeting) {
        this.greeting = greeting;
exposed via a JAX-RS:


public class HelloResource {

    public Hello hello() {
        return new Hello("hello, component");
can be easily accessed from a vanilla WebComponent:

class HelloComponent extends HTMLElement { 

    async connectedCallback() { 
        const response = await fetch("/hello");
        const { greeting } = await response.json();
        this.innerHTML = `

...declared in a HTML page

<!DOCTYPE html>
<html lang="en">
    <script src="app.js" type="module"></script>

No dependencies, no migrations.

See you at Web, MicroProfile and Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home: (e.g.:

Cloudy Jakarta EE and MicroProfile: Microservices, Clouds and Beyond Jakarta EE / MicroProfile airhacks workshops at MUC airport, Winter Edition the podcast:

Stay in touch:


Post a Comment:
  • HTML Syntax: NOT allowed
Online Workshops
...the last 150 posts
...the last 10 comments