Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to build using GraalVM native-image tool using spring jdbc and micronaut #715

Closed
nikitakakra opened this issue Sep 4, 2020 · 6 comments

Comments

@nikitakakra
Copy link

Hi, I am trying to use GraalVM native-image tool to build a simple Micronaut application, but I am getting an exception.
The application is a simple which gets the data from the database and writes it to the database which is hosted on aws lambda .
I am using following version

  • Micronaut : 1.3.6 or 1.3.4

  • Spring-jdbc: 5.2.8.RELEASE

  • GraalVM:19.2.1

  • AWS SDK:2.12.0

Below is the exception that I am getting.

Error: Classes that should be initialized at run time got initialized during image building:
 org.springframework.jdbc.datasource.ConnectionProxy was unintentionally initialized at build time. com.sun.proxy.$Proxy298 caused initialization of this class with the following trace: 

com.oracle.svm.core.util.UserError$UserException: Classes that should be initialized at run time got initialized during image building:
 org.springframework.jdbc.datasource.ConnectionProxy was unintentionally initialized at build time. com.sun.proxy.$Proxy298 caused initialization of this class with the following trace: 

    at com.oracle.svm.core.util.UserError.abort(UserError.java:65)
    at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.checkDelayedInitialization(ConfigurableClassInitialization.java:494)
    at com.oracle.svm.hosted.classinitialization.ClassInitializationFeature.duringAnalysis(ClassInitializationFeature.java:188)
    at com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$8(NativeImageGenerator.java:711)
    at com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:63)
    at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:711)
    at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:526)
    at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:444)
    at java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1386)
    at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
    at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
    at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
    at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Error: Image build request failed with exit status 1

[Container]  Command did not exit successfully ./build-native-image.sh exit status 1
[Container] Phase complete: BUILD State: FAILED

I am using the following arguments in native-image.properties

Args =-H:+ReportExceptionStackTraces \
      -H:+PrintClassInitialization \
      -H:+TraceClassInitialization \
      -H:EnableURLProtocols=http \
      -H:IncludeResources="logback.xml|application.properties|git.properties|ESAPI.properties" \
	  -H:DynamicProxyConfigurationFiles=dynamic-proxies.json \
	  -H:Log=registerResource \
	  -H:Name=server \
      -H:Class=io.micronaut.function.aws.runtime.MicronautLambdaRuntime \
      -H:+ReportUnsupportedElementsAtRuntime \
      -H:-AllowVMInspection \
      --allow-incomplete-classpath \
      --initialize-at-build-time=software.amazon.awssdk.protocols.core.StringToValueConverter,org.apache.http.conn.routing.HttpRoute,org.apache.http.protocol.HttpContext,org.apache.http.HttpClientConnection,org.apache.http.pool.ConnPoolControl,org.apache.http.conn.HttpClientConnectionManager,org.apache.http.conn.ConnectionRequest,org.apache.xerces.jaxp.SAXParserFactoryImpl \
      --initialize-at-run-time=io.micronaut.http.bind.binders.ContinuationArgumentBinder

and this is my build.gradle

plugins {
    id "net.ltgt.apt-eclipse" version "0.21"
    id "com.github.johnrengelman.shadow" version "5.2.0"
    id "application"
    id "com.gorylenko.gradle-git-properties" version "2.2.2"
}

version "0.1"
group "com.example.abc"

repositories {
    mavenCentral()
    jcenter()
}

configurations {
    // for dependencies that are needed for development only
    developmentOnly
    all {
            exclude group: "commons-logging"
    }
}

dependencies {
    developmentOnly "io.micronaut:micronaut-http-server-netty:$micronautVersion"
    annotationProcessor platform("io.micronaut:micronaut-bom:$micronautVersion")
    annotationProcessor "io.micronaut:micronaut-inject-java"
    annotationProcessor "io.micronaut:micronaut-validation"
    annotationProcessor "io.micronaut:micronaut-graal"
    
    implementation platform("io.micronaut:micronaut-bom:$micronautVersion")    
	implementation "io.micronaut:micronaut-http-client"
    implementation "io.micronaut:micronaut-validation"
	implementation "io.micronaut:micronaut-management"
    implementation "io.micronaut:micronaut-runtime"
    implementation "javax.annotation:javax.annotation-api"

    implementation ("io.micronaut:micronaut-inject:$micronautVersion"){
    	exclude group: "org.yaml", module: "snakeyaml"
    }
	implementation "org.yaml:snakeyaml:1.26"


    implementation("io.micronaut.aws:micronaut-function-aws-custom-runtime:$micronautVersion") {
        exclude group: "com.fasterxml.jackson.module", module: "jackson-module-afterburner"
        exclude group: "io.micronaut", module: "micronaut-http-server-netty"
         exclude group: "io.micronaut", module: "micronaut-http-client"
    }
    implementation("io.micronaut.aws:micronaut-function-aws-api-proxy:$micronautVersion") {
        exclude group: "com.fasterxml.jackson.module", module: "jackson-module-afterburner"
        exclude group: "io.micronaut", module: "micronaut-http-server-netty"
        exclude group: "io.micronaut", module: "micronaut-http-client"
    }
	
	//aws functionalities
	compile "software.amazon.awssdk:ssm:${awssdkVersion}"
	compile "software.amazon.awssdk:s3:${awssdkVersion}"
	compile "software.amazon.awssdk:lambda:${awssdkVersion}"
	compile "software.amazon.awssdk:kms:${awssdkVersion}"
	compile "com.auth0:java-jwt:3.10.2"
	compileOnly "org.graalvm.nativeimage:svm:19.3.0"
	compile "org.slf4j:jcl-over-slf4j:1.7.30"
   	runtimeOnly "ch.qos.logback:logback-classic:1.3.0-alpha5"
   	
   
	
   	//spring 
	compile group: 'org.springframework', name: 'spring-jdbc', version: '5.2.8.RELEASE'
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '2.3.2.RELEASE'
    compile group: 'org.owasp.esapi', name: 'esapi', version: '2.2.0.0'
    compile group: 'org.mariadb.jdbc', name: 'mariadb-java-client', version: '2.6.2'
    compile "io.micronaut.configuration:micronaut-jdbc-hikari"
        
    
    testAnnotationProcessor platform("io.micronaut:micronaut-bom:$micronautVersion")

    testAnnotationProcessor "io.micronaut:micronaut-inject-java"
    testImplementation platform("io.micronaut:micronaut-bom:$micronautVersion")
    testImplementation "io.micronaut.test:micronaut-test-junit5"
    
    testCompile 'org.junit.jupiter:junit-jupiter-api:5.5.0'
	testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.5.0'
	testCompile group: 'org.mockito', name: 'mockito-core', version: '2.1.0'
}

test.classpath += configurations.developmentOnly

mainClassName = "com.example.Application"

// use JUnit 5 platform
test {
    useJUnitPlatform()
}

shadowJar {
    mergeServiceFiles()
}

run.classpath += configurations.developmentOnly
run.jvmArgs('-Dmicronaut.environments=dev','-noverify', '-XX:TieredStopAtLevel=1', '-Dcom.sun.management.jmxremote')

tasks.withType(JavaCompile){
    options.encoding = "UTF-8"
    options.compilerArgs.add('-parameters')
}

gitProperties {
	keys = ['git.branch','git.commit.id','git.commit.message.short','git.commit.time','git.commit.user.name','git.commit.user.email']
}

I have already added the org.springframework.jdbc.datasource.ConnectionProxy in dynamic-proxies.json

@ilopmar
Copy link
Contributor

ilopmar commented Sep 4, 2020

I'm not saying that the following will fix your issue but definitely can help:

You are using an old version of GraalVM. Current one is 20.2.0. For Micronaut 1.3.x we support GraalVM 20.1.0 so at least you should try to upgrade to that version because a lot has changed since 19.2.1.

Also keep in mind that we've done a lot of improvements to GraalVM support for data access but you should upgrade to Micronaut 2.x to get them (and then to GraalVM 20.2.0).

If you want to make sure that native images work, I suggest you to use Micronaut Data JDBC instead of Spring JDBC.

@nikitakakra
Copy link
Author

@ilopmar I have tried to update to the Micronaut Data:1.1.0 and GraalVM:20.2.0 and Micronaut:1.3.6 as per your suggestion, but I am getting the below exception while trying to build the native-image

Error: Classes that should be initialized at run time got initialized during image building:
 org.apache.xerces.impl.Constants was unintentionally initialized at build time. org.apache.xerces.impl.Constants has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=org.apache.xerces.impl.Constants
org.apache.xerces.impl.XMLVersionDetector was unintentionally initialized at build time. org.apache.xerces.impl.XMLVersionDetector has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=org.apache.xerces.impl.XMLVersionDetector
org.apache.xerces.impl.dv.ObjectFactory was unintentionally initialized at build time. org.apache.xerces.impl.dv.ObjectFactory has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=org.apache.xerces.impl.dv.ObjectFactory
org.apache.xerces.impl.XMLScanner was unintentionally initialized at build time. org.apache.xerces.impl.XMLScanner has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=org.apache.xerces.impl.XMLScanner
org.apache.xerces.impl.dtd.XMLDTDValidator was unintentionally initialized at build time. org.apache.xerces.impl.dtd.XMLDTDValidator has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=org.apache.xerces.impl.dtd.XMLDTDValidator
org.apache.xerces.impl.dtd.XMLNSDTDValidator was unintentionally initialized at build time. org.apache.xerces.impl.dtd.XMLNSDTDValidator has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=org.apache.xerces.impl.dtd.XMLNSDTDValidator
org.apache.xerces.util.XMLChar was unintentionally initialized at build time. org.apache.xerces.util.XMLChar has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=org.apache.xerces.util.XMLChar
org.apache.xerces.impl.dtd.XMLDTDProcessor was unintentionally initialized at build time. org.apache.xerces.impl.dtd.XMLDTDProcessor has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=org.apache.xerces.impl.dtd.XMLDTDProcessor
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl was unintentionally initialized at build time. org.apache.xerces.impl.XMLDocumentFragmentScannerImpl has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=org.apache.xerces.impl.XMLDocumentFragmentScannerImpl
org.apache.xerces.impl.XMLDTDScannerImpl was unintentionally initialized at build time. org.apache.xerces.impl.XMLDTDScannerImpl has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=org.apache.xerces.impl.XMLDTDScannerImpl
org.apache.xerces.util.XMLSymbols was unintentionally initialized at build time. org.apache.xerces.util.XMLSymbols has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=org.apache.xerces.util.XMLSymbols
org.apache.xerces.impl.XMLDocumentScannerImpl was unintentionally initialized at build time. org.apache.xerces.impl.XMLDocumentScannerImpl has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=org.apache.xerces.impl.XMLDocumentScannerImpl
org.apache.xerces.impl.XMLEntityScanner was unintentionally initialized at build time. org.apache.xerces.impl.XMLEntityScanner has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=org.apache.xerces.impl.XMLEntityScanner
org.apache.xerces.impl.XMLEntityManager$EncodingInfo was unintentionally initialized at build time. org.apache.xerces.impl.XMLEntityManager$EncodingInfo has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=org.apache.xerces.impl.XMLEntityManager$EncodingInfo
org.apache.xerces.impl.XMLEntityManager was unintentionally initialized at build time. org.apache.xerces.impl.XMLEntityManager has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=org.apache.xerces.impl.XMLEntityManager
org.apache.xerces.parsers.ObjectFactory was unintentionally initialized at build time. org.apache.xerces.parsers.ObjectFactory has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=org.apache.xerces.parsers.ObjectFactory
org.apache.xerces.impl.XMLNSDocumentScannerImpl was unintentionally initialized at build time. org.apache.xerces.impl.XMLNSDocumentScannerImpl has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=org.apache.xerces.impl.XMLNSDocumentScannerImpl
org.apache.xerces.xni.NamespaceContext was unintentionally initialized at build time. org.apache.xerces.xni.NamespaceContext has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=org.apache.xerces.xni.NamespaceContext

com.oracle.svm.core.util.UserError$UserException: Classes that should be initialized at run time got initialized during image building:
 org.apache.xerces.impl.Constants was unintentionally initialized at build time. org.apache.xerces.impl.Constants has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=org.apache.xerces.impl.Constants
org.apache.xerces.impl.XMLVersionDetector was unintentionally initialized at build time. org.apache.xerces.impl.XMLVersionDetector has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=org.apache.xerces.impl.XMLVersionDetector
org.apache.xerces.impl.dv.ObjectFactory was unintentionally initialized at build time. org.apache.xerces.impl.dv.ObjectFactory has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=org.apache.xerces.impl.dv.ObjectFactory
org.apache.xerces.impl.XMLScanner was unintentionally initialized at build time. org.apache.xerces.impl.XMLScanner has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=org.apache.xerces.impl.XMLScanner
org.apache.xerces.impl.dtd.XMLDTDValidator was unintentionally initialized at build time. org.apache.xerces.impl.dtd.XMLDTDValidator has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=org.apache.xerces.impl.dtd.XMLDTDValidator
org.apache.xerces.impl.dtd.XMLNSDTDValidator was unintentionally initialized at build time. org.apache.xerces.impl.dtd.XMLNSDTDValidator has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=org.apache.xerces.impl.dtd.XMLNSDTDValidator
org.apache.xerces.util.XMLChar was unintentionally initialized at build time. org.apache.xerces.util.XMLChar has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=org.apache.xerces.util.XMLChar
org.apache.xerces.impl.dtd.XMLDTDProcessor was unintentionally initialized at build time. org.apache.xerces.impl.dtd.XMLDTDProcessor has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=org.apache.xerces.impl.dtd.XMLDTDProcessor
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl was unintentionally initialized at build time. org.apache.xerces.impl.XMLDocumentFragmentScannerImpl has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=org.apache.xerces.impl.XMLDocumentFragmentScannerImpl
org.apache.xerces.impl.XMLDTDScannerImpl was unintentionally initialized at build time. org.apache.xerces.impl.XMLDTDScannerImpl has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=org.apache.xerces.impl.XMLDTDScannerImpl
org.apache.xerces.util.XMLSymbols was unintentionally initialized at build time. org.apache.xerces.util.XMLSymbols has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=org.apache.xerces.util.XMLSymbols
org.apache.xerces.impl.XMLDocumentScannerImpl was unintentionally initialized at build time. org.apache.xerces.impl.XMLDocumentScannerImpl has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=org.apache.xerces.impl.XMLDocumentScannerImpl
org.apache.xerces.impl.XMLEntityScanner was unintentionally initialized at build time. org.apache.xerces.impl.XMLEntityScanner has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=org.apache.xerces.impl.XMLEntityScanner
org.apache.xerces.impl.XMLEntityManager$EncodingInfo was unintentionally initialized at build time. org.apache.xerces.impl.XMLEntityManager$EncodingInfo has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=org.apache.xerces.impl.XMLEntityManager$EncodingInfo
org.apache.xerces.impl.XMLEntityManager was unintentionally initialized at build time. org.apache.xerces.impl.XMLEntityManager has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=org.apache.xerces.impl.XMLEntityManager
org.apache.xerces.parsers.ObjectFactory was unintentionally initialized at build time. org.apache.xerces.parsers.ObjectFactory has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=org.apache.xerces.parsers.ObjectFactory
org.apache.xerces.impl.XMLNSDocumentScannerImpl was unintentionally initialized at build time. org.apache.xerces.impl.XMLNSDocumentScannerImpl has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=org.apache.xerces.impl.XMLNSDocumentScannerImpl
org.apache.xerces.xni.NamespaceContext was unintentionally initialized at build time. org.apache.xerces.xni.NamespaceContext has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=org.apache.xerces.xni.NamespaceContext

        at com.oracle.svm.core.util.UserError.abort(UserError.java:68)
        at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.checkDelayedInitialization(ConfigurableClassInitialization.java:526)
        at com.oracle.svm.hosted.classinitialization.ClassInitializationFeature.duringAnalysis(ClassInitializationFeature.java:227)
        at com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$8(NativeImageGenerator.java:732)
        at com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:70)
        at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:732)
        at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:555)
        at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:468)
        at java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1386)
        at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
        at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
        at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
        at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:163)
Error: Image build request failed with exit status 1

Below is the build.gradle

plugins {
    id "net.ltgt.apt-eclipse" version "0.21"
    id "com.github.johnrengelman.shadow" version "5.2.0"
    id "application"
    id "com.gorylenko.gradle-git-properties" version "2.2.2"
}

version "0.1"
group "com.example.abc"

repositories {
    mavenCentral()
    jcenter()
}

configurations {
	developmentOnly
	all {
		exclude group: "commons-logging"
		resolutionStrategy {
			eachDependency { DependencyResolveDetails details ->
				// specifying a fixed version for all libraries with 'io.micronaut.data' group
				if (details.requested.group == 'io.micronaut.data') {
					details.useVersion micronautDataVersion
				}
			}
		}
	}
}

dependencies {
    developmentOnly "io.micronaut:micronaut-http-server-netty:$micronautVersion"
    annotationProcessor platform("io.micronaut:micronaut-bom:$micronautVersion")
    annotationProcessor "io.micronaut:micronaut-inject-java"
    annotationProcessor "io.micronaut:micronaut-validation"
    annotationProcessor "io.micronaut:micronaut-graal"
    annotationProcessor "io.micronaut.data:micronaut-data-processor:$micronautDataVersion"
    
    implementation platform("io.micronaut:micronaut-bom:$micronautVersion")    
	implementation "io.micronaut:micronaut-http-client"
    implementation "io.micronaut:micronaut-validation"
	implementation "io.micronaut:micronaut-management"
    implementation "io.micronaut:micronaut-runtime"
    implementation "javax.annotation:javax.annotation-api"
    implementation "io.micronaut.data:micronaut-data-jdbc:$micronautDataVersion"

    implementation ("io.micronaut:micronaut-inject:$micronautVersion"){
    	exclude group: "org.yaml", module: "snakeyaml"
    }
	implementation "org.yaml:snakeyaml:1.26"


    implementation("io.micronaut.aws:micronaut-function-aws-custom-runtime:$micronautVersion") {
        exclude group: "com.fasterxml.jackson.module", module: "jackson-module-afterburner"
        exclude group: "io.micronaut", module: "micronaut-http-server-netty"
         exclude group: "io.micronaut", module: "micronaut-http-client"
    }
    implementation("io.micronaut.aws:micronaut-function-aws-api-proxy:$micronautVersion") {
        exclude group: "com.fasterxml.jackson.module", module: "jackson-module-afterburner"
        exclude group: "io.micronaut", module: "micronaut-http-server-netty"
        exclude group: "io.micronaut", module: "micronaut-http-client"
    }
	
	//aws functionalities
	compile "software.amazon.awssdk:ssm:${awssdkVersion}"
	compile "software.amazon.awssdk:s3:${awssdkVersion}"
	compile "software.amazon.awssdk:lambda:${awssdkVersion}"
	compile "software.amazon.awssdk:kms:${awssdkVersion}"
	compile "com.auth0:java-jwt:3.10.2"
	compileOnly "org.graalvm.nativeimage:svm:19.3.0"
	compile "org.slf4j:jcl-over-slf4j:1.7.30"
   	runtimeOnly "ch.qos.logback:logback-classic:1.3.0-alpha5"
   	
   
	
   	//spring 
	//compile group: 'org.springframework', name: 'spring-jdbc', version: '5.2.8.RELEASE'
    //compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '2.3.2.RELEASE'
    compile group: 'org.owasp.esapi', name: 'esapi', version: '2.2.0.0'
    
    
    //micronaut data
	implementation "jakarta.persistence:jakarta.persistence-api:2.2.2"
	implementation "io.micronaut.data:micronaut-data-tx:$micronautDataVersion"
	implementation "io.micronaut.data:micronaut-data-jdbc:$micronautDataVersion"
	runtime "org.mariadb.jdbc:mariadb-java-client:2.5.2"
	runtime "io.micronaut.configuration:micronaut-jdbc-hikari"
    
    testAnnotationProcessor platform("io.micronaut:micronaut-bom:$micronautVersion")

    testAnnotationProcessor "io.micronaut:micronaut-inject-java"
    testImplementation platform("io.micronaut:micronaut-bom:$micronautVersion")
    testImplementation "io.micronaut.test:micronaut-test-junit5"
    
    testCompile 'org.junit.jupiter:junit-jupiter-api:5.5.0'
	testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.5.0'
	testCompile group: 'org.mockito', name: 'mockito-core', version: '2.1.0'
}

test.classpath += configurations.developmentOnly

mainClassName = "com.example.Application"

// use JUnit 5 platform
test {
    useJUnitPlatform()
}

shadowJar {
    mergeServiceFiles()
}

run.classpath += configurations.developmentOnly
run.jvmArgs('-Dmicronaut.environments=dev','-noverify', '-XX:TieredStopAtLevel=1', '-Dcom.sun.management.jmxremote')

tasks.withType(JavaCompile){
    options.encoding = "UTF-8"
    options.compilerArgs.add('-parameters')
}

gitProperties {
	keys = ['git.branch','git.commit.id','git.commit.message.short','git.commit.time','git.commit.user.name','git.commit.user.email']
}

@ilopmar
Copy link
Contributor

ilopmar commented Sep 9, 2020

Micronaut 1.3.x is only compatible out-of-the-box with GraalVM 20.1.0. If you want to use GraalVM 20.2.0 you need to upgrade your application to Micronaut 2.

Another option to use Micronaut 1.3.x and GraalVM 20.2.0 is to try what the error message suggests, I mean, adding all those classes as --initialize-at-build-time=xxxxxx

@nikitakakra
Copy link
Author

nikitakakra commented Sep 9, 2020

I tried to add all those classes as --initialize-at-build-time=xxxxxx but it goes into cyclic error,i.e if I initialize it with --initialize-at-build-time=xxxxxx the error say to initialized at run time --initialize-at-run-time=xxxxxx.
Even I tried it with Graavlm:19.2.1 and Micronaut:1.3.6 it's giving the same error

@ilopmar
Copy link
Contributor

ilopmar commented Sep 9, 2020

Then my previous suggestion is your only option:
Micronaut 1.3.x and GraalVM 20.1.0 or Micronaut 2.0 and GraalVM 20.2.0

@nikitakakra
Copy link
Author

nikitakakra commented Sep 10, 2020

I was able to build the native-image with Micronaut:2.0.0 and Graavlm:19.2.1. , However, it fails when I try to invoke any endpoint with a warning

�[36m07:29:45.142�[0;39m �[1;30m[main]�[0;39m �[31mWARN �[0;39m �[35ms.a.a.h.a.internal.utils.ApacheUtils�[0;39m - NoSuchMethodException was thrown when disabling normalizeUri. This indicates you are using an old version (< 4.5.8) of Apache http client. It is recommended to use http client version >= 4.5.9 to avoid the breaking change introduced in apache client 4.5.7 and the latency in exception handling. See https://github.com/aws/aws-sdk-java/issues/1919 for more information

and with the below error

java.lang.UnsatisfiedLinkError: sun.security.ec.ECKeyPairGenerator.isCurveSupported([B)Z [symbol: Java_sun_security_ec_ECKeyPairGenerator_isCurveSupported or Java_sun_security_ec_ECKeyPairGenerator_isCurveSupported___3B]

In my Gradle dependency tree, I could not find any dependency which is using org.apache.httpcomponents:httpclient:4.5.7 or lesser version.
After Debugging found out that is failing when invoking the aws-sdk-ssm service

PS: I looked into this aws/aws-sdk-java#1919 and other related issue but no luck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants