Closed georgy closed 5 years ago
Hi,
Exactly the same as #11.
I think it's related to the jdk. JDBC Spec says that the driver should be registred automatically...
Which part of JDBC spec?
On Fri, 20 Jul 2018 at 15:52, jgarec notifications@github.com wrote:
Hi,
Exactly the same as #11 https://github.com/utPLSQL/utPLSQL-maven-plugin/issues/11.
I think it's related to the jdk. JDBC Spec says that the driver should be registred automatically...
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/utPLSQL/utPLSQL-maven-plugin/issues/23#issuecomment-406606971, or mute the thread https://github.com/notifications/unsubscribe-auth/AAGA6eWSMiyyS5McnOfJ8ySG4DMwJcgaks5uIeCUgaJpZM4VYDpo .
I am guessing you mean the service provider mentioned in: https://docs.oracle.com/javase/6/docs/api/java/sql/DriverManager.html
Yes.
I don't remember how i solved this problem on my windows computer at work. I was not able to reproduce on my mac.
Which OS ? How do you get ojdbc ? from Oracle maven repository ? you install it locally ? Which JRE ?
You're running maven through eclipse or with command line ?
Hi @georgy,
All Oracle components are NOT published in the public repositories (maven central, etc) so you need to downloaded and imported to your local maven repository.
Could you check if you have it? If not, please try to download them and installed in your repository.
@alberto-hernandez the dependency comes from company's internal maven repo. I add the jar to the plugins classpath by adding dependency to the plugin configuration (described in my original message).
@jgarec Win 7, JDK 8, dependency comes from company's internal maven repo. I am running maven from the command line.
I will try to debug this a bit, from looking at the source code and environment is should work.
@georgy Is this issue still valid or can it be closed?
Closing as no response from @georgy
Hi, I'm trying to get this maven plugin to work, but I'm encountering the same problem 'no suitable driver found for jdbc:oracle:thin:[...]'.
Since this problem was discussed in this Issue, but not resolved as far as I can see it, I'm posting here. If I should rather open a new ticket I can also do that.
Maven is executed with a jdk 8 (1.8.0_192) and the maven dependencies come from a company internal maven repository. Since the utplsql java api is listing all the oracle dependencies in its POM and maven is not complaining about not finding dependencies I figure that the dependencies should be satisfied...
Did you guys find some way to get this work in the meantime? In other tools running with the same maven repository and the same DB connection string the database access is working fine.
Thanks, Johannes
I reopen this issue as it's the third time someone talk about this... But it's really hard to reproduce ...
Could you provide your pom file ? try to remove all unnecessary parts
I got it working from a private repo at work (with no access to public repo). Will provide example config and requirements.
utplsql-maven-plugin
is build without it's dependencies.
In order for it to work from your private repo, when you have no access to internet, you need to have the following modules in your private repo available:
Group: org.utplsql
Artifact: utplsql-maven-plugin
Version: 3.1.2
---
Group: org.utplsql
Artifact: java-api
Version: 3.1.2
---
Group: com.oracle.jdbc
Artifact: ojdbc8
Version: 12.2.0.1
Additionally, in your pom configuration, you need to specify dependency to ojdbc
driver.
Here is example extract of config that works for me:
<plugin>
<groupId>org.utplsql</groupId>
<artifactId>utplsql-maven-plugin</artifactId>
<version>3.1.2</version>
<configuration>
<reporters>
<reporter>
<name>ut_documentation_reporter</name>
<consoleOutput>true</consoleOutput>
</reporter>
<reporter>
<name>ut_junit_reporter</name>
<fileOutput>junit_test_results.xml</fileOutput>
</reporter>
<reporter>
<name>ut_coverage_cobertura_reporter</name>
<fileOutput>cobertura_coverage.xml</fileOutput>
</reporter>
</reporters>
</configuration>
<dependencies>
<dependency>
<groupId>com.oracle.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>12.2.0.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
<executions>
<execution>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
@jgarec, @viniciusam Can we have java-api packaged with maven plugin? That way, users don't need to pull needed package manually into their private (enterprise) repo.
I know we can't package ojdbc
due to licensing.
@hinjo89 - the utplsql-api is published to https://packagecloud.io/utPLSQL/utPLSQL-java-api
Hi,
we have utplsql-maven-plugin with jar and pom and also java-api with jar and pom and all their respective dependencies in our enterprise (nexus) repo.
So ojdbc8 12.2.0.1 is already resolved via the java-api dependencies and maven would fail much earlier if this would not be available.
But just to be sure I also tried to put ojdbc8 explicitly into the plugin dependencies, I also tried to put it everywhere else, but it still ends up with the same error message every time.
Here the relevant part of my pom.xml (with the dependency, even though that shouldn't make a difference):
<plugin>
<groupId>org.utplsql</groupId>
<artifactId>utplsql-maven-plugin</artifactId>
<version>3.1.2</version>
<dependencies>
<dependency>
<groupId>com.oracle.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>12.2.0.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
<executions>
<execution>
<goals>
<goal>test</goal>
</goals>
<configuration>
<paths>
<path>...</path>
</paths>
<reporters>
...
</reporters>
</configuration>
</execution>
</executions>
</plugin>
So all in all I'm very sure that ojdbc is on my classpath sot that I'm left wondering why the driver is not found. I've also tried it with two different java 8 jdks that I have availble, but same behaviour... Maybe it would make sense to add an optional dbDriver property to be able to explicitly initialize the db driver.
Thanks, Johannes
Hi Georgy,
why did you close this again? I don't have a solution yet. How did you solve this before?
Thanks, Johannes
Sorry, I was writing a comment and probably clicked close by mistake :). We ended up implementing a workaround, but as far as the issue goes: root cause is still unclear. The last thing that we saw was that JDK code responsible for service discovery runs twice: the first time it finds correct config file on classpath, but when it runs second time it does not find the service definition in ojdbc jar. It looks like results of the first lookup are ignored (since the driver class is not loaded), but that is all we know right now.
This problem nags me a little bit from the back of my mind, but not enough for me to invest my time :). Not yet at least. The main complication is that the issue only reproducible on some setups and I was not able to get the repro on my environments. So the only viable solution for me is to grab a laptop from a colleague that has this issue and run away for a couple of hours. Not everyone appreciates that approach.
@jgebal sorry for the late reply. I believe we can embed the java-api code into the maven-plugin's code without any problems. Let me try to sort this out this week.
I'm not sure if there's much we can do about the oracle driver, maybe if we embed and shade the library paths we won't be violating any licenses, I can try doing it and then we can avail if it would be an issue.
If we embed the java-api code we should make sure it's an automatic process to keep up-to-date.
Oracle driver may not be embedded or we will break license rules (there was a lengthy thread in the slack-group by Gerarld Venzl)
Hi,
sorry for the late reply, but I can't imagine that this would fix the problem, since the issue is not that the java-api and its dependencies are not on the classpath. All of them including java-api and ojdbc are on our company maven repository, so they are there.
I will try to build the referenced pull request one of these days to test it.
Thanks, Johannes
Hey guys! It's +1 to ones who get that error.
I'm using maven to build a project so when it comes to testing it fails with No suitable driver
. I tried the solution @jgebal described but didn't succeed. Putting driver everywhere in pm.xml
doesn't make any difference.
We probably need more info on this issue. What version of java are you using? What version of maven? What is the exact stackrace?
@jgebal
mvn clean compile liquibase:update test -P local -X > out.txt
so I put it on a slack thread.Hi, when I tried it last time, I tried multiple Java versions and also multiple maven versions. Always the same issue. I gave it up after a while, but would also still be interested in case the root would be found.
Running into a similar issue.
When running liquibase-maven-plugin to set-up the database, followed by utplsql-maven-plugin to execute tests -- liquibase would run in fine and utPLSQL would crash on missing classes.
Swapping the DriverManager to DataSource as per https://github.com/adrianhj/utPLSQL-maven-plugin/commit/4a23f0c4851c2c3d290681831a503147d8a01936 seems to have resolved our issue from a quick test at least (as in it now runs liquibase maven plugin, followed by utPLSQL maven plugin OK).
Thank you very much, @adrianhj I guess we should be easily able to get rid of the DriverManager for utPLSQL doesn't really need a ConnectionPool anyway. We plan to outsource that whole part to java-api, too, so maven-plugin and cli will be more similar.
Actually I haven't tried running tests without liquibase. Will try it as @adrianhj told
It was kinda silly of me not to try mvn clean compile test -P profile
- it works well inside my air-gapped system. The problem really comes up when you run it like mvn clean compile liquibase:update test ...
. Maybe it somehow messes up with drivers or something.
I had the chance to debug a bit further today so as to understand the root cause for the Liquibase + utPLSQL combination issue.
What seems to happen is the following:
oracle.jdbc.driver.OracleDriver
into a child classloader it uses in DatabaseFactory.getConnection(...)oracle.jdbc.driver.OracleDriver
it registers itself with the DriverManageroracle.jdbc.driver.OracleDriver
from the current utPLSQL Maven Plugin classloader, it does not yet exist so it provides a fresh one.oracle.jdbc.driver.OracleDriver
runs its static initialisation logic, attempts to register itself with the DriverManager -- however as registration is addIfAbsent
in DriverManager.registerDriver(...) the Liquibase registered one remains.DriverManager.getConnection(...)
loop continues and exhausts with no valid driver found, and subsequently raises the 'No suitable driver found for url...' exception.I believe there are two options:
oracle.jdbc.driver.OracleDriver
directly same as Liquibase, not going through the DriverManager.I will open a PR for option 2 as I don't believe there is a strong need to remain DB agnostic here unless anyone believes otherwise.. :-)
Thanks a lot for your thorough investigation - and no, we really don't need DB agnostic approach for utPLSQL plugin ;)
The issues should now be resolved by #44
How does this is resolved. I am facing same issue
@preethileela have you tried the latest version of CLI? AFAIK the solution was merge into the project.
It's working fine now cool
when utPLSQL-maven-plugin 3.1.3 release version made available with this change ? I am still seeing 3.1.3-SNAPSHOT version
I have a bit of a problem running utPLSQL-maven-plugin. If I simply add the plugin
Then I get following error:
This makes me think I need to add oracle jdbc driver onto classpath of the plugin. So I added the dependencies:
That helps a bit, but the test run still fails with
I can't find where in the code (plugin or java-api) do you register the oracle driver class. I can see that in cli project there is Class.forName(), but nothing like it in plugin nor java-api.
What is the right way to register the driver then?