eclipse-ee4j / eclipse-ee4j/jersey

Validation annotation not seen when bean packaged in different jar

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

Description

Given this ear structure@

```
app.ear
| --APP-INF
| | -- lib
| | -- common-entities.jar
| --ejb.jar
| --war.war
```

Define an entity mapping a table in common-entities.jar and add some validation annotation to its fields, like @NotNull.

```
**EntityDto.java**@Entity
public class EntityDto {

@Id
@XmlAttribute
@NotNull
private Long id

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}
}
```

in the war define a jar-rs class:

```
**TestValidation.java**
@Path("/test")
public class TestValidation {

@PUT
@Path("/{id}")
@Produces(MediaType.APPLICATION_JSON)
public EntityDto update(@PathParam("id") String id, @Valid EntityDto bean){
return bean;
}
}
```

If the update method gets invoked the validation run but the @NotNull annotation gets ignored.
If I move the EntitiyDto inside the war, the validation runs fine, and the @NotNull is evaluated.
#### Environment
weblogic 12.1.3
#### Affected Versions
[2.22.2]

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the EAR deployment on WebLogic 12.1.3 with EntityDto.java in common-entities.jar and TestValidation.java in the WAR, then compare it with EntityDto.java packaged in the WAR. Done means @NotNull on EntityDto.id is evaluated for the @Valid request bean in both layouts.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.