Skip to content

Java function host failed to discover main classes for spring cloud function #338

Closed
@Flanker32

Description

@Flanker32

Function host can't find the main class of spring cloud functions and report error. Both in azure services and local.

Investigative information

Function core tools 2.7.1948

Repro steps

  1. Prepare a spring cloud function project, could do it by git clone https://github.com/Azure-Samples/hello-spring-function-azure.git.
  2. Build the spring cloud function project by mvn clean package
  3. Invoke the function locally by mvn azure-functions:run.
    • This issue could also repo in service side, just remove the MAIN_CLASS settings in azure function configuration

Expected behavior

The main class of the function should be automatically found. The MAIN_CLASS property should not need to be specified and users could access the function by curl http://localhost:7071/api/hello -d "{\"name\":\"Azure\"}"

Actual behavior

No response from curl, function host reports

 java.lang.IllegalStateException: Failed to discover main class. An attempt was made to discover main class as 'MAIN_CLASS' environment variable, system property as well as entry in META-INF/MANIFEST.MF (in that order).

Known workarounds

Set the MAIN_CLASS in app settings, for local run, add a local.settings.json file with MAIN_CLASS specified

Related information

Referred microsoft/azure-maven-plugins#912

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions