Skip to content
This repository was archived by the owner on Feb 23, 2023. It is now read-only.
This repository was archived by the owner on Feb 23, 2023. It is now read-only.

Spring Cloud Function not working with Tomcat #368

Closed

Description

@dsyer

The sample is Netty so I guess we just never tested this yet. The error at runtime is:

Exception in thread "main" java.lang.IllegalArgumentException: Cannot instantiate interface org.springframework.context.ApplicationContextInitializer : org.springframework.cloud.function.web.function.FunctionEndpointInitializer
        at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:467)
        at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:449)
        at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:442)
        at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:284)
        at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:264)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1309)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1298)
        at org.knative.examples.cloudevents.spring.CloudEventSampleApplication.main(CloudEventSampleApplication.java:26)
Caused by: java.lang.NoSuchMethodException: org.springframework.cloud.function.web.function.FunctionEndpointInitializer.<init>()
        at java.lang.Class.getConstructor0(DynamicHub.java:3082)
        at java.lang.Class.getDeclaredConstructor(DynamicHub.java:2178)
        at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:462)
        ... 7 more

Activity

  1. added this to the 0.8.3 milestone on Nov 19, 2020
  2. dsyer commented on Nov 19, 2020

    @dsyer
    ContributorAuthor

    I tried fixing this by making the conditional class present check in FunctionEndpointInitializer static, and adding it to --initialize-at-build-time. Didn't work.

  3. sdeleuze commented on Nov 19, 2020

    @sdeleuze
    Contributor

    With verbose logs during the build I see in the logs:

    WARNING: Could not register reflection metadata for org.springframework.cloud.function.web.function.FunctionEndpointInitializer. Reason: java.lang.NoClassDefFoundError: org/springframework/web/reactive/function/server/RouterFunction
    

    @aclement Is there some fine tuning needed on the feature side?

  4. aclement commented on Nov 19, 2020

    @aclement
    Contributor

    Just to clarify that message (WARNING: Could not register reflection) is not from us, it is from GraalVM, but I will take a look.

  5. sdeleuze commented on Nov 19, 2020

    @sdeleuze
    Contributor

    I think the error is on Spring Cloud Function side, the classpath check is done on org.springframework.http.server.reactive.HttpHandler which is in spring-web so present when Spring MVC is used. The check should probably done using org.springframework.web.reactive.function.server.RouterFunction if the intent is to make it work only when spring-webflux is in the classpath.

  6. removed this from the 0.8.3 milestone on Nov 19, 2020
  7. self-assigned this
    on Nov 19, 2020
  8. added
    status: declined
    on Nov 19, 2020
  9. dsyer commented on Nov 20, 2020

    @dsyer
    ContributorAuthor

    Still not working. Re-opening.

  10. reopened this on Nov 20, 2020
  11. added this to the 0.8.3 milestone on Nov 20, 2020
  12. removed
    status: declined
    on Nov 20, 2020
  13. removed their assignment
    on Nov 21, 2020
  14. sdeleuze commented on Nov 21, 2020

    @sdeleuze
    Contributor

    As analyzed by @aclement, the root issue is the RouterFunction lambda not it the classpath that makes the reflection entry not taken in account.

    We should probably wait 0.9.0 and #345 to fix it.

  15. modified the milestones: 0.8.3, 0.9.0 on Nov 21, 2020
  16. added
    type: compatibility
    on Jan 8, 2021
  17. self-assigned this
    on Jan 12, 2021
  18. sdeleuze commented on Feb 8, 2021

    @sdeleuze
    Contributor

    @dsyer Could you please remind me how to reproduce the issue? Since we now have the build-time infrastructure we should be able to give it another try.

  19. dsyer commented on Feb 8, 2021

    @dsyer
    ContributorAuthor

    Just switch the sample from webflux to web MVC. That should do it.

  20. sdeleuze commented on Feb 9, 2021

    @sdeleuze
    Contributor

    It seems this issue is now gone with GraalVM 21.0.0 and our new build-time infrastructure.

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

Metadata

Metadata

Assignees

Labels

type: compatibility

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions