Scripted JQL Function failed to load/compile

Robert Romanczuk July 23, 2014

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 votes
Answer accepted
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 24, 2014

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

Robert Romanczuk July 24, 2014

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!

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 25, 2014

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.

Robert Romanczuk July 27, 2014

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!

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 28, 2014

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.

Robert Romanczuk July 28, 2014

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!

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 28, 2014

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 Sign up to answer