Hi All ,
I am trying to access the jira oracle database in my groovy class which i am using in behaviour plugin . i get the following error
java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver
The driver jar is present in /lib folder and i am even able to see the results when i run the below script in the script runner panel for scripts
import groovy.sql.Sql import com.atlassian.jira.ComponentManager Sql sql = Sql.newInstance("jdbc:oracle:thin:@localhost:1521:orcl", "mizan", "mizan", "oracle.jdbc.OracleDriver") def sqlString="select * from parent where parent='TP_1.0.0'" List row = sql.rows(sqlString) return row.parent
But when i try to run my groovy class in the behaviours plugin i get the error .
What might be the cause ? do i have to import some package ? do i have to add the oracle-jdbc jar in some directoy ?
can someone please help me with this ?
below is part of my groovy class
import groovy.sql.Sql public class Test extends FieldBehaviours { public void setTest() { FormField formComponent = getFieldById(fieldChanged) FormField formSubcomponent = getFieldByName("Test1") Object componentFormValue = formComponent.getFormValue() Sql sql = Sql.newInstance("jdbc:oracle:thin:@localhost:orcl", "mizan", "mizan", "oracle.jdbc.OracleDriver");
Community moderators have prevented the ability to post new answers.
It's classloader problems. If the oracle jar was a valid OSGi bundle, like the mysql one, it's relatively simple, however I doubt the oracle one is.
I think you will need to rebuild the plugin - info on the same problem here https://studio.plugins.atlassian.com/browse/JBHV-113
You should try the groovy sql part of your script in the script runner. Going forward I will use the same strategy for classloading in the behaviours plugin. In the meantime you need to add the dep to the pom and rebuild.
Hi Jamie ,
When i run the groovy sql part in script runner it work and i am able to see the database values as output.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
OK, that's good in that when I update behaviours, you will no longer need to rebuild it. But doesn't help you much right now :-(
The other thing to do is load the class in the context of the web-inf/lib classloader... but that may lead to even more confusing problems. Probably adding to the pom and rebuild is your best bet atm.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Which version of maven? And which version of the plugin? For jira4 you should run:
mvn -P jira4 -Dmaven.test.skip=true clean package
(assuming the latest version).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Not sure but i guess i was able to add oracle jdbc in behaviours when i added below code in pom
<dependency> <groupId>com.oracle</groupId> <artifactId>oracle-jdbc15</artifactId> <version>11.2.0.1.0</version> <scope>system</scope> <systemPath>${java.home}\lib\oracle-jdbc15-11.2.0.1.0.jar</systemPath> </dependency>
however now i get these errors .
"[WARNING] 'build.pluginManagement.plugins.plugin.(groupId:artifactId)' must be unique but found duplicate declaration of plugin org.codehaus.mojo:cobertura-maven-plugin @ com.atlassian.pom:atlassian-base-pom:22, C:\Documents and Settings\Administrator\.m2\repository\com\atlassian\pom\atlassian-base-pom\22\atlassian-base-pom-22.pom, line 395, column 25
[ERROR] 'build.plugins.plugin[org.codehaus.gmaven:gmaven-plugin].dependencies.dependency.scope' for org.seleniumhq.selenium:selenium-java:jar must be one of [compile, runtime, system] but is 'test'. @ line 169, column 32
[ERROR] 'build.plugins.plugin[org.codehaus.gmaven:gmaven-plugin].dependencies.dependency.scope' for junit:junit:jar must be one of [compile, runtime, system] but is 'test'. @ line 176, column 32
[WARNING] 'reporting.plugins.plugin.version' for org.apache.maven.plugins:maven-javadoc-plugin is missing. @
"
i have to still make a jar and test it for my script .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am using atlassian plugin sdk 3.7 .... and Behaviours-jira-0.4.7 .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
and your mvn command line?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Maven is version 2 , The above command does not complete its gives a outofmemory failure , i did atlas-clean and again did atlas-run i get this error "Couldn't detect an AMPS product to dispatch to" .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Found this so removed the <scope> and now it does not give any error but unable to do atlas-run it give error "Couldn't detect an AMPS product to dispatch to" . is there some otherway to build the source of behaviours plugin ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jamie ,
I am stuck here i am not able to rebuild the Behaviours plugin from its source . Am i missing something ? can you please help me with this ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am not sure what your issue with maven is, and don't have time to debug that. But if you create an issue in the JBHV project including the jira version you need to target I'll attach a custom build.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok , il do that . thanx .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jamie ,
Can you please provide me the source code for Behaviours plugin version 0.5.0 compatible with Jira 5 , i need to add oracle driver .
I was not able to get it using browse source link on marketplace .
Thank you .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try adding a dependency to the oracle-jdbc driver in your plugin's pom.xml and set the <scope> to "provided"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Joseph ,
I am trying to add the dependency in Behaviours plugin , for adding the dependency im following this approach
i run the following command
atlas-mvn install:install-file -Dfile=oracle-jdbc15-11.2.0.1.0.jar -DgroupId=com.oracle \ -DartifactId=oracle -Dversion=10.2.0.2.0 -Dpackaging=jar -DgeneratePom=true
I get an error
[INFO] ------------------------------------------------------------------------ [ERROR] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Invalid task 'oracle-jdbc15-11.2.0.1.0.jar': you must specify a valid lif ecycle phase, or a goal in the format plugin:goal or pluginGroupId:pluginArtifac tId:pluginVersion:goal [INFO] ------------------------------------------------------------------------
how to tackle this ?
Am i going wrong somewhere ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Add maven dependency to pom.xml file, something like:
<!-- Oracle Database 10g Release 2 (11.2.0.1.0) JDBC Drivers --> <dependency> <groupId>com.oracle</groupId> <artifactId>oracle-jdbc15</artifactId> <version>11.2.0.1.0</version> <scope>provided</scope> </dependency>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Xrakan ,
I get this error when i add the dependency in the pom
"Missing artifact com.oracle:oracle-jdbc15:jar:11.2.0.1.0:provided"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must find correct oracle mvn dependency (mayby on oracle sites), this is only example. Probably groupId, artifactId is not correct.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try
<dependency> <groupId>com.oracle.jdbc</groupId> <artifactId>ojdbc5</artifactId> <version>11.2.0.1.0</version> <scope>provided</scope> </dependency>
yet.
If it does not work - it looks that Oracle dont have public maven repository, than copy somewhere you driver jar file and try in pom reference it by system scope and system path (http://maven.apache.org/general.html#tools-jar-dependency).
<dependency> <groupId>com.oracle</groupId> <artifactId>oracle-jdbc15</artifactId> <version>11.2.0.1.0</version> <scope>system</scope> <systemPath>${project.basedir}/path/to/file/oracle-jdbc15-11.2.0.1.0.jar</systemPath> </dependency>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The same error . I even tried manually adding dependency through eclipse and even netbeans .
If someone has done this before can someone please provide the behaviours jar with oracle-jdbc drivers if possible .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.