.NET Core 3.1 Docker - Win32Exception: Exec format error



  • Hi,
    I build and run my application on Docker.
    I added this code to startup.cs

         services.AddJsReport(new LocalReporting()
            .UseBinary(JsReportBinary.GetBinary())
            .AsUtility()
            .Create());
    

    And use in controller:

        [MiddlewareFilter(typeof(JsReportPipeline))]
        public async Task<IActionResult> ReportClient(int id)
        {
            var order = await _context.Orders.FirstOrDefaultAsync(m => m.Id == id);
            var orderViewModel = order.MapperToViewModel();
                HttpContext.JsReportFeature().Recipe(Recipe.ChromePdf);
    
                return View(orderViewModel);
        }
    

    When I try to open my page in PDF I threw the error:

    Win32Exception: Exec format error
    System.Diagnostics.Process.ForkAndExecProcess(string filename, string[] argv, string[] envp, string cwd, bool redirectStdin, bool redirectStdout, bool redirectStderr, bool setCredentials, uint userId, uint groupId, uint[] groups, out int stdinFd, out int stdoutFd, out int stderrFd, bool usesTerminal, bool throwOnNoExec)
    System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
    System.Diagnostics.Process.Start()
    jsreport.Local.Internal.BinaryProcess.InnerExecute(string cmd, bool waitForExit)
    jsreport.Local.Internal.BinaryProcess.ExecuteExe(string cmd, bool waitForExit)
    jsreport.Local.Internal.LocalUtilityReportingService.RenderAsync(string requestString, CancellationToken ct)
    jsreport.AspNetCore.JsReportMiddleware.Invoke(HttpContext context)
    Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
    Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
    Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
    Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
    Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
    Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
    Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
    Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
    Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

    Can you help me?

    Best regards
    Pawel



  • Hi,

    do you use the right binary? Please check the following
    https://jsreport.net/learn/dotnet-local#windows-linux-mac
    And also the next chapter mentioning docker.



  • Hi Jan,

    Thanks for quick response.
    I added some lines in my dockerfile. It is the same result.
    Please look:

    #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

    FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
    WORKDIR /app
    EXPOSE 80
    EXPOSE 443

    FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
    RUN apt-get update && \
    apt-get install -y gnupg libgconf-2-4 wget &&
    wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - &&
    sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' &&
    apt-get update &&
    apt-get install -y google-chrome-unstable --no-install-recommends

    ENV chrome:launchOptions:args --no-sandbox

    FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
    WORKDIR /src
    COPY ["AppMcKapka/AppMcKapka.csproj", "AppMcKapka/"]
    RUN dotnet restore "AppMcKapka/AppMcKapka.csproj"
    COPY . .
    WORKDIR "/src/AppMcKapka"
    RUN dotnet build "AppMcKapka.csproj" -c Release -o /app/build

    FROM build AS publish
    RUN dotnet publish "AppMcKapka.csproj" -c Release -o /app/publish

    FROM base AS final
    WORKDIR /app
    COPY --from=publish /app/publish .
    ENTRYPOINT ["dotnet", "AppMcKapka.dll"]



  • The 3.1-buster-slim looks like debian linux/image.
    Do you use jsreport linux binary?
    https://jsreport.net/learn/dotnet-local#windows-linux-mac



  • Now I installed new package:
    jsreport.AspNetCore(2.0.2)
    jsreport.Binary.Linux(2.7.1)
    jsreport.Local(2.2.2)

    I change my Startup.cs

        services.AddJsReport(new LocalReporting()
             .UseBinary(jsreport.Binary.Linux.JsReportBinary.GetBinary())
             .AsUtility()
             .Create());
    

    Docker file is the same as above.
    My error now.

    An unhandled exception occurred while processing the request.
    JsReportBinaryException: Error rendering report: instance has been daemonized and initialized successfully (pid: 85)rendering has finished with errors:A critical error occurred while trying to execute the render command (2). Failed to launch chrome!/tmp/jsreport/compile/jsreport-2.7.1-Hy6PlIREU/chrome/chrome: error while loading shared libraries: libX11.so.6: cannot open shared object file: No such file or directoryTROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md (1). caused by error (2):-> stackError: at onCriticalError (/snapshot/jsreport/node_modules/jsreport-cli/lib/commands/render.js:302:19) at /snapshot/jsreport/node_modules/jsreport-cli/lib/commands/render.js:256:14 at processTicksAndRejections (internal/process/task_queues.js:93:5)caused by error (1):-> stackError: Failed to launch chrome!/tmp/jsreport/compile/jsreport-2.7.1-Hy6PlIREU/chrome/chrome: error while loading shared libraries: libX11.so.6: cannot open shared object file: No such file or directoryTROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md at Client.render (/snapshot/jsreport/node_modules/jsreport-client/lib/client.js) at processTicksAndRejections (internal/process/task_queues.js:93:5) at async startRender (/snapshot/jsreport/node_modules/jsreport-cli/lib/commands/render.js:319:24) at async /snapshot/jsreport/node_modules/jsreport-cli/lib/commands/render.js:226:22 at async Commander.executeCommand (/snapshot/jsreport/node_modules/jsreport-cli/lib/commander.js:242:22)Remote stack: Error: Failed to launch chrome!/tmp/jsreport/compile/jsreport-2.7.1-Hy6PlIREU/chrome/chrome: error while loading shared libraries: libX11.so.6: cannot open shared object file: No such file or directoryTROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md at onClose (/snapshot/jsreport/node_modules/puppeteer/lib/Launcher.js:348:14) at Interface.<anonymous> (/snapshot/jsreport/node_modules/puppeteer/lib/Launcher.js:337:50) at Interface.emit (events.js:215:7) at Interface.close (readline.js:403:8) at Socket.onend (readline.js:180:10) at Socket.emit (events.js:215:7) at endReadableNT (_stream_readable.js:1184:12) at processTicksAndRejections (internal/process/task_queues.js:80:21)
    jsreport.Local.Internal.LocalUtilityReportingService.RenderAsync(string requestString, CancellationToken ct)



  • This signals the chrome missing dependency that should get installed with that:

    RUN apt-get update && \   
        apt-get install -y gnupg  libgconf-2-4 wget && \
        wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
        sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' && \
        apt-get update && \
        apt-get install -y google-chrome-unstable --no-install-recommends
    
    ENV chrome:launchOptions:args --no-sandbox
    

    It seems you have twice FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base in your dockerfile.
    It should be there just once. Maybe the apt-get part isn't running actually. Please remove the second FROM declaration and try it again.


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.