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

Fast Serialization GraalVM native image Issue demo #2

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions fst-graalvm-demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# fst-graalvm-demo
Demo using Fast Serialization And GraalVM...\
This is in conjunction with [github.com/vlingo](https://github.com/vlingo) and [vlingo.io](https://vlingo.io).\
We encountered this issue when trying to run the native image of xoom-designer/xoom-schemata that use xoom-lattice which uses fast serialization in inter-node messaging in our cluster backed grid compute and data.

## Maven Build
```bash
mvn install
```

## Generate native image resources Configs
```bash
java -agentlib:native-image-agent=config-output-dir=src/main/resources/META-INF/native-image -jar target/fst-graalvm-0.0.1-SNAPSHOT-jar-with-dependencies.jar
```
## Adding Missing Serialization
```bash
{
"name": "java.lang.Object[]",
"customTargetConstructorClass": "java.lang.Object"
},
{
"name": "java.lang.Object[][]",
"customTargetConstructorClass": "java.lang.Object"
},
{
"name": "java.lang.Object[][][]",
"customTargetConstructorClass": "java.lang.Object"
},
{
"name": "java.sql.Timestamp"
},
{
"name": "java.lang.Object"
},
{
"name": "java.lang.Boolean"
},
{
"name": "java.lang.Character"
},
{
"name": "java.lang.Double"
},
{
"name": "java.lang.Float"
},
{
"name": "java.lang.Long"
},
{
"name": "java.lang.Integer"
},
{
"name": "java.lang.Short"
},
{
"name": "java.lang.Byte"
},
{
"name": "java.lang.String"
},
```

## Build the native image
```bash
mvn install -Pnative-image
```

## Run the native image
```bash
./target/fst-graalvm
```
## Issue
```bash
./target/fst-graalvm
Exception in thread "main" com.oracle.svm.core.jdk.UnsupportedFeatureError: SerializationConstructorAccessor class not found for declaringClass: [Ljava.lang.Object; (targetConstructorClass: java.lang.Object). Usually adding [Ljava.lang.Object; to serialization-config.json fixes the problem.
at com.oracle.svm.core.util.VMError.unsupportedFeature(VMError.java:87)
at com.oracle.svm.reflect.serialize.SerializationSupport.getSerializationConstructorAccessor(SerializationSupport.java:132)
at jdk.internal.reflect.MethodAccessorGenerator.generateSerializationConstructor(MethodAccessorGenerator.java:48)
at jdk.internal.reflect.ReflectionFactory.generateConstructor(ReflectionFactory.java:514)
at jdk.internal.reflect.ReflectionFactory.newConstructorForSerialization(ReflectionFactory.java:427)
at sun.reflect.ReflectionFactory.newConstructorForSerialization(ReflectionFactory.java:103)
at org.nustaq.serialization.FSTDefaultClassInstantiator.findConstructorForSerializable(FSTDefaultClassInstantiator.java:110)
at org.nustaq.serialization.FSTClazzInfo.<init>(FSTClazzInfo.java:137)
at org.nustaq.serialization.FSTClazzInfoRegistry.getCLInfo(FSTClazzInfoRegistry.java:129)
at org.nustaq.serialization.FSTClazzNameRegistry.addClassMapping(FSTClazzNameRegistry.java:98)
at org.nustaq.serialization.FSTClazzNameRegistry.registerClassNoLookup(FSTClazzNameRegistry.java:85)
at org.nustaq.serialization.FSTClazzNameRegistry.registerClass(FSTClazzNameRegistry.java:81)
at org.nustaq.serialization.FSTConfiguration.addDefaultClazzes(FSTConfiguration.java:845)
at org.nustaq.serialization.FSTConfiguration.initDefaultFstConfigurationInternal(FSTConfiguration.java:478)
at org.nustaq.serialization.FSTConfiguration.createDefaultConfiguration(FSTConfiguration.java:473)
at org.nustaq.serialization.FSTConfiguration.createDefaultConfiguration(FSTConfiguration.java:465)
at io.vlingo.xoom.experimental.fst.BootstrapApp.main(BootstrapApp.java:7)
```
96 changes: 96 additions & 0 deletions fst-graalvm-demo/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>io.vlingo.xoom.experimental</groupId>
<artifactId>fst-graalvm</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>fst-graalvm</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<exec.mainClass>io.vlingo.xoom.experimental.fst.BootstrapApp</exec.mainClass>
<graalvm.version>21.1.0</graalvm.version>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>${exec.mainClass}</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>de.ruedigermoeller</groupId>
<artifactId>fst</artifactId>
<version>2.57</version>
</dependency>
<dependency>
<groupId>org.graalvm.sdk</groupId>
<artifactId>graal-sdk</artifactId>
<version>${graalvm.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>

<profiles>
<profile>
<id>native-image</id>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.nativeimage</groupId>
<artifactId>native-image-maven-plugin</artifactId>
<version>${graalvm.version}</version>
<executions>
<execution>
<goals>
<goal>native-image</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
<configuration>
<imageName>${project.name}</imageName>
<mainClass>${exec.mainClass}</mainClass>
<buildArgs>
--no-fallback --no-server --enable-url-protocols=http -H:+AllowIncompleteClasspath
-H:ReflectionConfigurationFiles=classes/META-INF/native-image/reflect-config.json
-H:ResourceConfigurationFiles=classes/META-INF/native-image/resource-config.json
-H:SerializationConfigurationFiles=classes/META-INF/native-image/serialization-config.json
--initialize-at-run-time=io.netty
--allow-incomplete-classpath
</buildArgs>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.vlingo.xoom.experimental.fst;

import org.nustaq.serialization.FSTConfiguration;

public class BootstrapApp {
public static void main(String... args) {
final FSTConfiguration conf = FSTConfiguration.createDefaultConfiguration();

System.out.println("Hello Demo...");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[
]
Loading