Code generation not working, seems to be a classloading issue. · Issue #37 · jbosstools/m2e-apt · GitHub
Skip to content
This repository was archived by the owner on Feb 18, 2022. It is now read-only.
This repository was archived by the owner on Feb 18, 2022. It is now read-only.

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

Open

Description

@jfbenckhuijsen

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:

  • The m2e-apt plugin needs to fixes to handle classloading correctly
  • A (wild guess) might be if I implement some additional classes so this apt-plugin can also function as an eclipse plugin, so Eclipse knows how to handle the classloading issues correctly.

Activity

  1. fbricon commented on Jan 26, 2015

    @fbricon
    Member

    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)

  2. jfbenckhuijsen commented on Jan 27, 2015

    @jfbenckhuijsen
    Author

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

    • maven processor plugin
    • Setting Velocity to provided (so it's not on the classpath and I rely on Eclipse)
    • TCCL magic as described in the bug

    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...

  3. mickaelistria commented on Feb 17, 2022

    @mickaelistria

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions