Datanucleus Programmatic API Class Enhancement
Asked Answered
S

1

14

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?

Shipload answered 5/11, 2013 at 16:27 Comment(0)
T
1

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>
Tarazi answered 24/1, 2014 at 12:11 Comment(1)
i have the ASM jar in my dependencies. I believe the problem has to do with Eclipse OSGI layer that prevents ASM from being found by DN.Shipload

© 2022 - 2024 — McMap. All rights reserved.