Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Compiling JPA metamodel generated by Annotation Processor
Compiling JPA metamodel generated by Annotation Processor [message #532974] Tue, 11 May 2010 14:04 Go to next message
Eclipse UserFriend
I might be missing something obvious, but I've been googling for hours on this and found no answers...
I have enabled annotation processing in a java project, then added on the factory settings the eclipselink-jpa-modelgen_2.0.2-XXXX.jar. As I have GlassFish V3 as library, the needed classes for the processing itself are already on classpath.
The JPA 2 metamodel classes are correctly generated, but they are not compiled. So, I can use them (autocomplete works, etc), but always have compile errors stating that those classes couldn't be found.
In fact, they are not compiled into my output folder, despite being in the source path.
What am I doing wrong?
Re: Compiling JPA metamodel generated by Annotation Processor [message #532982 is a reply to message #532974] Tue, 11 May 2010 14:25 Go to previous messageGo to next message
Eclipse UserFriend
Murphy's law applied: Search a solution for hours - nothing. Ask for help. On a few minutes, you'll find the answer...

Ok, for those who might be struggling with this: On the project properties > Annotation processing > Factory path, select the jar containing the processor definition (eclipselink-jpa-modelgen_2.0.2-XXXX.jar in this case), click Advanced... and check "Run this container's processors in batch mode".

Done.
Re: Compiling JPA metamodel generated by Annotation Processor [message #533043 is a reply to message #532982] Wed, 12 May 2010 01:54 Go to previous messageGo to next message
Eclipse UserFriend
Luis Fernando Planella Gonzalez wrote:
> Murphy's law applied: Search a solution for hours - nothing. Ask for
> help. On a few minutes, you'll find the answer...
>
> Ok, for those who might be struggling with this: On the project
> properties > Annotation processing > Factory path, select the jar
> containing the processor definition
> (eclipselink-jpa-modelgen_2.0.2-XXXX.jar in this case), click
> Advanced... and check "Run this container's processors in batch mode".
>
> Done.

Hm, interesting that that worked.

Another thing you can try is adding the other classes you need to the factory
path. The factory path doesn't need to be restricted to just annotation
processors themselves, it should include any jars that the annotation processors
need. I can't quite tell from your problem description whether that is the
issue in this case. Anyway, glad you got it working.
Re: Compiling JPA metamodel generated by Annotation Processor [message #533237 is a reply to message #533043] Wed, 12 May 2010 12:17 Go to previous messageGo to next message
Eclipse UserFriend
The problem was not that the annotation processor weren't being invoked - it was (all classpath was ok) and metamodel classes were generated.
The problem was that those generated java files were not being compiled themselves into the output folder.
The batch mode did the trick.
Re: Compiling JPA metamodel generated by Annotation Processor [message #533747 is a reply to message #533237] Sun, 16 May 2010 12:07 Go to previous messageGo to next message
Eclipse UserFriend
"Luis Fernando Planella Gonzalez" <lfpg.dev@gmail.com> wrote in message
news:hsekbo$7n6$1@build.eclipse.org...
> The problem was not that the annotation processor weren't being invoked -
> it was (all classpath was ok) and metamodel classes were generated. The
> problem was that those generated java files were not being compiled
> themselves into the output folder. The batch mode did the trick.

If there is a way that you can make a sample project that demonstrates the
problem, please file a bug (http://bugs.eclipse.org/bugs) and attach an
archive of the project.

It might be that the processor is using java.io.File, rather than the Filer
API (which is part of the annotation processing API), to generate the files.
That's the only reason I can think of why running in batch mode would make a
difference, and actually I'm a bit surprised that even batch mode would help
in that case.

Batch mode is mainly intended to support processors that can't handle
incremental processing: for example, that rely on static variables being
properly initialized at the beginning of the run, or that rely on being able
to process all the files in a single round rather than one at a time, or
that make assumptions about how many rounds of processing will occur before
they exit. Sun's JPA processors do, I think, need to be run in batch mode;
but the symptoms you're describing are puzzling to me.

Thanks!
Re: Compiling JPA metamodel generated by Annotation Processor [message #533752 is a reply to message #533747] Sun, 16 May 2010 13:39 Go to previous message
Eclipse UserFriend
Sorry, but we've given up on using JPA metamodel, as JPA's criteria queries are way too complex.
We've switched to Querydsl instead.
But it shouldn't be hard to reproduce: I just had a project with JPA entities, and added on the annotation processor classpath the eclipselink jars as previously described....
I've also tried using the hibernate's metamodel generator, and had the same effect (had to enable batch mode, or generated classes weren't compiled.
Previous Topic:Create an OSX 10.5 standalone java app on 10.6?
Next Topic:How to print a whole big Tree widget
Goto Forum:
  


Current Time: Mon Apr 14 16:06:21 EDT 2025

Powered by FUDForum. Page generated in 0.03442 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top