Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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
Labels (2)
12 Replies
Anonymous
Not applicable
Author

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
Anonymous
Not applicable
Author

Any one? I find this dependency on groovy-1.0.jar quite odd, frankly...
(full path: \plugins\org.talend.designer.components.localprovider_5.2.2.r99271\components\tGroovyFile)
Thanks,
Yves
Anonymous
Not applicable
Author

To continue my monologue :-)... (I do hope someone is listening out there)
So it turns out Talend uses Groovy v1.0, despite of - and as mentioned earlier - the plugin which suggests Groovy v.1.8.6
In my script: println org.codehaus.groovy.runtime.InvokerHelper.getVersion()
Any plans to update the tGroovy (and tGroovyFile) components to a recent Groovy version?
Thanks,
Yves
Anonymous
Not applicable
Author

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 regards
Sabrina
0683p000009MDh7.png
Anonymous
Not applicable
Author

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
Anonymous
Not applicable
Author

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 regards
Sabrina
Anonymous
Not applicable
Author

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 regards
Sabrina
0683p000009MDsD.png
Anonymous
Not applicable
Author

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
Anonymous
Not applicable
Author

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.