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

0 votes
Accepted answer

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.

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

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
Community showcase
Published Nov 29, 2018 in Marketplace Apps

How to set up an incident workflow from the VP of Engineering at Sentry

Hey Atlassian community, I help lead engineering at Sentry, an open-source error-tracking and monitoring tool that integrates with Jira. We started using Jira Software Cloud internally last year, a...

1,431 views 0 8
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