Using easy-captcha verification code appears javax.script ScriptEngine.eval(String)" because "engine" is nul

1. Questions

The java project uses ArithmeticCaptcha verification code, and javax.script ScriptEngine.eval(String)" because "engine" is null appears

ArithmeticCaptcha captcha = new ArithmeticCaptcha(111, 36);
<dependency>
    <groupId>com.github.whvcse</groupId>
    <artifactId>easy-captcha</artifactId>
    <version>1.6.2</version>
</dependency>

2. Problem analysis

The built-in JavaScript engine in Jdk8 nashornwas removed, resulting in an error when using the verification codeCannot invoke "javax.script.ScriptEngine.eval(String)" because "engine" is null

com.github.whvcse包的easy-captchaThe verification code dependency is used in the project . After upgrading to Jdk17, the verification code interface reports an error: Cannot invoke "javax.script.ScriptEngine.eval(String)" because "engine" is null,

The cause of the error is obvious. The script engine executes the script statement and reports an error because the execution engine is empty.

Query relevant information The JavaScript engine that comes with Jdk8 nashornwas removed after upgrading to Jdk9, resulting in an error

3. Solutions

Add JavaScript engine dependencies to the pom file nashornand restart the project

<dependency>
    <groupId>org.openjdk.nashorn</groupId>
    <artifactId>nashorn-core</artifactId>
    <version>15.4</version>
</dependency>

 

Guess you like

Origin blog.csdn.net/liyh722/article/details/131479181