Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-4171

Groovy language - classNotFoundException in OSGi environment

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    Description

      The problem is in the following method of the GroovyLanguage

      @SuppressWarnings("unchecked")
      protected Class<Script> parseExpression(String expression) {
      return new GroovyClassLoader().parseClass(expression);
      }

      It uses the default constructor to create GroovyClassLoader, which uses Thread context classloader, which may not be equal to the classloader of the bundle where the camel context is defined.

      Caused by: java.lang.NoClassDefFoundError: groovy/lang/Script
      at java.lang.ClassLoader.defineClass1(Native Method)[:1.6.0_24]
      at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)[:1.6.0_24]
      at java.lang.ClassLoader.defineClass(ClassLoader.java:616)[:1.6.0_24]
      at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)[:1.6.0_24]
      at groovy.lang.GroovyClassLoader.access$300(GroovyClassLoader.java:55)
      at groovy.lang.GroovyClassLoader$ClassCollector.createClass(GroovyClassLoader.java:519)
      at groovy.lang.GroovyClassLoader$ClassCollector.onClassNode(GroovyClassLoader.java:536)
      at groovy.lang.GroovyClassLoader$ClassCollector.call(GroovyClassLoader.java:540)
      at org.codehaus.groovy.control.CompilationUnit$11.call(CompilationUnit.java:747)
      at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:932)
      at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:509)
      at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:487)
      at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:464)
      at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:306)
      at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:287)
      at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:267)
      at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:214)
      at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:224)
      at org.apache.camel.language.groovy.GroovyLanguage.parseExpression(GroovyLanguage.java:44)
      at org.apache.camel.language.groovy.GroovyLanguage.createExpression(GroovyLanguage.java:38)
      at org.apache.camel.language.groovy.GroovyLanguage.createExpression(GroovyLanguage.java:27)
      at org.apache.camel.component.language.LanguageProducer.process(LanguageProducer.java:41)[68:org.apache.camel.camel-core:2.6.0.fuse-01-09]
      at org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorTypeConverter.java:50)[68:org.apache.camel.camel-core:2.6.0.fuse-01-09]
      ... 92 more
      Caused by: java.lang.ClassNotFoundException: groovy.lang.Script
      at java.net.URLClassLoader$1.run(URLClassLoader.java:202)[:1.6.0_24]
      at java.security.AccessController.doPrivileged(Native Method)[:1.6.0_24]
      at java.net.URLClassLoader.findClass(URLClassLoader.java:190)[:1.6.0_24]
      at java.lang.ClassLoader.loadClass(ClassLoader.java:307)[:1.6.0_24]
      at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:696)[134:groovy-all:1.7.5]
      at groovy.lang.GroovyClassLoader$InnerLoader.loadClass(GroovyClassLoader.java:449)
      at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:793)[134:groovy-all:1.7.5]
      at java.lang.ClassLoader.loadClass(ClassLoader.java:248)[:1.6.0_24]
      ... 115 more

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            davsclaus Claus Ibsen
            szhemzhitsky Sergey Zhemzhitsky
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment