Mario
Mario

Reputation: 2621

Maven build fails when building Geonetwork

I am trying to build Geonetwork with Maven. The source code is from here: https://github.com/geonetwork/core-geonetwork/tree/3.10.x

I follow this tutorial to build Geonetwork: https://geonetwork-opensource.org/manuals/trunk/eng/users/tutorials/introduction/deployment/build.html

But when I build it, these errors appear:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project common: Compilation failure: Compilation failure:
[ERROR] /C:/Users/mn/Downloads/core_geonetwork/core-geonetwork-3.10.x/common/src/main/java/org/fao/geonet/utils/GeonetHttpRequestFactory.java:[59,24] cannot find symbol
[ERROR]   symbol:   class PreDestroy
[ERROR]   location: package javax.annotation
[ERROR] /C:/Users/mn/Downloads/core_geonetwork/core-geonetwork-3.10.x/common/src/main/java/org/fao/geonet/utils/Xml.java:[70,22] package javax.xml.bind does not exist
[ERROR] /C:/Users/mn/Downloads/core_geonetwork/core-geonetwork-3.10.x/common/src/main/java/org/fao/geonet/utils/Xml.java:[71,22] package javax.xml.bind does not exist
[ERROR] /C:/Users/mn/Downloads/core_geonetwork/core-geonetwork-3.10.x/common/src/main/java/org/fao/geonet/utils/GeonetHttpRequestFactory.java:[72,6] cannot find symbol
[ERROR]   symbol:   class PreDestroy
[ERROR]   location: class org.fao.geonet.utils.GeonetHttpRequestFactory
[ERROR] /C:/Users/mn/Downloads/core_geonetwork/core-geonetwork-3.10.x/common/src/main/java/org/fao/geonet/utils/Xml.java:[376,9] cannot find symbol
[ERROR]   symbol:   class JAXBContext
[ERROR]   location: class org.fao.geonet.utils.Xml
[ERROR] /C:/Users/mn/Downloads/core_geonetwork/core-geonetwork-3.10.x/common/src/main/java/org/fao/geonet/utils/Xml.java:[376,35] cannot find symbol
[ERROR]   symbol:   variable JAXBContext
[ERROR]   location: class org.fao.geonet.utils.Xml
[ERROR] /C:/Users/mn/Downloads/core_geonetwork/core-geonetwork-3.10.x/common/src/main/java/org/fao/geonet/utils/Xml.java:[377,9] cannot find symbol
[ERROR]   symbol:   class Unmarshaller
[ERROR]   location: class org.fao.geonet.utils.Xml
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <args> -rf :common

So there seems to be something with the package javax.annotation. I tried this hint here: https://stackoverflow.com/a/63268748/5621619 but it does not help. I also tried to replace the plugin repository according to this answer: https://stackoverflow.com/a/53853896/5621619 but it does not help.

My Java version is as follows:

java version "15.0.1" 2020-10-20
Java(TM) SE Runtime Environment (build 15.0.1+9-18)
Java HotSpot(TM) 64-Bit Server VM (build 15.0.1+9-18, mixed mode, sharing)

My Maven version is as follows:

Java HotSpot(TM) 64-Bit Server VM warning: Ignoring option MaxPermSize; support was removed in 8.0
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: C:\opt\apache-maven-3.6.3\bin\..
Java version: 15.0.1, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk-15.0.1
Default locale: de_CH, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

How can I get this build process to run?

Upvotes: 0

Views: 228

Answers (2)

Kevin
Kevin

Reputation: 100

@Mohamed Jaafar is correct, as Java 8 is required when building Geonetwork following instructions from https://geonetwork-opensource.org/downloads.html. I ran into the same problem and was able to resolve by executing

export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)

Ref: What is the installation path of AdoptOpenJDK 8.232 in appVeyor in the macos image?

And if you don't yet have Java 8, brew makes installation easy and only requires you run

brew install --cask adoptopenjdk8

Ref: How to install Java 8 on Mac

Upvotes: 0

Mohamed Gafar
Mohamed Gafar

Reputation: 327

This release of GeoNetwork requires the use of Java 8, that's why you are getting a compile error. You need to install Java 8 and then configure the JAVA_HOME to Java 8.

Upvotes: 1

Related Questions