Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Problems with AnnotationProcessorFactory
Problems with AnnotationProcessorFactory [message #237678] Wed, 25 October 2006 19:21 Go to next message
Eclipse User
Originally posted by: prisenhoover.daxsolutions.com

Hi All,

I am trying to get the APT plugin working with my Annotation Factory so that
my annotations can be generated from within Eclipse.

Now, I'll admit I know little about how the plugin system works, so please
be gentle. This is what I've done so far.

I downloaded the APTDemo and imported it as per the instructions on the web
site. I added my AnnotationProcessorFactory class to it and tweaked the
plugin.xml and the services files to indicate my new factory. Then I
exported a jar file. I then modified the Java Compiler properties of my
OTHER project -- the one with the annotations so that annotations were
enabled. In the "Factory Path" box I added the demo.jar that contains my
APF.

When I try to compile it, I get the following message in the "Other
Problems" section of my Problems view: "Unable to load annotation processor
factory 'demo.EntityDaoAPF' for project xxx."

Can somebody supply some guidance to me?

Thanks,
Paul
Re: Problems with AnnotationProcessorFactory [message #237714 is a reply to message #237678] Thu, 26 October 2006 15:59 Go to previous messageGo to next message
Eclipse User
Originally posted by: wharley.bea.com

"Paul" <prisenhoover@daxsolutions.com> wrote in message
news:ehorj1$gv3$1@utils.eclipse.org...
> Hi All,
>
> I am trying to get the APT plugin working with my Annotation Factory so
> that my annotations can be generated from within Eclipse.
>
> Now, I'll admit I know little about how the plugin system works, so please
> be gentle. This is what I've done so far.
>
> I downloaded the APTDemo and imported it as per the instructions on the
> web site. I added my AnnotationProcessorFactory class to it and tweaked
> the plugin.xml and the services files to indicate my new factory. Then I
> exported a jar file. I then modified the Java Compiler properties of my
> OTHER project -- the one with the annotations so that annotations were
> enabled. In the "Factory Path" box I added the demo.jar that contains my
> APF.
>
> When I try to compile it, I get the following message in the "Other
> Problems" section of my Problems view: "Unable to load annotation
> processor factory 'demo.EntityDaoAPF' for project xxx."
>
> Can somebody supply some guidance to me?


Sounds like you are doing things right, but your annotation processor
factory has a bug that is making it crash - perhaps an NPE or some such. Is
there anything in the Eclipse error log?

The fact that Eclipse can read the factory name implies that you did at
least get the META-INF/services entry correct in the jar file. But, you
might want to check that the class demo.EntityDaoAPF actually does exist in
the jar file, and that it's in the location you expect. It's possible that
something went wrong in the export, e.g., an incorrect build.properties
entry.

Since you exported your factory as a jar file, you're not running it as a
plug-in. The advantage to exporting it as a jar is that it can be
compatible with the Sun command-line apt tool; the disadvantage is that it's
a bit harder to debug into it. (It's also possible to have it work both
ways but I won't get into that here.)

To package and debug as a plug-in, you would have one workspace that
contained the annotation processor plug-in project, and you would launch the
debugger in that workspace with Debug As... Eclipse Application. That would
produce a second instance of Eclipse, with your plug-in installed. In that
instance's workspace, you would then create a project with your annotated
code. Doing it that way, you can set breakpoints in your processor's code
(e.g. in the Activator class, and/or in your factory's classes) and watch it
load and run.

For the processor to run as a plug-in, you need to extend the
org.eclipse.jdt.apt.annotationProcessorFactory extension point. If you need
help with that let me know.

-Walter Harley
JDT APT team
Re: Problems with AnnotationProcessorFactory [message #237750 is a reply to message #237714] Fri, 27 October 2006 15:43 Go to previous messageGo to next message
Eclipse User
Originally posted by: prisenhoover.daxsolutions.com

Thanks for the advice. I've spent all of today trying to figure this out
but I'm just stumped. If I were to send you my jar file could you take a
look at it?




"Walter Harley" <wharley@bea.com> wrote in message
news:ehr42e$1go$1@utils.eclipse.org...
> "Paul" <prisenhoover@daxsolutions.com> wrote in message
> news:ehorj1$gv3$1@utils.eclipse.org...
>> Hi All,
>>
>> I am trying to get the APT plugin working with my Annotation Factory so
>> that my annotations can be generated from within Eclipse.
>>
>> Now, I'll admit I know little about how the plugin system works, so
>> please be gentle. This is what I've done so far.
>>
>> I downloaded the APTDemo and imported it as per the instructions on the
>> web site. I added my AnnotationProcessorFactory class to it and tweaked
>> the plugin.xml and the services files to indicate my new factory. Then I
>> exported a jar file. I then modified the Java Compiler properties of my
>> OTHER project -- the one with the annotations so that annotations were
>> enabled. In the "Factory Path" box I added the demo.jar that contains my
>> APF.
>>
>> When I try to compile it, I get the following message in the "Other
>> Problems" section of my Problems view: "Unable to load annotation
>> processor factory 'demo.EntityDaoAPF' for project xxx."
>>
>> Can somebody supply some guidance to me?
>
>
> Sounds like you are doing things right, but your annotation processor
> factory has a bug that is making it crash - perhaps an NPE or some such.
> Is there anything in the Eclipse error log?
>
> The fact that Eclipse can read the factory name implies that you did at
> least get the META-INF/services entry correct in the jar file. But, you
> might want to check that the class demo.EntityDaoAPF actually does exist
> in the jar file, and that it's in the location you expect. It's possible
> that something went wrong in the export, e.g., an incorrect
> build.properties entry.
>
> Since you exported your factory as a jar file, you're not running it as a
> plug-in. The advantage to exporting it as a jar is that it can be
> compatible with the Sun command-line apt tool; the disadvantage is that
> it's a bit harder to debug into it. (It's also possible to have it work
> both ways but I won't get into that here.)
>
> To package and debug as a plug-in, you would have one workspace that
> contained the annotation processor plug-in project, and you would launch
> the debugger in that workspace with Debug As... Eclipse Application. That
> would produce a second instance of Eclipse, with your plug-in installed.
> In that instance's workspace, you would then create a project with your
> annotated code. Doing it that way, you can set breakpoints in your
> processor's code (e.g. in the Activator class, and/or in your factory's
> classes) and watch it load and run.
>
> For the processor to run as a plug-in, you need to extend the
> org.eclipse.jdt.apt.annotationProcessorFactory extension point. If you
> need help with that let me know.
>
> -Walter Harley
> JDT APT team
>
Re: Problems with AnnotationProcessorFactory [message #237805 is a reply to message #237750] Mon, 30 October 2006 12:48 Go to previous message
Eclipse User
Originally posted by: wharley.bea.com

"Paul" <prisenhoover@daxsolutions.com> wrote in message
news:ehtnhg$6fe$1@utils.eclipse.org...
>
> Thanks for the advice. I've spent all of today trying to figure this out
> but I'm just stumped. If I were to send you my jar file could you take a
> look at it?

Sure, send it on over.
Previous Topic:CompilationParticipant: good for this purpose?
Next Topic:Externalize all strings
Goto Forum:
  


Current Time: Sat Aug 30 00:28:06 EDT 2014

Powered by FUDForum. Page generated in 0.03963 seconds