TLDR:我更新了Java 11和最新的Maven,但是Maven遇到了问题。首先,它没有足够的内存来启动JVM。当内存增加到> 1.5 G时,它表示无法分配元空间。将内存减少到1.2 G左右,将产生链接错误。在这里做什么?
详细信息:有时它会抱怨某些Google库的非法反射而不是链接错误,尽管错误消息似乎取决于我尝试的顺序,并且很难准确再现。
在一种情况下,这是确切的输出:
>export MAVEN_OPTS="-Xmx1600m"
>mvn -version
Error occurred during initialization of VM
Could not allocate metaspace: 1073741824 bytes
>export MAVEN_OPTS="-Xmx1000m"
>mvn -version
Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-17T14:33:14-04:00)
Maven home: /usr/local/apache-maven-3.5.4
Java version: 11, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.15.0-38-generic", arch: "amd64", family: "unix"
>mvn install
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 48192 bytes for Chunk::new
# An error report file with more information is saved as:
# /home/zach/sync_docs/fs/runner/hs_err_pid5590.log
[thread 5617 also had an error]
#
# Can't open file to dump replay data. Error: Not enough space
>export MAVEN_OPTS="-Xmx1200m"
>mvn install
Error: LinkageError occurred while loading main class org.codehaus.plexus.classworlds.launcher.Launcher
java.lang.UnsatisfiedLinkError: /usr/lib/jvm/java-11-openjdk-amd64/lib/libnio.so: /usr/lib/jvm/java-11-openjdk-amd64/lib/libnio.so: failed to map segment from shared object
进一步的输出:
>echo $JAVA_HOME
/usr/lib/jvm/java-11-openjdk-amd64/
OS:Ubuntu 18.04.1 如果我要求它编译Java 8 JAR,它甚至无法工作,尽管有时它会开始尝试并很快失败。 javac成功编译了一个hello world程序,并且java成功运行了该程序。 使用更新替代方法切换回Java 8(如果Java-8-openjdk或Java-8-oracle有所不同),则可以解决此问题(但没有Java 11功能)。
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.boydwebb</groupId>
<artifactId>familysearch</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.compiler.version>1.8</java.compiler.version>
</properties>
<build>
<plugins>
<plugin>
<version>3.3</version>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.compiler.version}</source>
<target>${java.compiler.version}</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<finalName>graph-runner</finalName>
<appendAssemblyId>true</appendAssemblyId>
<archive>
<manifest>
<mainClass>org.boydwebb.familysearch.runner.Runner</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<!-- unimi dependencies
the unimi project versions MUST be as shown here -->
<dependency>
<groupId>it.unimi.dsi</groupId>
<artifactId>webgraph</artifactId>
<version>3.6.1</version>
</dependency>
<dependency>
<groupId>it.unimi.dsi</groupId>
<artifactId>sux4j</artifactId>
<version>4.3.0</version>
</dependency>
<dependency>
<groupId>it.unimi.dsi</groupId>
<artifactId>fastutil</artifactId>
<version>8.2.2</version>
</dependency>
<dependency>
<groupId>it.unimi.dsi</groupId>
<artifactId>dsiutils</artifactId>
<version>2.5.4</version>
</dependency>
<!-- required for runner utilities -->
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>1.2.1</version>
</dependency>
<!-- logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
<version>1.8.0-beta2</version>
</dependency>
<!-- command line option parsing -->
<dependency>
<groupId>net.sf.jopt-simple</groupId>
<artifactId>jopt-simple</artifactId>
<version>6.0-alpha-2</version>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>16.0.3</version>
<scope>compile</scope>
</dependency>
<!-- hdf5 -->
<!--<dependency>
<groupId>org.hdfgroup</groupId>
<artifactId>hdf-java</artifactId>
<version>2.6.1</version>
<type>jar</type>
</dependency>-->
<dependency>
<groupId>HDF_Group</groupId>
<artifactId>HDFJava</artifactId>
<version>3.3.2</version>
<type>jar</type>
</dependency>
</dependencies>
</project>