vladmihalcea / high-performance-java-persistence

The High-Performance Java Persistence book and video course code examples
Apache License 2.0
1.31k stars 489 forks source link

Compile not working / Oracle JAR requires authorization #27

Closed cruftex closed 6 years ago

cruftex commented 6 years ago

When I do

mvn clean test-compile

There is the error:

[ERROR] Failed to execute goal on project high-performance-java-persistence: Could not resolve dependencies for project com.vladmihalcea.book:high-performance-java-persistence:pom:1.0-SNAPSHOT: Failed to collect dependencies at com.oracle.jdbc:ojdbc8:jar:12.2.0.1: Failed to read artifact descriptor for com.oracle.jdbc:ojdbc8:jar:12.2.0.1: Could not transfer artifact com.oracle.jdbc:ojdbc8:pom:12.2.0.1 from/to maven.oracle.com (https://maven.oracle.com): Not authorized , ReasonPhrase:Authorization Required. -> [Help 1]

When removing the Oracle dependency compilation works.

Probably the Oracle JDBC cannot be obtained from Maven central. One solution would be to put the Oracle dependency in a separate Maven profile.

vladmihalcea commented 6 years ago

The README tells exactly what you have to do.

cruftex commented 6 years ago

@vladmihalcea please reconsider this. That is a bad OOTB experience.

Where is it written in the README that I need to register with Oracle to run the tests against PostgreSQL?!

cruftex commented 6 years ago

BTW, the README says exactly:

The Unit Tests are run against HSQLDB, so no preliminary set-ups are required.

How should I do this?

vladmihalcea commented 6 years ago

Just comment the Oracle repository if you don't want to set it up. The tests compile even without the Oracle JDBC Driver.

cruftex commented 6 years ago

Sure, that's what I did. However, a lot of other people will have the same experience and need to do the same.

If you like, I can do a PR with a suggestion how to solve this with a Maven profile. To run the tests with Oracle one would need to do mvn -Poracle test then. In IntelliJ you can enable the profiles in the Maven tool window.

I did something similar here: https://github.com/cruftex/jsr107-test-zoo/blob/master/pom.xml

If you don't like the idea, that's okay too.

The project is really nice!

Ultimately I would recommend working towards something like:

# run the tests with embedded SQL:
mvn test
# run the integration tests with Oracle:
mvn -Poracle verify
# run the integration tests with MySQL:
mvn -Pmysql verify
# run integration tests for performance on PostgreSQL:
mvn -Pperformance,postgresql verify
vladmihalcea commented 6 years ago

I'll use a profile activated by an environment variable.

vladmihalcea commented 6 years ago

Fixed. The Oracle repo must now be activated explicitly.

cruftex commented 6 years ago

@vladmihalcea please mind that you need to move the JDBC driver dependency into the profile as well.

vladmihalcea commented 6 years ago

The driver scope is provided so it won't be required during compile. So, it should be just fine.

cruftex commented 6 years ago

Scope provided means that it is not packaged, since present at the target environment. It's used for compiling.

If you don't want it in the compile scope, then the scope runtime is the correct one. However, runtime would be present during running the tests.

vladmihalcea commented 6 years ago

You're right. Unfortunately, Maven does not have a test-runtime scope, so only moving the dependency to the oracle profile does the trick. I pushed a new change to do that. Thanks for the tip.