Uploaded image for project: 'Karaf'
  1. Karaf
  2. KARAF-3335

Endorsed org.apache.karaf.exception-3.0.2 jar causes issues with Java 8 Nashorn scripts

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.0.2
    • 3.0.3, 2.4.1, 4.0.0.M2, 4.0.0.M3
    • None
    • None

    Description

      I have been trying to get our application up and running within Karaf-3.0.2, and have run into an issue with the exception-3.0.2 jar within the lib/endorsed folder. Our application relies heavily on Nashorn scripts, and these scripts will no longer run.

      When executing the following code, an exception is generated and the script fails to execute:

      Nashorn Script
      topic.modify(function(s) {
          s.roleList.add().userRoleKey = 1;
      });
      
      Java code

      The topic variable above is an instance of ModificationContext

      class ModificationContext
      {
          public <S extends DataObject> ModificationContext modify(Consumer<S> consumer)
          {
              ... //the contents here are unimportant, as it never actually gets this far
          }
      }
      
      Stack Trace
      java.lang.NoSuchMethodError: java.lang.Exception: method <init>(Ljava/lang/String;Ljava/lang/Throwable;ZZ)V not found
              at java.lang.RuntimeException.<init>(RuntimeException.java:117)
              at jdk.internal.dynalink.support.TypeConverterFactory$NotCacheableConverter.<init>(TypeConverterFactory.java:379)
              at jdk.internal.dynalink.support.TypeConverterFactory.createConverter(TypeConverterFactory.java:370)
              at jdk.internal.dynalink.support.TypeConverterFactory$1$1.computeValue(TypeConverterFactory.java:120)
              at jdk.internal.dynalink.support.TypeConverterFactory$1$1.computeValue(TypeConverterFactory.java:116)
              at jdk.internal.dynalink.support.ClassMap.get(ClassMap.java:150)
              at jdk.internal.dynalink.support.TypeConverterFactory.getCacheableTypeConverter(TypeConverterFactory.java:330)
              at jdk.internal.dynalink.support.TypeConverterFactory.getCacheableTypeConverterNull(TypeConverterFactory.java:317)
              at jdk.internal.dynalink.support.TypeConverterFactory.getTypeConverterNull(TypeConverterFactory.java:323)
              at jdk.internal.dynalink.support.TypeConverterFactory.asType(TypeConverterFactory.java:224)
              at jdk.internal.dynalink.support.LinkerServicesImpl.asType(LinkerServicesImpl.java:126)
              at jdk.nashorn.internal.runtime.linker.NashornBeansLinker$NashornBeansLinkerServices.asType(NashornBeansLinker.java:84)
              at jdk.internal.dynalink.beans.SingleDynamicMethod.createConvertingInvocation(SingleDynamicMethod.java:289)
              at jdk.internal.dynalink.beans.SingleDynamicMethod.getInvocation(SingleDynamicMethod.java:189)
              at jdk.internal.dynalink.beans.SingleDynamicMethod.getInvocation(SingleDynamicMethod.java:132)
              at jdk.internal.dynalink.beans.DynamicMethodLinker.getGuardedInvocation(DynamicMethodLinker.java:118)
              at jdk.internal.dynalink.beans.BeansLinker.getGuardedInvocation(BeansLinker.java:252)
              at jdk.nashorn.internal.runtime.linker.NashornBeansLinker.getGuardedInvocation(NashornBeansLinker.java:67)
              at jdk.nashorn.internal.runtime.linker.NashornBeansLinker.getGuardedInvocation(NashornBeansLinker.java:54)
              at jdk.internal.dynalink.support.CompositeGuardingDynamicLinker.getGuardedInvocation(CompositeGuardingDynamicLinker.java:124)
              at jdk.internal.dynalink.support.LinkerServicesImpl.getGuardedInvocation(LinkerServicesImpl.java:144)
              at jdk.internal.dynalink.DynamicLinker.relink(DynamicLinker.java:232)
              at jdk.nashorn.internal.scripts.Script$\^eval\_.runScript(<eval>:1)
              at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:498)
              at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:206)
              at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:378)
              at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:546)
              at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:528)
              at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:524)
              at jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:194)
              at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:233)
      

      If I remove the exception jar from the endorsed folder and run the same script, it executes correctly

      Attachments

        Activity

          People

            ffang Freeman Yue Fang
            Adam Davis Adam Davis
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: