justdb / jackson-dataformat-toml

jackson dataformat for toml
Apache License 2.0
2 stars 2 forks source link

Issue while creating toml file from java object using JDK 11 #9

Open swapnilgangrade01 opened 3 years ago

swapnilgangrade01 commented 3 years ago

Hi, I am facing issue while converting the Java Object to Toml file. Application is running on Java 11. Below is the exception. The code is working fine with Java 8. But not with Java 11. Please help.

IOException while creating file=/home/scan-service/policy.toml - [TypeError: [jdk.dynalink.beans.SimpleDynamicMethod String java.lang.String.repeat(int)] is not an Object in at line number 11020]

Below is my Code -

public void createTomlFile(TomlData tomlData) {
    TOMLMapper mapper = new TOMLMapper();
    String filePath = "/home/scan-service/policy.toml";
    try {
        mapper.writeValue(new File(filePath), tomlData);
    } catch (JsonParseException ex) {
        throw ex;
    } catch (JsonMappingException ex) {
       throw ex;
    } catch (IOException ex) {
       throw ex;
    }
}
swapnilgangrade01 commented 3 years ago

Complete error stack -

Warning: Nashorn engine is planned to be removed from a future JDK release java.io.IOException: TypeError: [jdk.dynalink.beans.SimpleDynamicMethod String java.lang.String.repeat(int)] is not an Object in at line number 11020 at com.teesoft.jackson.dataformat.toml.TOMLOutputDecorator$1.close(TOMLOutputDecorator.java:51) at com.fasterxml.jackson.core.json.UTF8JsonGenerator.close(UTF8JsonGenerator.java:1216) at com.fasterxml.jackson.databind.ObjectMapper.writeValueAndClose(ObjectMapper.java:4414) at com.fasterxml.jackson.databind.ObjectMapper.writeValue(ObjectMapper.java:3604) at com.nvidia.scan.services.model.Policy.Testing.tomlTesting(Testing.java:29) at com.example.asyncmethod.AppRunner.run(AppRunner.java:34) at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:804) at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:788) at org.springframework.boot.SpringApplication.run(SpringApplication.java:333) at com.example.asyncmethod.AsyncMethodApplication.main(AsyncMethodApplication.java:17) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) at org.springframework.boot.loader.Launcher.launch(Launcher.java:107) at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88) Caused by: javax.script.ScriptException: TypeError: [jdk.dynalink.beans.SimpleDynamicMethod String java.lang.String.repeat(int)] is not an Object in at line number 11020 at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(Unknown Source) at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(Unknown Source) at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(Unknown Source) at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(Unknown Source) at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.eval(Unknown Source) at java.scripting/javax.script.AbstractScriptEngine.eval(Unknown Source) at com.teesoft.jackson.dataformat.toml.TOMLOutputDecorator.createTOML2SJONInterface(TOMLOutputDecorator.java:95) at com.teesoft.jackson.dataformat.toml.TOMLOutputDecorator.getTomlInterface(TOMLOutputDecorator.java:77) at com.teesoft.jackson.dataformat.toml.TOMLOutputDecorator$1.close(TOMLOutputDecorator.java:46) ... 17 more Caused by: :11020 TypeError: [jdk.dynalink.beans.SimpleDynamicMethod String java.lang.String.repeat(int)] is not an Object at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ECMAErrors.error(Unknown Source) at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ECMAErrors.typeError(Unknown Source) at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ECMAErrors.typeError(Unknown Source) at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ECMAErrors.typeError(Unknown Source) at jdk.scripting.nashorn/jdk.nashorn.internal.objects.Global.checkObject(Unknown Source) at jdk.scripting.nashorn/jdk.nashorn.internal.objects.NativeObject.defineProperty(Unknown Source) at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$408$433726AAA$\^eval_.L:10916#defineProperty(:11020) at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$106$171760AAA$\^eval_.L:4457#exports(:4463) at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$155$239004AAAA$\^eval_.L:6226#exports(:6248) at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$671$182902AA$\^eval_.L:4709#exports(:4761) at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$1148$406913AAA$\^eval_$cu1$restOf.L:10393(:10399) at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(Unknown Source) at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptFunction.invoke(Unknown Source) at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptRuntime.apply(Unknown Source) at jdk.scripting.nashorn/jdk.nashorn.internal.objects.NativeFunction.call(Unknown Source) at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$30$30AA$\^eval_.L:1#r#o(:1) at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$31$279A$\^eval_.L:1#r#o#L:1(:1) at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$22$98594AAAAAAA$\^eval_.L:2806(:2889) at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$20$30AA$\^eval_.L:1#r#o(:1) at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$18$279A$\^eval_.L:1#r#o#L:1(:1) at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$21$524636AAAAAAA$\^eval_.L:13389(:13390) at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$20$30AA$\^eval_$cu1$restOf.L:1#r#o(:1) at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$18$279A$\^eval_.L:1#r#o#L:1(:1) at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$17$464AAAAAAA$\^eval_.L:1-1(:4) at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$16$30IA$\^eval_$cu1$restOf.L:1#r#o(:1) at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$14$12AAA$\^eval_.L:1#r(:1) at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$11$\^eval\.:program(:1) at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(Unknown Source) at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptFunction.invoke(Unknown Source) at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptRuntime.apply(Unknown Source) ... 25 more