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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Jul 10, 2018 in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...

136 views 0 4
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