"cannot resolve symbol" for a class generated by an annotation processor

Answered

Dear community,

I certainly miss something, since I found a couple of posts related to this topic. However, I could not manage to solve the issue.

Basically, I'm using an annotation processor to generate the canonical metamodel for my JPA entity classes, in a project with an JEE ear, containing a library and an EJB module. Here using EclipseLink, but I guess the implementation doesn't really matter. IntelliJ successfully compiles everything, packages artifacts, deploy them on (here: Glassfish, but don't think it matters), and everything works perfectly.

But, despite compilation succeeds, IntelliJ's editor reports "Cannot resolve symbol" for the generated classes.

I've tried "Invalidate Caches & Restart" (found in several posts): not solved.

I've tried build/rebuild/...: not solved.

Can somebody please help me?

0
6 comments

Do you see a directory with the generates sources in the project view?

Try to right click on it and configure it as the Generated Sources Root:

2
Avatar
Permanently deleted user

Thanks for the very fast reply.

Unfortunately, that's not that easy. As you can see on the following screenshot, the "Mark Directory as" entry is absent from the pop-up menu on this folder. Or... does it mean that the generated classes cannot be located in the output directory?

0

Either place them outside of output directory or remove the exclusion of output from the project (may affect performance).

0
Avatar
Permanently deleted user

I just moved to another place out of the output directory. It works.

Thanks a lot!

0
Avatar
Permanently deleted user

Hi,

I am facing the same issue. I configured the generated class by annotation processor to folder src/jpaMetaModel/java/ and tried to mark src/jpaMetaModel or src/jpaMetaModel/java/ as generated sources root, but these classes still cannot be resolved. Is these any other solution?

0

Please file an issue at https://youtrack.jetbrains.com/issues/IDEA and provide your build.gradle files.

0

Please sign in to leave a comment.