It looks like Apple's implementation of sun.security.pkcs11.SunPKCS11 is 
different from the version that the accompanying build of Derby has been built 
against, resulting in an incompatibility.  I downloaded a copy of the build and 
ran it on my mac, and instantly reproduced the problem.  Looking in the derby 
log, I spotted this LinkageError:

Database Class Loader started - derby.database.classpath=''
2011-05-10 15:56:30.053 GMT Thread[main,5,main] (XID = 146), (SESSIONID = 3), 
(DATABASE = 
/Users/jgrassel/Downloads/apache-openjpa-2.1.0/examples/simple/hellojpa/hellojpa-database),
 (DRDAID = null), Cleanup action starting
2011-05-10 15:56:30.053 GMT Thread[main,5,main] (XID = 146), (SESSIONID = 3), 
(DATABASE = 
/Users/jgrassel/Downloads/apache-openjpa-2.1.0/examples/simple/hellojpa/hellojpa-database),
 (DRDAID = null), Failed Statement is: EXECUTE STATEMENT SYS."getColumns"
java.lang.LinkageError: loader (instance of  sun/misc/Launcher$ExtClassLoader): 
attempted  duplicate class definition for name: "sun/security/pkcs11/SunPKCS11"
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
        at 
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
        at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
[big snip]

Now, Apple ships a copy of derby with Snow Leopard, it's in /usr/share/derby.  
I modified the build.xml to use that version of derby instead of the version 
that comes with the openjpa zip file:

[starting at line 79 in examples/simple/build.xml:]
        <fileset dir="${root}">
            <include name="openjpa-all-*.jar"/>
            <!-- <include name="lib/derby*.jar"/> -->
        </fileset>
        <fileset dir="/usr/share/derby">
            <include name="lib/derby*.jar"/>
        </fileset>

With that classpath modification, the sample started to work.

On Apr 21, 2011, at 2:52 AM, Joep Simons wrote:

> Hi,
> 
> I got the following output:
> 
> On another note: The exception disappeared in my 'test-code' when I added a
> second @entity object with a relation to the first. Not sure if that means
> something, but at least I can continue. 
> 
> buildfile:
> /Users/simons/openjpa/apache-openjpa-2.2.0-SNAPSHOT/examples/simple/hellojpa/build.xml
> 
> pre-compile:
> 
> compile:
>    [javac]
> /Users/simons/openjpa/apache-openjpa-2.2.0-SNAPSHOT/examples/simple/build.xml:104:
> warning: 'includeantruntime' was not set, defaulting to
> build.sysclasspath=last; set to false for repeatable builds
> 
> run:
>     [echo]  ============================================= 
>     [echo]  javaagent:
> /Users/simons/openjpa/apache-openjpa-2.2.0-SNAPSHOT/openjpa-2.2.0-20110415.075847-49.jar
>  
>     [echo]  parent   :
> /Users/simons/openjpa/apache-openjpa-2.2.0-SNAPSHOT/examples/simple/hellojpa/..
>  
>     [echo]  root     :
> /Users/simons/openjpa/apache-openjpa-2.2.0-SNAPSHOT/examples/simple/hellojpa/../../..
>  
>     [echo]  myCp     :
> /Users/simons/openjpa/apache-openjpa-2.2.0-SNAPSHOT/examples/simple:/Users/simons/openjpa/apache-openjpa-2.2.0-SNAPSHOT/lib/derby-10.5.3.0_1.jar:/Users/simons/openjpa/apache-openjpa-2.2.0-SNAPSHOT/openjpa-all-2.2.0-SNAPSHOT.jar
>  
>     [echo]  ============================================= 
>     [java] Exception in thread "main" <openjpa-2.1.0-r422266:1071316
> nonfatal general error> org.apache.openjpa.persistence.PersistenceException:
> Already closed.
>     [java]    at
> org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:558)
>     [java]    at
> org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:
> 
> --
> View this message in context: 
> http://openjpa.208410.n2.nabble.com/Can-t-get-hellopjpa-from-examples-working-tp6262603p6293513.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.

Reply via email to