At compile time, I only have
toplink-essentials-agent.jar
in classpath. This jar only contains a java agent class:oracle/toplink/essentials/internal/ejb/cmp3/JavaSECMPInitializerAgent.clas
But its META-INF/MANIFEST.MF contains a Class-Path
entry , in addition to a Premain-Class
entry:Premain-Class: oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInSo the class loader will follow this reference and load
itializerAgent
Class-Path: toplink-essentials.jar
<other entries omitted here>
toplink-essentials.jar
in the same directory. toplink-essentials.jar
contains all the Java Persistence API and implementation classes.At runtime, I don't even have any toplink jar in classpath. Because we use
-javaagent:toplink-essentials-agent.jar
, and any agent jars are automatically appended to the classpath. I wrote this post on -javaagent: option. So runtime classpath only needs to include application classes and jdbc driver jar.In NetBeans 5.5, I found I do need to include both toplink-essentials-agent.jar and toplink-essentials.jar in project library. Otherwise, NetBeans can't find JPA classes.
Tags: