Groovy script accessing MySQL database works in Script Runner, but not Behaviours

Scott Harman
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.
October 14, 2012

Hi guys

Any ideas on why this might be - the code below quite happily runs in the script runner panel, but as soon as I put it in a behaviours object, it throws an error about a missing class, however the JAR is in /lib (where you'd expect)

Does behaviours need it somewhere else?

log.debug "Debuggering Start..."

import groovy.sql.Sql

sql = Sql.newInstance( 'jdbc:mysql://10.54.1.82:3306/jira_customers', 'jirauser',

                       'jirapass', 'com.mysql.jdbc.Driver' )

sql.eachRow( 'select distinct system_id, customer_id, site_name from site limit 1' ) { log.debug "$it.system_id -- ${it.customer_id} -- ${it.site_name}--" }

log.debug "Debuggering End..."

Error:

2012-10-15 04:17:15,386 http-80-2 ERROR user 257x461x1 19nbclh 58.28.208.153 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/runvalidator.json [onresolve.jira.groovy.BehaviourManagerImpl] Something went wrong with method run in class

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:772)

at org.apache.felix.framework.ModuleImpl.access$200(ModuleImpl.java:73)

at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1690)

at java.lang.ClassLoader.loadClass(ClassLoader.java:247)

at java.lang.Class.forName0(Native Method)

Currently running behaviours 0.50, groovy runner 2.0.7

Many thanks

Scott

6 answers

1 accepted

0 votes
Answer accepted
Scott Harman
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.
November 21, 2012

Unfortunately the sources don't seem to be available - but I was able to achieve what I wanted with a Scripted Field executing basically the same SQL

0 votes
Mizan
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.
November 6, 2012

You will have to rebuild the behaviours plugin from source and add a dependency of MySQL driver jar in the pom .

Mizan
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.
November 6, 2012

I have no idea however i have done this when i wanted to use oracle with behaviours groovy script .

You can refer this answer

Bastien
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.
November 6, 2012

Ok, thank you Mizan. Is there any update planned to add this function in Behaviours ? It could be very interesting.

0 votes
Bastien
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.
November 6, 2012

Hi Scott,

My Jira version is 5.0.7 and my Behaviours plugin version is 0.5.0.

I didn't solve my problem :( , so i've used the database custom field plugin to do what i want.

0 votes
Scott Harman
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.
November 5, 2012

Hi all - anyone else had this or is it just Bastien and I?

Bastien - what version Jira and Behaviours plugins are you using?

Cheers

0 votes
Bastien
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.
October 15, 2012

I have the same problem with my groovy script ...

I will be back as soon as i find this.

0 votes
Bastien
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.
October 15, 2012

I have the same problem with my groovy script ...

I will be back as soon as i find this.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events