Search code examples
javamavenjboss6.xjbossfuseojdbc

Unable to load local jar inside my jar


I am banging my head around this, but could not find any solution. I am using jboss-fuse-6.1.0.redhat-379 server and deploying my jar inside Jboss_home/deploy/ folder

The problem I am having is that I am unable to load the oracle ojdbc jar when I run my application. I have tried adding this ojdbc14.jar in my local repository and then adding dependency in POM like:

<dependency>
    <groupId>com.oracle</groupId>
    <artifactId>ojdbc14</artifactId>
    <version>10.2.0.4.0</version>
</dependency>

It successfully resolves the imports problem, but when I deploy my jar in Jboss and run my application, it gives an error that:

java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:@//ip:port/some_name

I have also tried adding ojdbc.jar like this in POM:

<dependency>
    <groupId>com.oracle</groupId>
    <artifactId>ojdbc14</artifactId>
    <version>10.2.0.4.0</version>
    <scope>system</scope>
    <systemPath>${project.basedir}/libs/ojdbc14-10.2.0.4.0.jar</systemPath>
</dependency>

but still getting the same "No suitable driver found" message. Any help how can I add the ojdbc.jar inside my jar ?

**** Update ****

Java Code:

try
   {
   //   File CP_file = new File("/home/path/to/ojdbc14.jar");
   //   DBFactory dbMethod = new DBFactory();
   //   dbMethod.addJarToClasspath(CP_file);

      Class.forName ("oracle.jdbc.OracleDriver");
      String dbURL = "jdbc:oracle:thin:@//ip:port/name";
      String userID = "userid";
      String password = "pass";

  //  dbMethod.isJarOnClassPath(CP_file);

      Connection dbConnection=DriverManager.getConnection(dbURL,userID,password);
// getting exception on above line

Solution

  • i have same proplem and i solve it

    put this repository in your pom file

       <repository>
           <id>codelds</id>
           <url>https://code.lds.org/nexus/content/groups/main-repo</url>
        </repository>
    

    Then add your dependency

     <!-- ORACLE JDBC driver, need install yourself -->
        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc6</artifactId>
            <version>11.2.0.1.0</version>
        </dependency>