Scripted JQL Function failed to load/compile

After upgrading to JIRA 6.3.1 and Script Runner 3.0.1, our scripted JQL functions are failing to load.

We've reviewed the document on breaking changes in 3.0 and attempted to migrate the scripts. After scanning, a tooltip/popup says no additional scripts are added, and in the atlassian-jira.log we see an entry that the script file(s) 'failed to load/compile' with no additional detail.

As a test, we tried to create a function that does only returns null following the example provided (ABC.groovy), with no change.

Is there any undocumented gotches to the new format, or anything we can do to improve the debugging information on WHY it failed to load?

Any ideas would be appreciated, thanks.

package com.onresolve.jira.groovy.jql

import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.jql.query.QueryCreationContext
import com.atlassian.jira.util.MessageSet
import com.atlassian.query.clause.TerminalClause
import com.atlassian.query.operand.FunctionOperand
import org.apache.lucene.search.Query

class JQLTEST extends AbstractScriptedJqlFunction implements JqlQueryFunction{
	@Override
	String getDescription() {
		"test JQL function"
	}
	
	@Override
	List<Map> getArguments() {
		[]
	}
	
	@Override
	String getFunctionName() {
		"testJQL"
	}
	
	def String subquery
	@Override
	MessageSet validate(User user, FunctionOperand operand, TerminalClause terminalClause) {
		null
	}
	
	@Override
	Query getQuery(QueryCreationContext queryCreationContext, FunctionOperand operand, TerminalClause terminalClause) {
		null
	}
}

1 answer

1 accepted

0 vote

First of all it's good that you are trying a stubbed class.

It's no good that the compilation error is not shown, I raised https://jamieechlin.atlassian.net/browse/GRV-476.

I tried the class you posted and it compiled and was added. Have you tried with that exact class? Is it in the correct directory under your script root? eg

<jira_home>/scripts/com/onresolve/jira/groovy/jql/JQLTEST.groovy

Thanks Jamie. The text was an exact copy/paste of the contents of the file, I believe it is in the location you refer to. Here's the later part of the one entry we do get in the log file for that particular test script:

C:\Program Files\Atlassian\Application Data\JIRA\scripts\com\onresolve\jira\groovy\jql\JQLTEST.groovy failed to load/compile

We also added a different location to the scripts path as you described in the documentation, so we've tried a few different files in both locations. For both locations, once the directory structure (\com\onres...) was created and the file(s) placed in the lowest directory we see a line for each file as above, but always failed to load/compile. Other JQL function script files in the root rather then down the line in ..\jql do not show in the log in this way.

I took that to mean our issue is with the content of the file, and not the location, but I'll be happy if it's simple user error on file name or location!

Robert, can you install the snapshot of the next release version from https://jamieechlin.atlassian.net/wiki/pages/viewpageattachments.action?pageId=33619976

This should tell you why the function is failing to load.

That was the key, thanks so much.

I suspect that it didn't like the space in Program Files. Once I had that clue, I created a new scriptroot with no spaces, and the illegal charecter went away and started giving me really meaningful errors in the log that I could trace down. I got the test recognized quickly have now have two of our original custom JQLs in.

Since I had the some when I tried putting the files in the scriptroot the plugin creates (JIRA_HOME\scripts), I'm not sure if there is something you can address or at least put a comment in the docs that this could be an issue.

2014-07-28 08:58:15,622 Thread-43 WARN xxxxxxx 537x119x2 z0zkay xxx.xxx.xxx.xxx /rest/plugins/1.0/ [onresolve.scriptrunner.runner.ScriptRunnerImpl] Script C:\Program Files\Atlassian\Application Data\JIRA\scripts\com\onresolve\jira\groovy\jql\plugins\JQLTEST.groovy failed to load/compile: Illegal character in path at index 16: file:/C:/Program Files/Atlassian/Application Data/JIRA/scripts/com/onresolve/jira/groovy/jql/plugins/JQLTEST.groovy

Thanks again!

Great, thanks. Did you try with the snapshot version, and that then gave you the clue about the space? Or it didn't warn you about that?

I raised https://jamieechlin.atlassian.net/browse/GRV-485for the issue with spaces, but have not tried to reproduce yet.

With the release version, all we were getting was the basic "...<file> failed to load/compile".

Once I loaded the snapshot version you provided, the logging started adding the illegal charecter message I mentioned previously.

Based on that I started moving files to the alternate scriptroot, and the illegal charecter message went away for the moved file and I started seeing errors about the content (basically issues with our code) instead and relatively easy to debug with the error messages provided.

We're still working through some coding issues, making sure we understand the new format, but we do have two basic jqlfunctions in place and working so we're heading down the right path.

Thanks again!

Brilliant, thanks. The change I made for the snapshot is in the version released last night, 3.0.2.

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,301 views 14 20
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot