Git Product home page Git Product logo

Comments (3)

swaechter avatar swaechter commented on August 19, 2024

Hey

I also encountered the same warning on several native host systems. As you mentioned the crash is not relatable to lib musl nor glibc (Alpine or not Alpine) - I guess it happens somewhere in the J2V8 library. As always: Wild guessing without a stacktrace ;)

I am not satisfied with the whole J2V8 solution so I wrote a TCP based solution in the last days. TCP and gRPC are now Angular official ways to interact with Angular Universal, so this is the way to go/the future proof way.

I pushed a first runnable version that needs some further love (Better documentation, support for lazy modules and better Node.js error handling).

Is it possible for you to give it a try? I would also be interested in a Docker image (Image with Java 8+ and Node.js).

You can find more information in the README.md and this image: https://raw.githubusercontent.com/swaechter/angularj-universal/master/doc/AngularJ_Universal_HighLevelOverview.png

from angularj-universal.

FusionHS avatar FusionHS commented on August 19, 2024

Sorry for the delay, new year and such.

So I solved the issue by building an imagine with the right binaries for j2v8 built for the alpine image.
Then excluding the packaged one

        <dependency>
            <groupId>ch.swaechter</groupId>
            <artifactId>angularj-universal-renderer-v8</artifactId>
            <version>0.0.3</version>
            <exclusions>
                <exclusion>
                    <groupId>com.eclipsesource.j2v8</groupId>
                    <artifactId>j2v8_linux_x86_64</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

I'll be happy to try the TCP version, but your 0.0.4-SNAPSHOT does not seem to be available on maven, unless I missed some definition for a snapshot repo in the examples.

For reference, here is the dockerfile for the alpine image I'm using. I don't know if this is the right or best way of doing it, but I got sick of things so just left it when it started working.

FROM openjdk:8u181-jdk-alpine

RUN apk add --update --virtual build-dependencies wget git g++ python linux-headers alpine-sdk binutils-gold --no-cache && \

    # Download and build J2V8 4.8.0
    # Source: https://github.com/eclipsesource/J2V8/issues/151
    mkdir /data/ && cd /data/ && git clone https://github.com/eclipsesource/J2V8.git && cd /data/J2V8/ && git checkout 0828fcd5ac2a0f4281e7a5ef913da8cd5a993ac9 && \

    # Set compiler flags
    export CCFLAGS="${CCFLAGS} -fPIC" CXXFLAGS="${CXXFLAGS} -fPIC" CPPFLAGS="${CPPFLAGS} -fPIC" && \

    # Download and build the J2V8 specific node version
    cd /data/J2V8/ && sh ./build-node.sh && \

    cd /data/J2V8/jni && \
    g++ -I ../node -I ../node/deps/v8 -I ../node/deps/v8/include \
        -I ../node/src -I $JAVA_HOME -I $JAVA_HOME/linux  \
        com_eclipsesource_v8_V8Impl.cpp -std=c++11 -fPIC -shared -o /usr/lib/libj2v8_linux_x86_64.so \
        -Wl,--whole-archive ../node/out/Release/obj.target/libnode.a -Wl,--no-whole-archive \
        -Wl,--start-group \
                          ../node/out/Release/obj.target/deps/v8/src/libv8_libbase.a \
                          ../node/out/Release/obj.target/deps/v8/src/libv8_libplatform.a \
                          ../node/out/Release/obj.target/deps/v8/src/libv8_base.a \
                          ../node/out/Release/obj.target/deps/v8/src/libv8_nosnapshot.a \
                          ../node/out/Release/obj.target/deps/v8/src/libv8_libsampler.a \
                          ../node/out/Release/obj.target/deps/uv/libuv.a \
                          ../node/out/Release/obj.target/deps/openssl/libopenssl.a \
                          ../node/out/Release/obj.target/deps/http_parser/libhttp_parser.a \
                          ../node/out/Release/obj.target/deps/gtest/libgtest.a \
                          ../node/out/Release/obj.target/deps/zlib/libzlib.a \
                          ../node/out/Release/obj.target/deps/cares/libcares.a \
        -Wl,--end-group \
        -lrt -z noexecstack -D NODE_COMPATIBLE=1 && \

    # https://github.com/eclipsesource/J2V8/commit/67bfd09f24fece7a0eddcbb0388a572c895c4b8e
    strip --strip-unneeded -R .note -R .comment /usr/lib/libj2v8_linux_x86_64.so && \

    # Cleanup
    apk del build-dependencies && \
    rm -rf /var/cache/apk/* && \
    rm -rf /data/

from angularj-universal.

swaechter avatar swaechter commented on August 19, 2024

Ah, glad to hear that. Where you able to figure out the exact reason like for example some JVM binary related issue or so?

As you mentioned you have to add the OSS Sonatype snapshot repository. Here is a full Maven example:

<?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>ch.swaechter</groupId>
    <artifactId>acme</artifactId>
    <version>1.0-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>ch.swaechter</groupId>
            <artifactId>angularj-universal-renderer-tcp</artifactId>
            <version>0.0.4-SNAPSHOT</version>
        </dependency>
    </dependencies>
    <repositories>
        <repository>
            <id>snapshots-repo</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>
</project>

Keep in mind that your Docker image also needs a Node.js binary to start the Node.js mini app with the TCP server socket. You can find a working Linux-ish Java configuraiton example in the README.md

from angularj-universal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.