Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

"java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver" error

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

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");

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

5 votes
Answer accepted
JamieA
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.
March 7, 2012

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.

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.
March 7, 2012

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.

JamieA
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.
March 7, 2012

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.

JamieA
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.
March 7, 2012

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).

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.
March 7, 2012

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 .

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.
March 7, 2012

I am using atlassian plugin sdk 3.7 .... and Behaviours-jira-0.4.7 .

JamieA
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.
March 7, 2012

and your mvn command line?

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.
March 11, 2012

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" .

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.
March 11, 2012

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 ?

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.
March 12, 2012

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 ?

JamieA
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.
March 12, 2012

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.

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.
March 12, 2012

Ok , il do that . thanx .

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.
March 19, 2012
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.
October 2, 2012

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 .

0 votes
Joe Clark
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 7, 2012

Try adding a dependency to the oracle-jdbc driver in your plugin's pom.xml and set the <scope> to "provided"

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.
March 7, 2012

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 ?

Radek Kantor
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.
March 7, 2012

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>

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.
March 7, 2012

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"

Radek Kantor
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.
March 7, 2012

You must find correct oracle mvn dependency (mayby on oracle sites), this is only example. Probably groupId, artifactId is not correct.

Radek Kantor
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.
March 7, 2012

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>
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.
March 7, 2012

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 .

TAGS
AUG Leaders

Atlassian Community Events