Hey together,
so I'ld like to develop and automate some custom workflows and we're using Scriptrunner for this.
The configuration:
JIRA: 7.3.7
Scriptrunner: 5.0.4
Other plugins such as LabelManger
Developing and debugging over IDEA against a localhost-Installation
Now, so far it's working good but I'm having some general issues with importing other classes or plugins. Autocomplete works when the jar is referenced. However, when triggering the execution, it's always responding with "Unable to resolve class" for the external class. This is even the case for my own custom classes that're placed below the main script in the directory.
-MainScript +HelperDirectory +-HelperClass
Some exemplaric code I'm using:
... import com.onresolve.scriptrunner.runner.customisers.PluginModule import com.onresolve.scriptrunner.runner.customisers.WithPlugin import com.almworks.jira.structure.AllPublicStructureComponents // Specify that classes from this plugin should be available to this script @WithPlugin("com.almworks.jira.structure") // Inject plugin module @PluginModule AllPublicStructureComponents structureComponents
Note: I'm not sure if the documentation is outdated on that, but I can't find an actual "API" folder in the actual version of Structure.
I'm able to load at least my own classes with a construct like this but it's really uncomfortable and I'm loosing stuff like autocompletion:
File sourceFile = new File("D:\\Programming\\Idea\\ScholledevJIRAScriptrunner\\src\\main\\scholledev\\HelperClasses\\BBCodeBlockLibrary.groovy"); Class groovyClass = new GroovyClassLoader(getClass().getClassLoader()).parseClass(sourceFile); GroovyObject stringMapLibClass = (GroovyObject) groovyClass.newInstance();
Is this an actual issue with Scriptrunner or am I doing something fundamentally wrong?
Greetings Marcus
Hello Marcus.
Recently we have seen a few issues that relate to being unable to resolve a class from an outside plugin or jar. They have been solved by placing the "@WithPlugin" diretive as the latest import on your import list.
Can you try setting up your file imports like so:
... import com.onresolve.scriptrunner.runner.customisers.PluginModule import com.onresolve.scriptrunner.runner.customisers.WithPlugin import com.almworks.jira.structure.AllPublicStructureComponents // Inject plugin module @PluginModule AllPublicStructureComponents structureComponents // Specify that classes from this plugin should be available to this script @WithPlugin("com.almworks.jira.structure")
If this doesn't solve you issue let me know.
Cheers!
DYelamos
Thanks for your reply.
However, this does not help in my case.
Actually I don't think it's necessary an issue on Scriptrunners end.
I'm even unable to import one of my own classes that're residing in the same project.
To better visualize it, this is a screenshot of my project tree:
"BugTransitionMoreInfo" is my "Main class" in this context, where I would like to import "BBCodeBlockLibrary" into.
So the start of "BBCodeBlockLibrary looks like this:
package HelperClasses class BBCodeBlockLibrary {
Then I'm using this code to import my class in "BugTransitionMoreInfo".
import HelperClasses.BBCodeBlockLibrary
Autocompletion works this way (so I'm seeing the corresponding methods and stuff) in my main class. However, when executing this in JIRA, all the times I'm getting "Unable to resolve class".
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Marcus,
Did you add the directory to your script roots?
If not, you can find this community question in which Jamie Echlin explains how to set this up properly. If this does not help you, please let me know.
Cheers
Dyelamos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Daniel
I am facing the similar issue getting below error while adding new issue to the structure.
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'com.almworks.jira.structure.AllPublicStructureComponents@16b28350' with class 'com.almworks.jira.structure.AllPublicStructureComponents' to class 'com.almworks.jira.structure.api.StructureComponents'
Above error gets resolved on using
import com.onresolve.scriptrunner.runner.customisers.PluginModule import com.onresolve.scriptrunner.runner.customisers.WithPlugin import com.almworks.jira.structure.AllPublicStructureComponents // Inject plugin module @PluginModule AllPublicStructureComponents structureComponents // Specify that classes from this plugin should be available to this script @WithPlugin("com.almworks.jira.structure")
But, error occurs for RowManager.
Versions currently used are
Structure verison : 5.4.0
Script runner version : 5.5.7
JIRA Server version : 7.10.1
Any help would be appreciated.
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm facing the same issue with my own plugin module component that I'd like to use in scriptrunner scripts. I know it's something to do with ClassLoaders, yet can't understand how to overcome it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We have the same issue as @Dennis Alexander
Does anyone know anything further?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've actually has resolved this.
The problem I had was that the interface was described as groovy interface.
So now I have interface described as java and implementation as groovy.
I was able to resolve this by:
1. Describe interface as Java Interface
2. add java folder to the source folder
<!-- We add java source files to the build -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/main/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
3. replace gmavenplus complier
<!-- And we switch off the standard gmaven compiler -->
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<executions>
<execution>
<phase>none</phase>
</execution>
</executions>
</plugin>
with
groovy-eclipse-compiler
<!-- We install and configure Groovy Eclipse Compiler -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerId>groovy-eclipse-compiler</compilerId>
<compilerArguments>
<indy/><!-- optional; supported by batch 2.4.12-04+ -->
<!--<configScript>config.groovy</configScript>--><!-- optional; supported by batch 2.4.13-02+ -->
</compilerArguments>
<failOnWarning>true</failOnWarning><!-- optional; supported by batch 2.5.8-02+ -->
<fork>true</fork><!-- optional; enables Parrot Parser by default for Groovy 3+ -->
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>3.9.0</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-batch</artifactId>
<version>3.0.8-01</version>
</dependency>
</dependencies>
</plugin>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.