Error due to older Groovy version

Error due to older Groovy version

Hi,I have code in a tGroovy component which requires a more recent version of Groovy than is provided in Talend. Specifically, there is a missing property 'mkp' in the class MarkupBuilder which is loaded from groovy-1.0.jar. I tested the same script in a recent Groovy version, where it works. Then I installed a more recent version of Talend (5.2.2), to find out it uses the same Groovy version. Next I thought about replacing the jar file, however this got me into deeper trouble. Any advice?Kind regards,Yves

Re: Error due to older Groovy version

To be a bit more specific:As can be seen in the TOS install dir, the Groovy version is quite recent:\plugins\org.codehaus.groovy_1.8.6.xx-20120301-1300-e36-RELEASE\However, my Groovy code is in a tGroovy component, and the tGroovy component depends on the file groovy-1.0.jar in the tGroovyFile component. When this jar is replaced by one which is more recent, errors occur when building the script ("groovy-1.0.jar is missing" etc.)Is there any way of fixing this?Thanks,Yves

Re: Error due to older Groovy version

Hi yvest, There is an issue reported on talend bug tracker: https://jira.talendforge.org/browse/TDI-24781. Our developer will make a research on it and give the response asap, thanks for your suggestion.In addition, I have a solution for your issue. Download the new version jar and rename the jar as "Groovy-1.0.jar", and then replace the old one, try it and let me know if it works?Best regardsSabrina

--Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.

Re: Error due to older Groovy version

Hi Sabrina,Many thanks for your response. I had tried already your suggestion of taking a recent jar and renaming it, however other problems arose (in the generated java code for the tGroovy component, the GroovyShell.evaluate() method which accepts an InputStream was first deprecated and has subsequently been removed; hence the code won't compile). For now, I have worked around the issue by using tSystem and executing the script in the Groovy SDK on my system. However this is a rather ugly and non-portable solution, which I will surely fix as soon as Talend adapts the most recent Groovy version.Best regards,Yves

Re: Error due to older Groovy version

Hi,

however other problems arose (in the generated java code for the tGroovy component, the GroovyShell.evaluate() method which accepts an InputStream was first deprecated and has subsequently been removed; hence the code won't compile).

Thanks for your feedback, I will make a research on this problem, hope there will be a solution for it. In addition, I'm tracing this bug and give you a notification when it has been fixed.Best regardsSabrina

--Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.

Re: Error due to older Groovy version

Hi,

Many thanks for your response. I had tried already your suggestion of taking a recent jar and renaming it, however other problems arose (in the generated java code for the tGroovy component, the GroovyShell.evaluate() method which accepts an InputStream was first deprecated and has subsequently been removed; hence the code won't compile).

Maybe the jar is not refreshed, try to delete the component cache file and restart Talend Studio, to do:1. Go to <Talend Studio installation path>/configuration/ the delete the file ComponentsCache.javacache. 2. Restart Talend Studio, the file ComponentsCache.javacache" file will be created again.Let me know if it works?Best regardsSabrina

--Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.

Re: Error due to older Groovy version

Hi Rebecca,I did that, and - having Groovy-2.1.1.jar renamed to Groovy-1.0.jar - compilation now failed because the generated java code still has a dependency on a Groovy 1.0 method which is no longer in Groovy 2.1.1. Here is the excerpt:String codetGroovy_1 = "my groovy script";java.io.ByteArrayInputStream istGroovy_1 = new java.io.ByteArrayInputStream(codetGroovy_1.getBytes());groovy.lang.Binding bindingtGroovy_1 = new groovy.lang.Binding();bindingtGroovy_1.setVariable("i2b2DataDir", context.i2b2DataDir);groovy.lang.GroovyShell shelltGroovy_1 = new groovy.lang.GroovyShell(bindingtGroovy_1);shelltGroovy_1.evaluate(istGroovy_1); // >>> compilation fails here <<<The method GroovyShell.evaluate(InputStream) was deprecated in Groovy 1.8, and later removed from the API. One possible solution would be to use the method GroovyShell.evaluate(String) instead, and pass codetGroovy_1 to it. Best regards,Yves

Re: Error due to older Groovy version

Yes this is an issue which can only be solved by creating a new component as copy of the existing one. I suggest doing that and rename the new component tGroovy2.The component designer allows to copy an existing component and modify it. I already did that in for a missing feature in the LDAP components.

Re: Error due to older Groovy version

This topic lives on at TDI-33821Now, there are incompatibilities between the Ancient Groovy 1.0 (Used on TOS DI 6.1.x) and Java 1.8.If interested, please see the JIRA which has my attached changes to tGroovy to be compatible with Java 1.8 and upgrade Groovy itself.I believe the right approach to use this is as follows:* make a custom component out of the modified tGroovy* Switch jobs to use the revised version* Talend to integrate the fix and Groovy version upgrade* Upon that fix being included in the talend release, switch Jobs back over to using the official talend component