micronaut-views icon indicating copy to clipboard operation
micronaut-views copied to clipboard

Rendering fails using default java version (Eclipse OpenJ9)

Open Sabst opened this issue 5 years ago • 1 comments

Task List

  • [x] Steps to reproduce provided
  • [x] Example that reproduces the problem uploaded to Github
  • [x] Full description of the issue provided (see below)

Steps to Reproduce

Note: it might be easier for you to reproduce the problem using micronaut-views project tests but I will describe below how I discovered the issue trying to use Swagger UI

Create a docker container for a project using a template engine (Java version set by Micronaut)

The Java version is adoptopenjdk/openjdk11-openj9:jdk-11.0.1.13-alpine-slim)

Clone this project https://github.com/aruld/maps-app.git (this is one of the public micronaut examples using Swagger UI as I do in my projects : I did not contribute to this one) and run it in a container:

cd maps-gateway/
chmod 755 gradlew
./gradlew build
docker build .
docker run -p 8080:8080 (...)

Then try to open the Swagger UI : http://localhost:8080/api

The page is empty. Look at its source code, it contains something like:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Swagger-ui</title>

    <link rel="icon" type="image/png" href="https://unpkg.com/[email protected]/favicon-32x32.png">
    <link rel="stylesheet" type="text/css" href="https://unpkg.com/[email protected]/swagger-ui.css">

    <script src="https://unpkg.com/[email protected]/swagger-ui-standalone-preset.js"></script>
    <script src="https://unpkg.com/[email protected]/swagger-ui-bundle.js"></script>
</head>
<body>
<div id="swagger-ui"></div>
<script>
        window.onload = function() {
            var ui = SwaggerUIBundle({
                urls: [
                ],
                dom_id: '#swagger-ui',
                deepLinking: ,
                presets: [
                    SwaggerUIBundle.presets.apis,
                    SwaggerUIStandalonePreset
                ],
                plugins: [
                    SwaggerUIBundle.plugins.DownloadUrl
                ],
                layout: ""
            });
            window.ui = ui
        }
    </script>
</body>
</html>

As you see, some template variables have been taken into account (version) but most have been ignored (deepLinking, urls...).

Same test as before but using Java 8

Follow the previous steps using Java 8 (change the FROM in the Dockerfile to, say, adoptopenjdk/openjdk8:alpine-slim).

In that case, Swagger UI is displayed correctly.

Using other java template engines

I initially thought the problem was in the java template library itself (handlebars.java) but the problem still appears using for example Apache velocity

Expected Behaviour

The template variables should be correctly substituted and the resulting page (swagger UI here) should appear whatever the supported Java version is.

Actual Behaviour

The display of the page fails with the default JDK as some variables are not substituted in the template

Environment Information

  • Operating System: Linux mint 19.1
  • Micronaut Version: 1.1.0 (same issue with 1.1.3 and 1.2.0.RC1)
  • JDK Version: 9

Example Application

https://github.com/aruld/maps-app.git

Sabst avatar Jun 24 '19 14:06 Sabst

I had the same problem. I had to annotate my model bean with @Introspected to make it work with openj9.

Looks like the problem is in BeanMap.of: https://github.com/micronaut-projects/micronaut-views/blob/1234b6f27961267c6e52f9fee5c69359182c8fda/views-core/src/main/java/io/micronaut/views/ViewsRenderer.java#L86

croudet avatar Sep 23 '19 18:09 croudet