9 responses to “Statically weaving JPA entities for EclipseLink using Maven”

  1. Magnus Heino

    What are your dependencies?

    I get

    [exec] [INFO] [antrun:run {execution: default}]
    [exec] [INFO] Executing tasks
    [exec] [java] Exception in thread “main” java.lang.NoClassDefFoundError: javax/persistence/spi/PersistenceUnitInfo
    [exec] [java] at org.eclipse.persistence.tools.weaving.jpa.StaticWeaveProcessor.process(StaticWeaveProcessor.java:233)
    [exec] [java] at org.eclipse.persistence.tools.weaving.jpa.StaticWeaveProcessor.performWeaving(StaticWeaveProcessor.java:159)
    [exec] [java] at org.eclipse.persistence.tools.weaving.jpa.StaticWeave.start(StaticWeave.java:110)
    [exec] [java] at org.eclipse.persistence.tools.weaving.jpa.StaticWeave.main(StaticWeave.java:82)
    [exec] [java] Caused by: java.lang.ClassNotFoundException: javax.persistence.spi.PersistenceUnitInfo
    [exec] [java] at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    [exec] [java] at java.security.AccessController.doPrivileged(Native Method)
    [exec] [java] at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    [exec] [java] at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    [exec] [java] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
    [exec] [java] at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    [exec] [java] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    [exec] [java] … 4 more
    [exec] [java] Java Result: 1

    the dependency is there, but it seems that it can’t be picked up by antrun?

  2. Magnus Heino

    Ok, it was a rtfm. I needed classpathref=”maven.test.classpath” since jpa was scope provided.

  3. donny

    Thanks for the hint!!

  4. Ari

    Thanks for the info. Here’s the alternative Ant Task call (insert in place of the section above). Note that you need to use ${basedir} prefix for the directories, as shown below. Also note that I have to use maven.test.classpath, like Magnus above, to pick up my provided-scope javax.persistence classes.

    Also strange that my persistence.xml is located under src/main/resources/META-INF, but if I list it like that, it won’t be found. When I leave off the META-INF, it finds it. Go figure…

    Thanks again!

  5. Ari

    Didn’t pick up the block. ;-) Hope this comes through.

  6. Ari

    need pre tag?

  7. Ari

    if xmp tag doesn’t work, i give up — sorry for all the posts — i don’t know how to post my XML in this blog comment

  8. Ari

    Sorry, none of my XML would come post with or without code/pre/xmp tags — suggestions?

  9. spiros

    Hello Ari,

    thanks for your comment. I am sorry but WordPress filters XML tags from comments for security reasons.