Skip to content

Java 17 - Fail to build backend #68

@Gaetanbrl

Description

@Gaetanbrl

Hi !

The issue came from a chain of backend startup and build configuration problems rather than from the frontend itself.

First step was to launch :

git clone --recursive https://github.com/geosolutions-it/MapStoreExtension
git submodule update
nvm use 20
npm install
# frontend
npm run fe:start
# backend
npm run be:start

But I encountered several issues related to the backend.

- Maven dependancies

First, Maven dependency resolution failed because the project seems still referenced obsolete Spring repositories (maven.springframework.org), which are no longer available.

I fixed that by removing those legacy repositories and using Maven Central explicitly :

In MapStoreExtension/web/pom.xml, add :

        <repository>
            <id>central</id>
            <name>Maven Central</name>
            <url>https://repo.maven.apache.org/maven2</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>

... and remove :

        <!-- Spring -->
        <repository>
            <id>spring-release</id>
            <name>Spring Portfolio Release Repository</name>
            <url>https://maven.springframework.org/release</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>spring-external</id>
            <name>Spring Portfolio External Repository</name>
            <url>https://maven.springframework.org/external</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>

- Java 17 issue

Then, even after that fix, the backend still could not start correctly. The application runs on Java 17, but part of the stack still depends on an old JAXB implementation (jaxb-impl 2.1.2) that uses reflective access now restricted by the Java module system. This caused Spring context initialization to fail during GeoStore startup, which prevented the /rest/geostore/* endpoints from being exposed.

As a result, the frontend login request to http://localhost:8081/rest/geostore/session/login returned 404, but that was only a consequence of the backend not having started successfully.

I fixed the runtime issue by adding the required JVM --add-opens options to the Cargo/Tomcat startup configuration in web/pom.xml :

MapStoreExtension/web/pom.xml

                    <properties>
                        <cargo.jvmargs>
                            --add-opens=java.base/java.lang=ALL-UNNAMED
                            --add-opens=java.base/java.io=ALL-UNNAMED
                        </cargo.jvmargs>
                        <cargo.servlet.port>${tomcat.port}</cargo.servlet.port>
                        <cargo.logging>low</cargo.logging>
                    </properties>

Now the frontend and backend are communicating properly, and I can log in as admin.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions