ist-dresden / composum-nodes

Set of Apache Sling / AEM development tools: JCR browser, user and package management and more
https://www.composum.com/home/nodes.html
MIT License
55 stars 21 forks source link

Composum does not work with Java 9 #114

Closed rombert closed 6 years ago

rombert commented 7 years ago

I'm doing some basic tests with Java 9 and Sling. One of the issues we have is that composum does not work, see SLING-7134.

The root cause is that with Java 9 Nashorn is registered by default as a javax.scripting.ScriptEngine, which makes it available to executing scripts.

In Composum's case, when trying to include a resource of type composum/nodes/console/components/codeeditor, both codeeditor.js and codeeditor.jsp are found and the JS one is selected.

The simple solution here would be to make sure that client-side and server-side files don't mix. We discovered this when testing with Java 9, but anyway using a scripting engine registered for js files would have the same issue.

If you think that there are other solutions, feel free to discuss on SLING-7134.

rombert commented 7 years ago

I created a small shell script to to detect script conflicts:

#!/bin/sh

for jsp in $(find -name '*.jsp'); do
    js=${jsp%jsp}js

    if [ -e $js ]; then
        echo "WARN Found both js and jsp scripts in $(dirname $js): $(basename $jsp) $(basename $js)"
    fi
done

It only detected 6 conflicts:

WARN Found both js and jsp scripts in ./sling/core/console/src/main/resources/root/libs/composum/nodes/console/browser/components/favorites: favorites.jsp favorites.js
WARN Found both js and jsp scripts in ./sling/core/console/src/main/resources/root/libs/composum/nodes/console/components/codeeditor: codeeditor.jsp codeeditor.js
WARN Found both js and jsp scripts in ./sling/core/pckgmgr/src/main/resources/root/libs/composum/nodes/pckgmgr/jcrpckg/coverage: coverage.jsp coverage.js
WARN Found both js and jsp scripts in ./sling/core/pckgmgr/src/main/resources/root/libs/composum/nodes/pckgmgr/jcrpckg/filter: filter.jsp filter.js
WARN Found both js and jsp scripts in ./sling/core/pckgmgr/src/main/resources/root/libs/composum/nodes/pckgmgr/jcrpckg/general: general.jsp general.js
WARN Found both js and jsp scripts in ./sling/core/pckgmgr/src/main/resources/root/libs/composum/nodes/pckgmgr/jcrpckg/options: options.jsp options.js

A quick hack of appending an underscore to the file names and updating the client libraries fixed composum for me on Java 9. Since this does not look like a very big issue it whould be great if this would be considered for the 1.9 release so we can pick it it up for Sling 10 which will feature Java 9 compatibility.

ist-rw commented 7 years ago

Thanks a lot. I've pushed all changes to fix this issue. I've tested it on an instances running on Java 9 sucessfully.

rombert commented 7 years ago

Great news, thank you.