Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JENA-1609 Jena master does not build under JDK10 #474

Closed
wants to merge 3 commits into from

Conversation

lewismc
Copy link
Member

@lewismc lewismc commented Oct 1, 2018

Copy link
Member

@ajs6f ajs6f left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know very much about Java 10 builds, but I'm a bit confused about some of these changes-- maybe we could get some in-line comments on them?

.gitignore Outdated
@@ -14,7 +14,10 @@ buildNumber.properties
.project
.settings
.recommenders
.metadata
.metadat
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct? .metadata => .metadat?

jena-arq/pom.xml Outdated
@@ -216,6 +216,7 @@
</group>
</groups>
<bottom>Licenced under the Apache License, Version 2.0</bottom>
<additionalOptions>-html5</additionalOptions>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this in some way needed for Java 10 builds?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is not included there is a WARNING message as follows

javadoc: warning - You have not specified the version of HTML to use. The default is currently HTML 4.01, but this will change to HTML5 in a future release. To suppress this warning, please specify the version of HTML used in your documentation comments and to be generated by this doclet, using the -html4 or -html5 options.

The -html5 additional option cleans up presence of WARNING's during Maven build.

Copy link
Member

@afs afs Oct 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This setting is in the parent POM. It is commented out because the build fails with Java8. It is not the only setting up for the javadoc plugin.

  1. Is setting in the parent enough? If it does, it is better to have in one place because ...
  2. Has this PR been run with Java8? The build exits with an error in jena-iri:javadoc for me.

* {@link #accepts(TKey, T)}
*
*
* {@link #accepts(Object, AbstractNodeTupleWritable)}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just looks wrong-- the method below clearly is accepts(TKey key, T tuple), and the concrete class isn't there at all.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree... it was strange when it turned out that this seemed to be the fix. Without the code augmentation, I was unable to generate the Javadocs for the project. It should be noted that Javadoc generation is activated by default during an install target.

<artifactId>log4j</artifactId>
</dependency>

<dependency>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you pulling in the log4j API?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the org.apache.log4j.PropertyConfigurator class is required in jena/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/JenaDriver.java

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO The fix is not to use log4 directly but to use SLF4J and LogCtl because then logger can be swapped. But, for history reasons, this may not be practical. cc @rvesse

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup. We may have to do something like this, but it's definitely "papering-over" the underlying fault.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This being said, what would you rather see? This issue is titled Jena master does not build under JDK10 so I wonder if getting Jena to build under JDK 10 is the immediate response. Someone can then go and work on the underlying logging issue. Right now I have not investigated it enough or else I would have provided the fix.

Copy link
Member

@rvesse rvesse Oct 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JenaDriver can optionally configure Log4j, this is because JDBC drivers can be used in contexts where the end user can't directly configure logging e.g. when dropped into other applications. In those contexts users can add logging=<log4j-config> in their JDBC connection string to have the driver configure logging for them.

However the default behaviour is to not configure anything and all the code internally uses SLF4J so in environments where users can control logging configuration they are free to do that. So in environments where the user fully controls things they can configure logging as appropriate.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok thanks @rvesse. The logic seems clear from what you wrote, it doesn't however take away from the fact that the codebase will not build under JDK10 (and possibly JDK9) without the presence of the log4j library containing org.apache.log4j.PropertyConfigurator as currently used within jena/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/JenaDriver.java.
The issue here is to either refactor the logging or to add the dependency... I would think there is no other scenario under consideration.
Is that a fair statement?

@lewismc
Copy link
Member Author

lewismc commented Oct 1, 2018

Thanks for comments @ajs6f

@acoburn
Copy link
Member

acoburn commented Oct 1, 2018

It is possibly worth noting here that these changes also make it possible to build Jena on JDK 11.

@lewismc
Copy link
Member Author

lewismc commented Oct 1, 2018

Thats good to know @acoburn thanks for chiming in.

@afs
Copy link
Member

afs commented Oct 1, 2018

See https://builds.apache.org/view/H-L/view/Jena/job/Jena_JDK11/ which builds with -Pdev and has been running for a while. It does not build jena-jdbc or jena-elephas both of which need looking at.

@lewismc
Copy link
Member Author

lewismc commented Oct 1, 2018

Thanks @afs I looked at the build and built locally using the following parameters

mvn clean verify -Pdev

... it results in SUCCESSFUL build.

<artifactId>log4j</artifactId>
</dependency>

<dependency>
Copy link
Member

@rvesse rvesse Oct 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JenaDriver can optionally configure Log4j, this is because JDBC drivers can be used in contexts where the end user can't directly configure logging e.g. when dropped into other applications. In those contexts users can add logging=<log4j-config> in their JDBC connection string to have the driver configure logging for them.

However the default behaviour is to not configure anything and all the code internally uses SLF4J so in environments where users can control logging configuration they are free to do that. So in environments where the user fully controls things they can configure logging as appropriate.


<!-- Intercept direct use of log4j2 -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is unnecessary, the only Log4j direct usage is to configure Log4j, the code itself always uses SLF4J for its logging

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed - I checked using the current master branch. Only log4j1 is used (log4j::log4j).

What I am baffled by is that fact it builds with java8 and not with java10 and the failure is a dependency missing. log4j1 is a "optional" dependency in the parent.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK so we agree on this however the code doesn't build due to the missing dependency. I wasn't able to build without the additions as proposed.

Copy link
Member

@afs afs Oct 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unclear here. I tried with JDK10 and had to add the log4j1 dependency but not the log4j2 dependencies.

In the code I can only find imports of org.apache.log4j, which is log4j1, not org.apache.logging.log4j which is log4j2. Something weird is going on anyway that the log4j1 dependency is necessary. @lewismc, are the group "org.apache.logging.log4j" dependencies necessary for you? If so, what's the build failure?

Elasticsearch does use log4j2 and Jena adds adapters there for that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More:

Confirmed I have only have to add a single log4j1 dependency.
The error is otherwise from the maven-javadoc-plugin, not the compiler:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:3.0.0:jar (attach-javadocs) on project jena-jdbc-driver-bundle: MavenReportException: Error while generating Javadoc: 
[ERROR] Exit code: 1 - /home/afs/Jena/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/JenaDriver.java:42: error: package org.apache.log4j does not exist
[ERROR] import org.apache.log4j.PropertyConfigurator;
[ERROR]                        ^
[ERROR] 
[ERROR] Command line was: /usr/lib/jvm/default-java/bin/javadoc @options @packages
[ERROR] 
[ERROR] Refer to the generated Javadoc files in '/home/afs/Jena/jena-jdbc/jena-jdbc-driver-bundle/target/apidocs' dir.
[ERROR] 

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. This is the behavior I get as well.
My thinking was that the dependency needed to be available at compile time as oppose to only runtime... but maybe this thinking is wrong.
The generated Javadoc look fine but the error prevents a stable build.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I understand, the offending class org.apache.log4j.PropertyConfigurator resides in log4j 2.0... the runtime dependencies are detailed as follows with the Maven Artifacts detailed here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code predates Log4j 2.x so shouldn't have any dependency upon it

Copy link
Member

@afs afs Oct 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong PropertyConfigurator - there are two (!!), one in log4j1 and one in the log4j2 for compatibility code log4j-1.2-api/src/main/java/org/apache/log4j/PropertyConfigurator.java.

Jena is picking up the one from log4j1. So the log4j2 dependencies aren't need but the log4j1 is. Either will do to compile but log4j1 is intended.

@afs
Copy link
Member

afs commented Oct 2, 2018

I'm trying to get a single build configuration for both java10 and java8.

I can't get Jena to build with java8 if <additionalOptions>-html5</additionalOptions> is set.

It is a problem in the full build because skipping javadoc isn't an option - the distributions include javadoc by dependency.

With java 10.0.2 (Ubuntu latest with the placeholder java11 - still waiting for real java11): jena-elephas-common fails because:

[ERROR] Failed to execute goal on project jena-elephas-common: Could not resolve dependencies for project org.apache.jena:jena-elephas-common:jar:3.10.0-SNAPSHOT: Could not find artifact jdk.tools:jdk.tools:jar:1.6 at specified path /usr/lib/jvm/java-11-openjdk-amd64/../lib/tools.jar -> [Help 1]

(it also used MRUnit which is a retired project)

A pure maven build will put the java11 runtime (no tools.jar) on the compile classpath.

@lewismc - am I right in concluding it worked for you in the IDE because the java8 runtime was on the build path?

@rvesse
Copy link
Member

rvesse commented Oct 2, 2018

@afs For some projects where I have added JDK 9/10 support I have had to create separate profiles activated by JDK version for the Javadoc plugin because there are breaking changes between the plugin versions and supported flags for the underlying javadoc tool

Also if you have updated the Javadoc plugin version to a 3.x release then you need to add an <option> sub-element within <additionalOptions> rather than just specifying the options directly

@lewismc
Copy link
Member Author

lewismc commented Oct 3, 2018

@afs how about we propose the change to

<additionalOptions>-html4</additionalOptions>

This would produce JDK WARNING's under several environment's however would at least enable successful build under this environments.

@lewismc
Copy link
Member Author

lewismc commented Oct 3, 2018

@afs I have not tried this build under JDK11 yet, neither did I try to build under an IDE. I just build using my terminal.

@afs
Copy link
Member

afs commented Oct 3, 2018

@lewismc

@afs how about we propose the change to

<additionalOptions>-html4</additionalOptions>

This would produce JDK WARNING's under several environment's however would at least enable successful build under this environments.

The problem is not html4/html5 (we can clean up the javadoc) but compatible with java8 javadoc tool. Java8 build causes:

Exit code: 1 - javadoc: error - invalid flag: -html4

I'd prefer that the build uses java8 for java8 libraries because cross-compiling does not catch changes in the runtime libraries.

@afs
Copy link
Member

afs commented Oct 3, 2018

@rvesse - The current plugin in the build is 3.0.0. <option> didn't change the situation. Can you given an example or point to one? (the online plugin doc does not talk about <option>

Profiles: that would be great. Again, a sample to start from would help. While all the suggestions here are great, it's going to be slower if I have to carry out each one from scratch.

@rvesse
Copy link
Member

rvesse commented Oct 3, 2018

@afs https://github.com/rvesse/airline/blob/master/pom.xml#L495-L497 which I discovered via JIRA https://issues.apache.org/jira/browse/MJAVADOC-475

Notice that same POM configures the Javadoc plugin differently for each supported JVM via profiles

@lewismc
Copy link
Member Author

lewismc commented Oct 3, 2018

@afs

The problem is not html4/html5 (we can clean up the javadoc) but compatible with java8 javadoc tool. Java8 build causes:

Got it.

I'd prefer that the build uses java8 for java8 libraries because cross-compiling does not catch changes in the runtime libraries.

So do you want to abandon this PR and state that Jena should be used with JDK 1.8? If so I can close out this issue. Unless of course if you can propose an alternative.

@rvesse
Copy link
Member

rvesse commented Oct 3, 2018

I think there is a simpler solution to this, I have Jena JDBC building locally under JDK10 and will push a new PR shortly

@lewismc
Copy link
Member Author

lewismc commented Oct 3, 2018

@rvesse grand

@afs
Copy link
Member

afs commented Oct 3, 2018

"should be used with JDK 1.8" has several facets.
There are different levels of Java11 usage: the project discussions back when it was Java9:

dev@ message and sent as part of users@ message.

Ultimately, it is a community decision.

My personal opinion is that Jena should be able to run on Java8 runtime. Research projects may upgrade quickly but enterprise deployments are another matter.

To ensure no accidents, I prefer the release build used Java8 because it protects against runtime library changes (we have one currently about tools.jar).

I'd like the build to work with Java11 - hence the commented line in the parent pom.xml and the Jenkins job, both of which came out of the project discussions from Feb. Currently, "-Pdev" works, the full release build does not.

I have ~/.mavenrc setup to make sure I gets builds right. I use JDK10 as the default java on my system (I am resisting installing Java11 manually and waiting for Ubuntu ... at least for now!), I make sure maven runs with Java8.

 # ~/.mavenrc
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64

Java11 will change the ecosystem and we don't know how that plays out or what may come out of adoptjava and the Jan2019 deadline from Oracle. I think it will rapidly become clear.

@rvesse
Copy link
Member

rvesse commented Oct 3, 2018

@afs Agreed, many folks are going to migrate Java 8 -> Java 11 because of the LTS release status and are skipping interim versions

@ajs6f
Copy link
Member

ajs6f commented Oct 3, 2018

@rvesse Yup, that's my site and every other one I know. That's not to say that this PR isn't worthwhile, just that I would certainly like to spend as much time as possible on 11, not 10.

@afs
Copy link
Member

afs commented Oct 3, 2018

10 < 11. All these issues are in Java11 because Java 9 & 10 were the big changes and Java 11 the consolidation.

@lewismc
Copy link
Member Author

lewismc commented Oct 3, 2018

Closing in favor of #476

@lewismc lewismc closed this Oct 3, 2018
@lewismc lewismc deleted the JENA-1609 branch October 3, 2018 18:47
@afs
Copy link
Member

afs commented Oct 3, 2018

I've picked out the .gitignore changes (not for META-INF - that's needed) and added them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants