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

Multiple Application Contexts created when running launch project with aws-lambda #2308

Open
trynow-david opened this issue Mar 5, 2025 · 0 comments

Comments

@trynow-david
Copy link

Expected Behavior

When you create a new launch project from the micronaut.io/launch, include the aws-lambda project, and run the application via ./gradlew run command, the application context is ran twice. This is due to the AwsApiProxyTestServer embedded server class building and running a new application context. The Jetty embedded server class you get if you change the micronaut runtime to jetty rather than lambda_java does not create a new application context but uses the one that already exists so I believe this is a bug.

Actual Behaviour

Multiple application contexts are built and run.

Steps To Reproduce

Download the basic launch project with aws-lambda feature. Below is the config I used.

applicationType: default
defaultPackage: com.example
testFramework: junit
sourceLanguage: kotlin
buildTool: gradle_kotlin
features: [app-name, aws-lambda, aws-lambda-events-serde, aws-lambda-handler-default, gradle, http-client-test, junit, kotlin, kotlin-application, ksp, logback, micronaut-aot, micronaut-build, micronaut-http-validation, properties, readme, serialization-jackson, shade, snapstart, static-resources, x86]

To show the effect, I created a simple Singleton that runs on a schedule which then you can see is created twice.

@Singleton
class HomeService {
    companion object {
        private val LOG: Logger = LoggerFactory.getLogger(this::class.java)
    }
    init {
        LOG.info("HomeService initialized with UUID: ${UUID.randomUUID()}")
    }

    @Scheduled(fixedDelay = "5s")
    fun test(){
        LOG.info("HomeService test method called")
    }
}

Image

Environment Information

  • Mac OS 14.5 (23F79)

Example Application

No response

Version

micronautVersion=4.7.6

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

No branches or pull requests

1 participant