Maven packages don't declare dependencies
(Sorry if I don't use the correct Maven terminology)
What I want to do
Start a simple SiLA Server without any custom features, with using the Maven packages instead of using this repo as git submodule:
import sila_java.library.server_base.SiLAServer;
import sila_java.library.server_base.identification.ServerInformation;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
ServerInformation serverInformation = new ServerInformation(
"ExampleType",
"Example description",
"https://example.com",
"0.1"
);
try (SiLAServer server = SiLAServer.Builder.withoutConfig(serverInformation)
.withPlainText()
.withPort(50052)
.start()) {
System.out.println(server.getClass().getName());
}
}
}
What I expect my pom.xml to look like
SiLAServer and ServerInformation are part of the server_base package, so I expect this pom.xml to work:
pom.xml
<?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.example</groupId>
<artifactId>my-simple-sila2-server-app</artifactId>
<version>1.0-SNAPSHOT</version>
<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>
</properties>
<!-- sila_java GitLab Maven repository-->
<repositories>
<repository>
<id>gitlab-maven</id>
<url>https://gitlab.com/api/v4/projects/4205706/packages/maven</url>
</repository>
</repositories>
<dependencies>
<!-- SiLA Server -->
<dependency>
<groupId>org.sila-standard.sila_java.library</groupId>
<artifactId>server_base</artifactId>
<version>0.5.0</version>
</dependency>
<!-- logger -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.36</version>
</dependency>
</dependencies>
</project>
Actual Behavior
Compile-time error:
Exception in thread "main" java.lang.NoClassDefFoundError: sila_java/library/core/sila/mapping/feature/MalformedSiLAFeature
at Main.main(Main.java:15)
Caused by: java.lang.ClassNotFoundException: sila_java.library.core.sila.mapping.feature.MalformedSiLAFeature
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
... 1 more
What I need to do
It only works when I add all required transitive dependencies to my project, so my pom.xml looks like this:
pom.xml
<?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.example</groupId>
<artifactId>sila2-connection-issues</artifactId>
<version>1.0-SNAPSHOT</version>
<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>
</properties>
<!-- sila_java GitLab Maven repository-->
<repositories>
<repository>
<id>gitlab-maven</id>
<url>https://gitlab.com/api/v4/projects/4205706/packages/maven</url>
</repository>
</repositories>
<dependencies>
<!-- SiLA Server -->
<dependency>
<groupId>org.sila-standard.sila_java.library</groupId>
<artifactId>server_base</artifactId>
<version>0.5.0</version>
</dependency>
<!-- logger -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.36</version>
</dependency>
<!-- transitive -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-configuration2</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId>
<version>1.47.0</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<version>1.47.0</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
<version>1.47.0</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>4.0.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.sun.activation</groupId>
<artifactId>jakarta.activation</artifactId>
<version>2.0.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.sila-standard.sila_java.library</groupId>
<artifactId>core</artifactId>
<version>0.5.0</version>
</dependency>
<dependency>
<groupId>org.sila-standard.sila_java.library</groupId>
<artifactId>sila_base</artifactId>
<version>0.5.0</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-api</artifactId>
<version>1.47.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
</dependency>
</dependencies>
</project>
What might cause this
The .pom files in the package registry don't declare any depencencies:
server_base-0.5.0.pom from server_base package
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.sila-standard.sila_java.library</groupId>
<artifactId>server_base</artifactId>
<version>0.5.0</version>
</project>
grpc-core-1.48.0.pom from grpc-core package
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>io.grpc</groupId>
<artifactId>grpc-core</artifactId>
<version>1.48.0</version>
<name>io.grpc:grpc-core</name>
<description>gRPC: Core</description>
<url>https://github.com/grpc/grpc-java</url>
<licenses>
<license>
<name>Apache 2.0</name>
<url>https://opensource.org/licenses/Apache-2.0</url>
</license>
</licenses>
<developers>
<developer>
<id>grpc.io</id>
<name>gRPC Contributors</name>
<email>grpc-io@googlegroups.com</email>
<url>https://grpc.io/</url>
<organization>gRPC Authors</organization>
<organizationUrl>https://www.google.com</organizationUrl>
</developer>
</developers>
<scm>
<connection>scm:git:https://github.com/grpc/grpc-java.git</connection>
<developerConnection>scm:git:git@github.com:grpc/grpc-java.git</developerConnection>
<url>https://github.com/grpc/grpc-java</url>
</scm>
<dependencies>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-api</artifactId>
<version>[1.48.0]</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.9.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>annotations</artifactId>
<version>4.1.1.4</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-annotations</artifactId>
<version>1.21</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_annotations</artifactId>
<version>2.14.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.1-android</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.perfmark</groupId>
<artifactId>perfmark-api</artifactId>
<version>0.25.0</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</project>
Edited by Niklas Mertsch