jbosstools / m2e-apt

Maven integration with Eclipse JDT Annotation Processor Toolkit
39 stars 19 forks source link

Code generation not working, seems to be a classloading issue. #37

Open jfbenckhuijsen opened 9 years ago

jfbenckhuijsen commented 9 years ago

Hi,

I've created an APT maven project to generate some code. I've succesfully tested this code from Maven and all seems to work fine. However, whenever I use the m2e-apt plugin to run this from Eclipse, I get unexpected runtime-errors in the compilation process. The concrete exceptions differ largely from build-to-build, from execution-to-execution and from pc-to-pc, i.e. there is no real direct cause which I can define.

I've seen various ResourceExceptions where internal JDK code is complaining about the JAR file being correct (the same JAR which is used for the maven compilation, i.e. the JAR is fine), I've seen exceptions of files which cannot be loaded from the classpath (classLoader.getResourceAsStream() like calls which fail) and classcast exceptions (some velocity class does not implement an interface from velocity itself).

All these seem to indicate some classloading issue, however, I've got no idea where to start searching (running an Eclipse debug session right now), or how to fix this without diving headlong into the plugin code, so any advice is apprectiated.

RIght now I can see two possible solutions:

fbricon commented 9 years ago

m2e-apt does not perform any annotation processing, only project configuration, by default (When JDT APT) is used. Have you tried configuring maven-processor-plugin and delegating AP to maven (see preferences)? No idea if that'll fix your issue.

You most likely hit https://bugs.eclipse.org/bugs/show_bug.cgi?id=396554. Basically using Velocity from inside an Eclipse plugin (as in running from JDT AP) will lead you to a world of pain.

Also, be aware you can NOT run AP from open workspace projects (issue #18)

jfbenckhuijsen commented 9 years ago

Yeah, i got that already :(. Have tried various approaches:

I finally ended up creating an Eclipse plugin and needed to package Velocity itself with all deps in my plugin to force Eclipse to have all needed classes. Bummer, now I have to manually update all clients with that plugin, as rewriting it to not use Velocity wasn't really an option right now.

I'm aware of issue #18, thanks for the quick reply...

mickaelistria commented 2 years ago

m2e-apt's code is now included in https://github.com/eclipse-m2e/m2e-core , please consider reporting issue to https://github.com/eclipse-m2e/m2e-core/issues if it's still relevant.