Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Datanucleus Programmatic API Class Enhancement

I'm using Eclipse 3.7 (OSGI), and i can do the manual Enhancement (with the Datanucleus Eclipse Plugin & datanucleus-enhancer-2.1.0-release imported as plugin dependency)

I'm trying now to use the API Class Enhancement: http://www.datanucleus.org/products/accessplatform/jpa/enhancer.html#api

With ASM 3.1 in the classpath and this code:

DataNucleusEnhancer enhancer=new DataNucleusEnhancer("JDO","ASM");
enhancer.setVerbose(true);
enhancer.addClasses(...);
enhancer.enhance();

I get:

You have selected to use ClassEnhancer "ASM" yet the JAR for that enhancer does not seem to be in the CLASSPATH!
org.datanucleus.enhancer.NucleusEnhanceException: You have selected to use ClassEnhancer "ASM" yet the JAR for that enhancer does not seem to be in the CLASSPATH!
    at org.datanucleus.enhancer.DataNucleusEnhancer.init(DataNucleusEnhancer.java:224)
    at org.datanucleus.enhancer.DataNucleusEnhancer.addClasses(DataNucleusEnhancer.java:406)

With the code suggested in the tutorial:

JDOEnhancer enhancer = JDOHelper.getEnhancer();
enhancer.setVerbose(true);
enhancer.addClasses(...);
enhancer.enhance();

I get:

javax.jdo.JDOFatalUserException: There are 0 services entries for the JDOEnhancer; there were no valid JDOEnhancer implementations found in the CLASSPATH. The file META-INF/services/javax.jdo.JDOEnhancer should name the implementation class.

Is there a way to achieve API Class Enhancement?

like image 424
marcolopes Avatar asked Nov 05 '13 16:11

marcolopes


1 Answers

See this link http://www.datanucleus.org/products/accessplatform_3_0/enhancer.html#runtime

Especially sentence: "Runtime Enhancement requires the following runtime dependencies: ASM, and DataNucleus Core libraries."

So you are probably missing ASM dependency.

Try add this dependency:

    <dependency>
      <groupId>org.ow2.asm</groupId>
      <artifactId>asm</artifactId>
      <version>4.2</version>
    </dependency>
like image 170
none_ Avatar answered Sep 20 '22 17:09

none_