eclipse-ee4j / eclipse-ee4j/jersey

@Value members not populated without component-scan

Open
#3,455 3 comments 0 reactions 0 assignees View on GitHub
Priority: Major Type: Bug
Dominant language
Java
Stars
730
Forks
382
PR merge metrics
No merged PRs in 30d

Description

When using the jersey-spring3 module, the members of a class that is annotated with @Value isn't beeing populated, but @Autowired are.

Here is an example of the behaviour:

[https://github.com/alexanderkjall/jersey-jetty-interaction-example](https://github.com/alexanderkjall/jersey-jetty-interaction-example)

If

is added to applicationContext.xml then both fields are populated. Otherwise the field 'message' stays as null.

I guess that this is intended behavior, but it makes it harder for us to write unit-tests.

In our main code we have component-scan populated, but in our unit tests we need to controll the content of the spring context precisely, so there we don't have it.

We can work around this by have all annotation on setter methods, but that adds boilerplate code that would be nice to be without.

It would also be nice if this was documented somewhere, as I didn't manage to find any information about it online.
#### Affected Versions
[2.24]

Contributor guide

Open the contributing guide

Research direction

Start with the linked jersey-jetty-interaction-example and its applicationContext.xml, reproducing the difference with and without the component-scan entry. Confirm whether jersey-spring3 intentionally requires component scanning for @Value processing, then document the behavior, the unit-test implication, and the supported workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
backend
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.