Skip to content

Unable to resolve place holders in @RequestMapping #1406

Open
@adriendengreville

Description

@adriendengreville

Using spring-hateoas:1.2.1 with Spring Boot 2.4.0:

When a REST controller class annotated with @RequestMapping("${some-variable}/resources") returns a resource extending RepresentationModel, I get the following error :

{
"label": "uncatched exception",
"detailMessage": "Not enough variable values available to expand 'some-variable'",
"statusCode": 500
}

I pinned the issue to this suspect line in the core library :

WebApplicationContext context = ContextLoader.getCurrentWebApplicationContext();

From what I could read, ContextLoader.getCurrentWebApplicationContext() doesn't return the expected context when using Spring Boot, and it's actually returning null when I place a breakpoint there :
image
You can see (L.92) that the resolvePlaceholders method won't be called, explaining my error since the raw string is passed on.

Any idea on how we could fix this ? :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions