How to add dependencies for JAXB and JAF when migrating from Java 8 to Java 11

On https://github.com/apache/fineract/compare/develop...vorburger:bump-gradle-wrapper_FINERACT-700_still-Tomcat-with-Java11, I am attempting to migrate a project from Java 8 to Java 11 (and upgrade that project’s use of an ancient old Gradle version to a current one).

As per many blog and Stack Overflow posts, Java 11 does not include javax.xml.bind and javax.activation anymore like Java 8 used to. I’m therefore adding explicit dependencies for them to the project, where all of its other dependencies are specified, with scope compile. However, the project still fails to build, due to:

error: package javax.xml.bind.annotation does not exist
import javax.xml.bind.annotation.XmlElement; 
error: package javax.xml.bind.annotation does not exist
import javax.xml.bind.annotation.XmlElementWrapper; 
error: cannot find symbol @XmlElementWrapper(name = "errors") 
error: cannot access DataSource mimeMessageHelper.addAttachment(attachment.getName(),attachment); class file for javax.activation.DataSource not found

I’m puzzled and can’t figure out where to correctly add the required dependencies so that it works. I suspect that this may have something to do with Java Module, JPMS? In this project, we don’t want to use modules. Is there nevertheless any special syntax required to “just add” JAXB and JAF dependencies?

It should be possible to easily reproduce the problem as follows:

git clone https://github.com/vorburger/fineract.git
git checkout bump-gradle-wrapper_FINERACT-700_still-Tomcat-with-Java11
./gradlew build

Thanks a lot for any help.

Have you noticed it yet?

Try removing lines 182 and 183 from fineract-provider/build.gradle:

    ...
    exclude module: 'jaxb-api'
    exclude module: 'jaxb-impl'
    ...

If that’s not the solution, please share with us whatever solution you do eventually find?

Thanks.

Are you familiar with the advantages of api/implementation separation?

I ran your project through an Application Binary Interface static analysis tool.

It detected that out of the 42 dependencies that you assigned to the compile configuration in fineract-provider/dependencies.gradle, 74% of them (31) could be safely assigned to the implementation configuration instead.

The remaining 26% of those dependencies could/should be assigned to the api configuration instead of compile. These are those 11 api dependencies:

------------------------------------------------------------------------------
 ABI Dependencies Summary (counts are approximate)
------------------------------------------------------------------------------
 com.google.code.gson:gson:2.2.4, seen 430 time(s)
------------------------------------------------------------------------------
 org.quartz-scheduler:quartz:2.1.7, seen 19 time(s)
------------------------------------------------------------------------------
 joda-time:joda-time:2.4, seen 893 time(s)
------------------------------------------------------------------------------
 org.apache.openjpa:openjpa-all:2.4.1, seen 10 time(s)
------------------------------------------------------------------------------
 org.springframework:spring-jms:4.0.7.RELEASE, seen 6 time(s)
------------------------------------------------------------------------------
 org.mnode.ical4j:ical4j:1.0.4, seen 3 time(s)
------------------------------------------------------------------------------
 com.google.guava:guava:15.0, seen 3 time(s)
------------------------------------------------------------------------------
 org.springframework:spring-context-support:4.1.9.RELEASE, seen 1 time(s)
------------------------------------------------------------------------------
 org.springframework.security.oauth:spring-security-oauth2:2.0.4.RELEASE, seen 1 time(s)
------------------------------------------------------------------------------
 com.squareup.retrofit:retrofit:1.6.1, seen 8 time(s)
------------------------------------------------------------------------------
 com.sun.jersey:jersey-core:1.17, seen 418 time(s)
------------------------------------------------------------------------------
1 Like

Try removing lines 182 and 183 from fineract-provider/build.gradle

duh! Yes, that did the trick indeed! It didn’t even occur to me to check for exclusions. Thank you so much!

Are you familiar with the advantages of api / implementation separation ?

That’s cool! We (Apache Fineract) would certainly love a contribution (PR) from you for this - would you have any interest in doing that?

1 Like

Awesome! Glad you got it working :+1:

Yeah, I could help you out and refactor those configurations. But, I won’t be free until this weekend. Would that be too late?

No, whenever you can would be great. I’ve now raised [FINERACT-777] Use api / implementation instead of compile scoped dependencies - ASF JIRA to track all work related to this.

Hi there,

Is the pull request I submitted yesterday publicly visible?

I went ahead yesterday and made the changes using the branch you shared above as the base for my working branch.