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

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

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

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

I will be back as soon as i find this.

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

I will be back as soon as i find this.

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

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

Cheers

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 vote
Mizan Community Champion Nov 06, 2012

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

Mizan Community Champion Nov 06, 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

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

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Published Apr 19, 2018 in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

366 views 0 6
Read article

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