You are not logged in.
I currently have many groovy scripts with commonalities between them, but am having difficulty refactoring these parts into say a helper file.
I created a folder with my helper file. In the helper file, I simply define the package as `package folder_name` and a static variable containing some text. However, when I try to import the variable using `import static folder_name.Class.variable`, I run into an error saying:
The report could not be executed: net.datenwerke.rs.scripting.service.scripting.exceptions.ScriptEngineException: javax.script.ScriptException: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: ...unable to resolve class...
Would anyone happen to know how to import variables or methods from other files into groovy scripts? Thanks in advance!
Offline
Offline
Will do, thank you Eduardo!
Offline
Hi, I have tried following the example in the documentation here: https://reportserver.net/en/guides/scri … m-Scripts/
Just to share, in case anyone else is running into issues, there are two bugs in the sample code:
1. lib.groovy (line 11): return encrypt(ciphertext, (27 - k)
is missing a closing bracket, it should be: return encrypt(ciphertext, (27 - k))
2. encryptionTest.groovy (line 9): tout.println(dec(cipher, key))
is using the wrong method name, it should be: tout.println(dec(cipher, key))
Note also that the filename for the encryption test is encryptionTest.groovy, not encryptionTest.rs, as it is described in the documentation explanation part.
Offline
pls take a look here: https://reportserver.net/en/guides/scri … m-Scripts/
May I check if this solution is supposed to work when executing reports via "Administration > Reports" instead of through the terminal? I can execute my script successfully through the terminal, but when executing reports by right clicking on them and clicking "Execute", the library file cannot seem to be found:
Error: The report could not be executed: net.datenwerke.rs.scripting.service.scripting.exceptions.ScriptEngineException: javax.script.ScriptException: java.lang.RuntimeException: net.datenwerke.rs.terminal.service.terminal.vfs.exceptions.LocationDoesNotExistException: filesystem not found: lib.groovy ------- SCRIPT ERROR INFO ------- Script execution failed. error message: javax.script.ScriptException: java.lang.RuntimeException: net.datenwerke.rs.terminal.service.terminal.vfs.exceptions.LocationDoesNotExistException: filesystem not found: lib.groovy (java.lang.RuntimeException) script arguments: file: encryptionTest.groovy (id: 6234537, line 1) line number: 1 line: GLOBALS.exec("lib.groovy")
I tried running my script in the terminal with my working directory as the home directory, and found that the same error also occurred. If I were to change to the directory where the scripts are stored, then they execute fine via the terminal. How could I fix this issue? Thank you!
Offline
In hindsight, I might have been unclear in my forum topic title: For context, I am trying to use Groovy scripts for Script Reporting, so I am trying to execute reports linked to Groovy scripts, rather than executing Groovy scripts by themselves. Hope this makes more sense!
Offline
Another alternative I am considering is using the registry in the GLOBALS object: https://reportserver.net/en/guides/scri … n-Scripts/
However, this seems like an overkill. Does anyone know of a simpler solution? Thank you!
Offline
Hi Johann,
we will check the documentation issues you mention and correct them.
You can use GLOBALS.exec("lib.groovy") as documented here https://reportserver.net/en/guides/scri … m-Scripts/ and you mentioned here: https://forum.reportserver.net/viewtopi … 9499#p9499
Regards,
Eduardo
Offline
Got it, thank you!
Offline
Hi Johann,
note that we corrected the online documentation issues you mentioned.
Regards,
Eduardo
Offline
Hi Eduardo,
Thank you for the update!
Regards,
Johann
Offline