It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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

5 votes
Answer accepted

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.

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.

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

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 .

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

and your mvn command line?

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

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 ?

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 ?

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.

Ok , il do that . thanx .

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 Mar 07, 2012

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

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 ?

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>

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 find correct oracle mvn dependency (mayby on oracle sites), this is only example. Probably groupId, artifactId is not correct.

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>

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 .

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Off-topic

Atlassian Community Guide to A+ Articles

Stop: Articles and permission Article-writing permissions are given to Leaders, Marketplace Vendors, Solutions Partners, Atlassian Team members, and those who are Level 4 + above. But for any aspir...

54 views 5 3
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you