Project: talendesb
Issue TESB-6240: Class-loading issues when Talend routes invoke groovy script
From user perspective, expected that route can add those dependencies automatically when we use groovy language. 1. Created a route with studio which uses groovy as script language 2. Exported and deployed the kar file into a container. 3. When the route invokes the groovy script, a classloading exception occurs: Caused by: java.lang.ClassNotFoundException: groovy.lang.Script at java.net.URLClassLoader$1.run(URLClassLoader.java:200)[:1.6.0_11] at java.security.AccessController.doPrivileged(Native Method)[:1.6.0_11] at java.net.URLClassLoader.findClass(URLClassLoader.java:188)[:1.6.0_11] at java.lang.ClassLoader.loadClass(ClassLoader.java:307)[:1.6.0_11] at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:696)[177:groovy-all:1.8.6] at groovy.lang.GroovyClassLoader$InnerLoader.loadClass(GroovyClassLoader.java:449) at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:805)[177:groovy-all:1.8.6] at java.lang.ClassLoader.loadClass(ClassLoader.java:252)[:1.6.0_11] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)[:1.6.0_11] ... 51 more 4. when edit MANIFEST.MF in this route kar file, manually add the below package into Import-Package, then update this route, it would work well. Required 5 packages for groovy language: groovy.lang org.codehaus.groovy.runtime org.codehaus.groovy.runtime.callsite org.codehaus.groovy.runtime.typehandling org.codehaus.groovy.reflection BTW, in this attachment model, we must add camel groovy dependencies in advanced settings of component cMessagingEndpoint_1, if only select language "Groovy" in basic settings of the component "cMessageFilter_1", then run this model, will throw the below exception. {noformat} Failed to create route cMessagingEndpoint_1 at: >>> Filter[groovy{['Ta', 'len', 'd', 'Route'].grep { elem -> elem.length() < 5 }.size() == 3} -> [Choice[[When[groovy{['a', 'b', 'c'].sum() == 'abc'} -> [To[direct:a]]]] Otherwise[[To[direct:b]]]]]] <<< in route: Route[[From[dataset://GroovyTestRoute20120618]] -> [Filter[g... because of No language could be found for: groovy org.apache.camel.FailedToCreateRouteException: Failed to create route cMessagingEndpoint_1 at: >>> Filter[groovy{['Ta', 'len', 'd', 'Route'].grep { elem -> elem.length() < 5 }.size() == 3} -> [Choice[[When[groovy{['a', 'b', 'c'].sum() == 'abc'} -> [To[direct:a]]]] Otherwise[[To[direct:b]]]]]] <<< in route: Route[[From[dataset://GroovyTestRoute20120618]] -> [Filter[g... because of No language could be found for: groovy org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:873) org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:171) org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:722) org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:1789) org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1575) org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1444) org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60) org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1412) mfshen20121023.groovytestroute20120618_0_4.GroovyTestRoute20120618.doStart(GroovyTestRoute20120618.java:179) org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60) org.apache.camel.main.MainSupport.run(MainSupport.java:141) mfshen20121023.groovytestroute20120618_0_4.GroovyTestRoute20120618.runJobInTOS(GroovyTestRoute20120618.java:365) mfshen20121023.groovytestroute20120618_0_4.GroovyTestRoute20120618.main(GroovyTestRoute20120618.java:305) Caused by: org.apache.camel.NoSuchLanguageException: No language could be found for: groovy org.apache.camel.impl.DefaultLanguageResolver.noSpecificLanguageFound(DefaultLanguageResolver.java:101) org.apache.camel.impl.DefaultLanguageResolver.resolveLanguage(DefaultLanguageResolver.java:80) org.apache.camel.impl.DefaultCamelContext.resolveLanguage(DefaultCamelContext.java:989) org.apache.camel.model.language.ExpressionDefinition.createPredicate(ExpressionDefinition.java:154) org.apache.camel.model.language.ExpressionDefinition.createPredicate(ExpressionDefinition.java:143) org.apache.camel.model.ExpressionNode.createPredicate(ExpressionNode.java:120) org.apache.camel.model.ExpressionNode.createFilterProcessor(ExpressionNode.java:110) org.apache.camel.model.WhenDefinition.createProcessor(WhenDefinition.java:77) org.apache.camel.model.ChoiceDefinition.createProcessor(ChoiceDefinition.java:137) org.apache.camel.model.ProcessorDefinition.createOutputsProcessor(ProcessorDefinition.java:382) org.apache.camel.model.ProcessorDefinition.createOutputsProcessor(ProcessorDefinition.java:130) org.apache.camel.model.ProcessorDefinition.createChildProcessor(ProcessorDefinition.java:149) org.apache.camel.model.FilterDefinition.createFilterProcessor(FilterDefinition.java:72) org.apache.camel.model.FilterDefinition.createProcessor(FilterDefinition.java:66) org.apache.camel.model.FilterDefinition.createProcessor(FilterDefinition.java:34) org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:441) org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:179) org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:870)	... 12 more {noformat} Actually, when user just select language "Groovy", then it should work as expected.
Story points: 1