You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@johnzon.apache.org by "MathisGuillet1 (via GitHub)" <gi...@apache.org> on 2023/12/19 10:07:27 UTC

[PR] Add nashorn engine dependency in compiled scope for Java 15+ [johnzon]

MathisGuillet1 opened a new pull request, #116:
URL: https://github.com/apache/johnzon/pull/116

   When trying to bump my application to Java 17, I faced issues with johnzon json-schema module.
   
   As explained here https://stackoverflow.com/questions/71481562/use-javascript-scripting-engine-in-java-17 the nashorn javascript engine is removed starting jdk 15.
   
   Here is the error I faced with JDK 17 :
   
   `java.lang.NullPointerException: Cannot invoke "javax.script.ScriptEngine.createBindings()" because "org.apache.johnzon.jsonschema.regex.JavascriptRegex.ENGINE" is null`
   
   Adding nashorn dependency in my application fixes the issue, but it is tricky to discover what gone wrong, so I suggest taking care of it here.
   
   See here for the NullPointerException origin : https://github.com/apache/johnzon/blob/885cec0ef9484c3666c82315826143045f1c492a/johnzon-jsonschema/src/main/java/org/apache/johnzon/jsonschema/regex/JavascriptRegex.java#L32


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@johnzon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add nashorn engine dependency in compiled scope for Java 15+ [johnzon]

Posted by "rmannibucau (via GitHub)" <gi...@apache.org>.
rmannibucau commented on PR #116:
URL: https://github.com/apache/johnzon/pull/116#issuecomment-1863406152

   To be honest I always disable it to use java implementation, default is just more jsonschema friendly (java impl requires some constraints on the regex forms)
   
   But clearly not an option to make it transitive by default, in particular cause there are other js impl (thinking to graal one) so we just respect the constract and user picks its impl if he uses js regexes.
   
   hope it makes sense


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@johnzon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add nashorn engine dependency in compiled scope for Java 15+ [johnzon]

Posted by "jungm (via GitHub)" <gi...@apache.org>.
jungm commented on PR #116:
URL: https://github.com/apache/johnzon/pull/116#issuecomment-1863377390

   I think I'd prefer if johnzon would be more user friendly on this (explain in docs, and maybe log a warning/error when running on jdk >=15 and no ScriptEngine is available for js) instead of forcing a transient dependency like openjdk nashorn onto every user. They might be on an older jdk where this simply isn't needed or user prefers some other impl
   
   another idea I have would be to make a "batteries included" johnzon-jsonschema-java15 module that has both johnzon-jsonschema and nashorn as dependencies. But I really doubt if this would be worth it 
   
   wdyt? @rmannibucau @jeanouii 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@johnzon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add nashorn engine dependency in compiled scope for Java 15+ [johnzon]

Posted by "rmannibucau (via GitHub)" <gi...@apache.org>.
rmannibucau commented on PR #116:
URL: https://github.com/apache/johnzon/pull/116#issuecomment-1866083536

   I'm fine moving `new ScriptEngineManager().getEngineByName("javascript");` in the constructor instead of static (does not bring much) and to throw an exception if null


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@johnzon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add nashorn engine dependency in compiled scope for Java 15+ [johnzon]

Posted by "MathisGuillet1 (via GitHub)" <gi...@apache.org>.
MathisGuillet1 commented on PR #116:
URL: https://github.com/apache/johnzon/pull/116#issuecomment-1866074941

   Ok, let's close this, maybe just a log would help users with JDK15+ to figure out that they are missing an engine dependency


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@johnzon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add nashorn engine dependency in compiled scope for Java 15+ [johnzon]

Posted by "MathisGuillet1 (via GitHub)" <gi...@apache.org>.
MathisGuillet1 closed pull request #116: Add nashorn engine dependency in compiled scope for Java 15+
URL: https://github.com/apache/johnzon/pull/116


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@johnzon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org