Bug 387188 - Validation constraints cannot be resolved.
Summary: Validation constraints cannot be resolved.
Status: REOPENED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2012-08-14 06:05 EDT by Hajo Lemcke CLA
Modified: 2022-10-22 17:31 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hajo Lemcke CLA 2012-08-14 06:05:13 EDT
Java compiler generates errors for constraint annotations like "@NotNull", "@Valid" and others.

Problem text = "NotNull cannot be resolved to a type"

The lib "validation-api-1.0.0.GA.jar" is part of the build path and contains the complete validation API.
The statement "import javax.validation.constraints.NotNull;" is in the source file.

Opening such a file with one of these problems, adding a character, removing it and saving the file leads to zero problems when Eclipse recompiled it. Activating the menu item "Project - Clean" recreates all problems.

This problem already existed in Indigo. Its available in Eclipse on Win XP, Win 7 and Linux.

Enabling or disabling annotation processing makes no difference.
Comment 1 Stephan Herrmann CLA 2012-08-14 15:33:31 EDT
I quickly tried what you describe but I cannot reproduce.
Apparently we need some more info.

Ideally you would put together a small test project exhibiting the error.
Could you do that?
Comment 2 Srikanth Sankaran CLA 2012-08-14 19:30:07 EDT
Very loosely speaking, parts of this problem sound like https://bugs.eclipse.org/bugs/show_bug.cgi?id=386356#c7,
but comment#0 mentions Indigo which would rule out 386356
and point to something else.
Comment 3 Hajo Lemcke CLA 2012-08-15 03:45:32 EDT
I'm not yet able to reproduce this problem in a smaller environment. I could give you access to our Subversion Repository. I think the problem may be related to the interdependent projects and the index management of Eclipse.

If subversion access is an option for you, please tell where I should send your credentials.
Comment 4 Hajo Lemcke CLA 2012-08-18 06:48:19 EDT
I did not really solve the issue, but I have some work-around.

The problem with validation constraints vanished after:

- copying all sources to a new workspace (no metadata, no classpath, ...)
- create all projects as new
- recreate all build paths manually

The effect can be reproduced when setting up an annotation processor (self written) which creates Remote Interface classes from annotated bean methods (@GenerateRemote) and create them in another project.

So the workaround is to create these files in ".apt_generated" in the same project and regularly start a job to copy newer files into the other project.

Well ... not perfect but at least working
Comment 5 Stephan Herrmann CLA 2012-08-18 07:02:32 EDT
(In reply to comment #4)
> I did not really solve the issue, but I have some work-around.

Thanks for reporting your workaround, which means this no longer is a blocker.
Still I'd like to find out if it's a bug in the tool.
 
> The effect can be reproduced when setting up an annotation processor (self
> written) which creates Remote Interface classes from annotated bean methods
> (@GenerateRemote) and create them in another project.

So I see three kinds of types: 

A) regular classes written by you
B) types created by the annotation processor
C) additional annotations inside the validation-api jar

Is this list complete?

No the compiler complains that C) cannot be found.
QUESTIONS: 
Where is that error reported, against A) or against B)?
Does the annotation processor evaluate annotations from C)?
Comment 6 Eclipse Genie CLA 2020-10-14 11:55:30 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 7 Eclipse Genie CLA 2022-10-22 17:31:29 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.