
Signature
Kenneth P. Turvey <kt-usenet@squeakydolphin.com>
Words to the wise, "Kenneth P. Turvey" <kt-usenet@squeakydolphin.com>
wrote:
>I'm trying to work through the book "Pro EJB 3 - Java Persistence API"
>(don't buy it), but I'm having some difficulty getting things to work
>here. I'm just trying to use the derby embedded database and the
>glassfish implementation of the JPA, as I think is being done in the book.
>Unfortunately, I'm getting a stack trace when I try to run the code.
>
[quoted text clipped - 9 lines]
><!--
> Document : persistence.xml.xml
persistence.xml.xml? Is the name of the file really that?
> Created on : March 15, 2008, 4:27 PM
> Author : kt
[quoted text clipped - 3 lines]
>
><persistence>
I think you need to add something there:
xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
At least that is how I read the stacktrace. What I mentioned below are
is plain guess work.
> <persistence-unit name="EmployeeService" transaction-type="RESOURCE_LOCAL">
> <class>examples.model.Employee</class>
[quoted text clipped - 3 lines]
> <property name="toplink.jdbc.url"
> value="jdbc:derby:MyTestDb;create=true"/>
Did you specify myTestDb as Datasource in glassfish?
> <property name="toplink.jdbc.user" value="APP" />
> <property name="toplink.jdbc.password" value="APP" />
> </properties>
> </persistence-unit>
></persistence>
Also, there is no datasource here, although I do not know whether you
actually need one when using the embedded derby db.
Oh, and does the database scheme exist already? I think you need to
create the scheme the tables and so on are created for you, but I
cannot say for sure.
Hope this helps, please report back if it does and also if it does
not.
--
Claus Dragon <clauskick@mpsahotmail.com>
=(UDIC)=
d++ e++ T--
K1!2!3!456!7!S a29
"Coffee is a mocker. So, I am going to mock."
- Me, lately.
Kenneth P. Turvey - 16 Mar 2008 01:08 GMT
> Also, there is no datasource here, although I do not know whether you
> actually need one when using the embedded derby db.
[quoted text clipped - 5 lines]
> Hope this helps, please report back if it does and also if it does
> not.
I got it working. I actually tried to cancel this post, but it was
already out the door.
Anyway, your post was helpful. I got the system to create the schema for
me. The file is actually quite close to what was necessary. The problems
were mainly in the XML file above. I'll post the result here so that it
goes to the search engines.
This gets things working with Glassfish and Derby.
Thanks!
-----
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="EmployeeService" transaction-type="RESOURCE_LOCAL">
<provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</provider>
<class>javapersistence.Employee</class>
<properties>
<property name="toplink.jdbc.driver"
value="org.apache.derby.jdbc.EmbeddedDriver"/>
<property name="toplink.jdbc.url"
value="jdbc:derby:MyTestDb;create=true"/>
<property name="toplink.jdbc.user" value="APP" />
<property name="toplink.jdbc.password" value="APP" />
<!-- Java2DB properties, creates the tables -->
<property name="toplink.ddl-generation" value="create-tables" />
</properties>
</persistence-unit>
</persistence>
-----

Signature
Kenneth P. Turvey <kt-usenet@squeakydolphin.com>