Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

How to use the OpenJPA Eclipse Tooling Builder for Bytecode Enhancement

Once you have installed the OpenJPA Eclipse tooling, here is how to add the Bytecode Enhancement Builder to a Java project:

...

  • persistence.xml is ignored, the plug-in / builder only looks for annotations annotations (@Entity, @MappedSuperclass, @Embeddable, @ManagedInterface) to decide if a class actually needs enhancement
  • error markers (the lines shown in the Problems view) are on the .class resource, instead of on the source .java class, which would be more convenient
  • the Builder runs even on classes which are red and compilation issues, because the Eclipse compiler still tries to produce a .class file, and may log weird error messages in that case

Troubleshooting, Tips & Recommendations

  • If the Builder has trouble during enhancement, it normally logs useful messages / exception stack traces to the Eclipse Error Log. Use menu Window > Show View > Error Log to display it. If you don't have the Error Log view, this could be because you have an Eclipse with the PDE (Plug-in Development Environment), get that. The Eclipse Error Log can also be exported from this view, e.g. to send it to the mailing list. Further debugging & informational log messages can be enabled via the .project file, see below.
  • If your Eclipse dies due to "java.lang.OutOfMemoryError: Java heap space" / "java.lang.OutOfMemoryError: PermGen space" issues, you may need to add e.g. "-XX:PermSize=64m -XX:MaxPermSize=256m -Xms128m -Xmx512m" to your eclipse.ini (each option on a separate line) for the enhancement builder
  • In order to be sure that you're actually using build time enhancement, and not enhancing dynamically at run-time, you may wish to set the openjpa.RuntimeUnenhancedClasses=unsupported property in your persistence.xml or wherever you bootstrap OpenJPA (see Omitting the OpenJPA enhancer)

Options

  • More verbose logging for the Builder can be enabled via a configuration option in .project. This option is only intended for troubleshooting & debugging, because it seems to significantly (warning) slow down the builder, and something goes wrong with the Progress view (Monitor stuff) causing it to not update correctly anymore, and appear to keep running (although it's not).

...