Search code examples
pythondockerspring-bootjava-8jython

Python ScriptEngine null on docker image


I have a normal spring boot app deployed on docker. The ScriptEngine works properly if app started normally or deployed on tomcat. But if I start it on docker the scriptEngine instance is returned null. Any idea?

ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
scriptEngine = scriptEngineManager.getEngineByName("python");  // returns null

Solution

  • Turns out that the jython library needs to be unpacked for docker from the spring boot application. Following configuration in maven makes it work on docker as well.

    <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <configuration>
            <requiresUnpack>
                <dependency>
                    <groupId>org.python</groupId>
                    <artifactId>jython-standalone</artifactId>
                </dependency>
            </requiresUnpack>
        </configuration>
    </plugin>