Micronaut: Build native image with Consul dependency does not workHow does the Java 'for each' loop work?How does autowiring work in Spring?Consul agent does not respondDocker service registering into Consul but health check is failingWildfly-Swarm Consul service discovery - Invalid service addressOverriding a dependency in a Micronaut testWhy is my Micronaut GraalVM native image application starting so slowly?GraalVM: Allow external scripts to have access to native compiled objectsMicronaut property injection does not work with Gradle multi-project buildMicronaut application yml placeholder with default value not working

Coupling two 15 Amp circuit breaker for 20 Amp

Printing a list as "a, b, c." using Python

Should I judge the efficacy of Samadhi based on the ethical qualities of the meditator?

How to prevent a hosting company from accessing a VM's encryption keys?

Find feasible point in polynomial time in linear programming

web scraping images

What checks exist against overuse of presidential pardons in the USA?

Employing a contractor proving difficult

Why does a sticker slowly peel off, but if it is pulled quickly it tears?

Are spot colors limited and why CMYK mix is not treated same as spot color mix?

Is the internet in Madagascar faster than in UK?

Should I ask for a raise one month before the end of an internship?

What does GDPR mean to myself regarding my own data?

Why is 3/4 a simple meter while 6/8 is a compound meter?

Is the Amazon rainforest the "world's lungs"?

Looking for a plural noun related to ‘fulcrum’ or ‘pivot’ that denotes multiple things as crucial to success

Why does AM radio react to IR remote?

Why does the weaker C–H bond have a higher wavenumber than the C=O bond?

How to say "I only speak one language which is English" in French?

Shall I fix cracks on bathtub and how to fix them?

How to export an email from Mail application?

Drawing probabilities on a simplex in TikZ

Why is "I let him to sleep" incorrect (or is it)?

Is there a way to tell what frequency I need a PWM to be?



Micronaut: Build native image with Consul dependency does not work


How does the Java 'for each' loop work?How does autowiring work in Spring?Consul agent does not respondDocker service registering into Consul but health check is failingWildfly-Swarm Consul service discovery - Invalid service addressOverriding a dependency in a Micronaut testWhy is my Micronaut GraalVM native image application starting so slowly?GraalVM: Allow external scripts to have access to native compiled objectsMicronaut property injection does not work with Gradle multi-project buildMicronaut application yml placeholder with default value not working






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I am trying to build a native image of a micronaut (v1.0.4) application.



This application uses Consul as service discovery.



I've created the app using --features option:



$ mn create-app my-app --features discovery-consul --features graal-native-image --build maven


The application works perfectly on my local machine, but when I try to build a docker container with the native image I get an error:



$ ./docker-build.sh 


error: No instances are allowed in the image heap for a class that is initialized or reinitialized at image runtime: 
sun.security.provider.NativePRNG
Detailed message:
Error: No instances are allowed in the image heap for a class that is initialized or reinitialized at image runtime: sun.security.provider.NativePRNG
Trace: object java.security.SecureRandom
method com.sun.jndi.dns.DnsClient.query(DnsName, int, int, boolean, boolean)
Call path from entry point to com.sun.jndi.dns.DnsClient.query(DnsName, int, int, boolean, boolean):
at com.sun.jndi.dns.DnsClient.query(DnsClient.java:178)
at com.sun.jndi.dns.Resolver.query(Resolver.java:81)
at com.sun.jndi.dns.DnsContext.c_getAttributes(DnsContext.java:434)
at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_getAttributes(ComponentDirContext.java:235)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.getAttributes(PartialCompositeDirContext.java:141)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.getAttributes(PartialCompositeDirContext.java:129)
at javax.naming.directory.InitialDirContext.getAttributes(InitialDirContext.java:142)
at io.micronaut.discovery.client.DnsResolver.getCNamesFromTxtRecord(DnsResolver.java:59)
at io.micronaut.discovery.client.EndpointUtil.getEC2DiscoveryUrlsFromZone(EndpointUtil.java:197)
at io.micronaut.discovery.client.EndpointUtil.getServiceUrlsFromDNS(EndpointUtil.java:141)


If I remove Consul integration, it works without any problem.



I could not find anything useful on the official documentation:



Microservices as GraalVM native images



Consul Support



Does anyone know where the problem is?










share|improve this question



















  • 1





    github.com/oracle/graal/issues/712

    – James Kleeh
    Mar 28 at 19:32

















1















I am trying to build a native image of a micronaut (v1.0.4) application.



This application uses Consul as service discovery.



I've created the app using --features option:



$ mn create-app my-app --features discovery-consul --features graal-native-image --build maven


The application works perfectly on my local machine, but when I try to build a docker container with the native image I get an error:



$ ./docker-build.sh 


error: No instances are allowed in the image heap for a class that is initialized or reinitialized at image runtime: 
sun.security.provider.NativePRNG
Detailed message:
Error: No instances are allowed in the image heap for a class that is initialized or reinitialized at image runtime: sun.security.provider.NativePRNG
Trace: object java.security.SecureRandom
method com.sun.jndi.dns.DnsClient.query(DnsName, int, int, boolean, boolean)
Call path from entry point to com.sun.jndi.dns.DnsClient.query(DnsName, int, int, boolean, boolean):
at com.sun.jndi.dns.DnsClient.query(DnsClient.java:178)
at com.sun.jndi.dns.Resolver.query(Resolver.java:81)
at com.sun.jndi.dns.DnsContext.c_getAttributes(DnsContext.java:434)
at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_getAttributes(ComponentDirContext.java:235)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.getAttributes(PartialCompositeDirContext.java:141)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.getAttributes(PartialCompositeDirContext.java:129)
at javax.naming.directory.InitialDirContext.getAttributes(InitialDirContext.java:142)
at io.micronaut.discovery.client.DnsResolver.getCNamesFromTxtRecord(DnsResolver.java:59)
at io.micronaut.discovery.client.EndpointUtil.getEC2DiscoveryUrlsFromZone(EndpointUtil.java:197)
at io.micronaut.discovery.client.EndpointUtil.getServiceUrlsFromDNS(EndpointUtil.java:141)


If I remove Consul integration, it works without any problem.



I could not find anything useful on the official documentation:



Microservices as GraalVM native images



Consul Support



Does anyone know where the problem is?










share|improve this question



















  • 1





    github.com/oracle/graal/issues/712

    – James Kleeh
    Mar 28 at 19:32













1












1








1








I am trying to build a native image of a micronaut (v1.0.4) application.



This application uses Consul as service discovery.



I've created the app using --features option:



$ mn create-app my-app --features discovery-consul --features graal-native-image --build maven


The application works perfectly on my local machine, but when I try to build a docker container with the native image I get an error:



$ ./docker-build.sh 


error: No instances are allowed in the image heap for a class that is initialized or reinitialized at image runtime: 
sun.security.provider.NativePRNG
Detailed message:
Error: No instances are allowed in the image heap for a class that is initialized or reinitialized at image runtime: sun.security.provider.NativePRNG
Trace: object java.security.SecureRandom
method com.sun.jndi.dns.DnsClient.query(DnsName, int, int, boolean, boolean)
Call path from entry point to com.sun.jndi.dns.DnsClient.query(DnsName, int, int, boolean, boolean):
at com.sun.jndi.dns.DnsClient.query(DnsClient.java:178)
at com.sun.jndi.dns.Resolver.query(Resolver.java:81)
at com.sun.jndi.dns.DnsContext.c_getAttributes(DnsContext.java:434)
at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_getAttributes(ComponentDirContext.java:235)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.getAttributes(PartialCompositeDirContext.java:141)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.getAttributes(PartialCompositeDirContext.java:129)
at javax.naming.directory.InitialDirContext.getAttributes(InitialDirContext.java:142)
at io.micronaut.discovery.client.DnsResolver.getCNamesFromTxtRecord(DnsResolver.java:59)
at io.micronaut.discovery.client.EndpointUtil.getEC2DiscoveryUrlsFromZone(EndpointUtil.java:197)
at io.micronaut.discovery.client.EndpointUtil.getServiceUrlsFromDNS(EndpointUtil.java:141)


If I remove Consul integration, it works without any problem.



I could not find anything useful on the official documentation:



Microservices as GraalVM native images



Consul Support



Does anyone know where the problem is?










share|improve this question














I am trying to build a native image of a micronaut (v1.0.4) application.



This application uses Consul as service discovery.



I've created the app using --features option:



$ mn create-app my-app --features discovery-consul --features graal-native-image --build maven


The application works perfectly on my local machine, but when I try to build a docker container with the native image I get an error:



$ ./docker-build.sh 


error: No instances are allowed in the image heap for a class that is initialized or reinitialized at image runtime: 
sun.security.provider.NativePRNG
Detailed message:
Error: No instances are allowed in the image heap for a class that is initialized or reinitialized at image runtime: sun.security.provider.NativePRNG
Trace: object java.security.SecureRandom
method com.sun.jndi.dns.DnsClient.query(DnsName, int, int, boolean, boolean)
Call path from entry point to com.sun.jndi.dns.DnsClient.query(DnsName, int, int, boolean, boolean):
at com.sun.jndi.dns.DnsClient.query(DnsClient.java:178)
at com.sun.jndi.dns.Resolver.query(Resolver.java:81)
at com.sun.jndi.dns.DnsContext.c_getAttributes(DnsContext.java:434)
at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_getAttributes(ComponentDirContext.java:235)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.getAttributes(PartialCompositeDirContext.java:141)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.getAttributes(PartialCompositeDirContext.java:129)
at javax.naming.directory.InitialDirContext.getAttributes(InitialDirContext.java:142)
at io.micronaut.discovery.client.DnsResolver.getCNamesFromTxtRecord(DnsResolver.java:59)
at io.micronaut.discovery.client.EndpointUtil.getEC2DiscoveryUrlsFromZone(EndpointUtil.java:197)
at io.micronaut.discovery.client.EndpointUtil.getServiceUrlsFromDNS(EndpointUtil.java:141)


If I remove Consul integration, it works without any problem.



I could not find anything useful on the official documentation:



Microservices as GraalVM native images



Consul Support



Does anyone know where the problem is?







java consul micronaut graalvm






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 27 at 21:20









jfcorugedojfcorugedo

6,1895 gold badges29 silver badges40 bronze badges




6,1895 gold badges29 silver badges40 bronze badges










  • 1





    github.com/oracle/graal/issues/712

    – James Kleeh
    Mar 28 at 19:32












  • 1





    github.com/oracle/graal/issues/712

    – James Kleeh
    Mar 28 at 19:32







1




1





github.com/oracle/graal/issues/712

– James Kleeh
Mar 28 at 19:32





github.com/oracle/graal/issues/712

– James Kleeh
Mar 28 at 19:32












1 Answer
1






active

oldest

votes


















0















After going over several issues and posts, I ended up finding the answer.



To remove this failure, just add this class com.sun.jndi.dns.DnsClient to the list of classes under the option --delay-class-initialization-to-runtime when you create the native image in you Dockerfile:



Dockerfile



RUN native-image --no-server 
...
--delay-class-initialization-to-runtime=...,com.sun.jndi.dns.DnsClient
-H:-UseServiceLoaderFeature
--allow-incomplete-classpath
-H:Name=model-quotes
-H:Class=model.quotes.Application
...


After doing that, everything works ok and the docker image is generated successfully.



It should be a good idea to add this class in Dockerfile generated by default. It is a bit annoying to generate a new project using Micronaut CLI and find that native images does not work without changing anything.






share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55386634%2fmicronaut-build-native-image-with-consul-dependency-does-not-work%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0















    After going over several issues and posts, I ended up finding the answer.



    To remove this failure, just add this class com.sun.jndi.dns.DnsClient to the list of classes under the option --delay-class-initialization-to-runtime when you create the native image in you Dockerfile:



    Dockerfile



    RUN native-image --no-server 
    ...
    --delay-class-initialization-to-runtime=...,com.sun.jndi.dns.DnsClient
    -H:-UseServiceLoaderFeature
    --allow-incomplete-classpath
    -H:Name=model-quotes
    -H:Class=model.quotes.Application
    ...


    After doing that, everything works ok and the docker image is generated successfully.



    It should be a good idea to add this class in Dockerfile generated by default. It is a bit annoying to generate a new project using Micronaut CLI and find that native images does not work without changing anything.






    share|improve this answer





























      0















      After going over several issues and posts, I ended up finding the answer.



      To remove this failure, just add this class com.sun.jndi.dns.DnsClient to the list of classes under the option --delay-class-initialization-to-runtime when you create the native image in you Dockerfile:



      Dockerfile



      RUN native-image --no-server 
      ...
      --delay-class-initialization-to-runtime=...,com.sun.jndi.dns.DnsClient
      -H:-UseServiceLoaderFeature
      --allow-incomplete-classpath
      -H:Name=model-quotes
      -H:Class=model.quotes.Application
      ...


      After doing that, everything works ok and the docker image is generated successfully.



      It should be a good idea to add this class in Dockerfile generated by default. It is a bit annoying to generate a new project using Micronaut CLI and find that native images does not work without changing anything.






      share|improve this answer



























        0














        0










        0









        After going over several issues and posts, I ended up finding the answer.



        To remove this failure, just add this class com.sun.jndi.dns.DnsClient to the list of classes under the option --delay-class-initialization-to-runtime when you create the native image in you Dockerfile:



        Dockerfile



        RUN native-image --no-server 
        ...
        --delay-class-initialization-to-runtime=...,com.sun.jndi.dns.DnsClient
        -H:-UseServiceLoaderFeature
        --allow-incomplete-classpath
        -H:Name=model-quotes
        -H:Class=model.quotes.Application
        ...


        After doing that, everything works ok and the docker image is generated successfully.



        It should be a good idea to add this class in Dockerfile generated by default. It is a bit annoying to generate a new project using Micronaut CLI and find that native images does not work without changing anything.






        share|improve this answer













        After going over several issues and posts, I ended up finding the answer.



        To remove this failure, just add this class com.sun.jndi.dns.DnsClient to the list of classes under the option --delay-class-initialization-to-runtime when you create the native image in you Dockerfile:



        Dockerfile



        RUN native-image --no-server 
        ...
        --delay-class-initialization-to-runtime=...,com.sun.jndi.dns.DnsClient
        -H:-UseServiceLoaderFeature
        --allow-incomplete-classpath
        -H:Name=model-quotes
        -H:Class=model.quotes.Application
        ...


        After doing that, everything works ok and the docker image is generated successfully.



        It should be a good idea to add this class in Dockerfile generated by default. It is a bit annoying to generate a new project using Micronaut CLI and find that native images does not work without changing anything.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 30 at 18:42









        jfcorugedojfcorugedo

        6,1895 gold badges29 silver badges40 bronze badges




        6,1895 gold badges29 silver badges40 bronze badges





















            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55386634%2fmicronaut-build-native-image-with-consul-dependency-does-not-work%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript