I've finally solved this. Here are the CLI commands needed to create the datasource for a networked Derby datasource:
# Create the module directory, including all of the required derby JARs. The base driver class
# you need is ClientDriver, but it requires others which are scattered in other JARs. As you
# progress from just the client JAR you'll get errors for other missing classes.
module add --name=org.apache.derby --resources=/usr/local/derby/lib/derbyclient.
jar,/usr/local/derby/lib/derbyshared.jar,/usr/local/derby/lib/derbytools.jar,/us
r/local/derby/lib/derby.jar --resource-delimiter=, --dependencies=javax.api,jav
ax.transaction.api
# The basic name of the datasource (as it would be displayed in the admin console) is
# DerbyDS, and the full name of the driver class is
# org.apache.derby.jdbc.ClientDriver
# obtained by concatenating the "driver-module-name" with the "driver-class-name".
/subsystem=datasources/jdbc-driver=derbyDS:add(driver-name=derbyDS,driver-module
-name=org.apache.derby,driver-class-name=org.apache.derby.jdbc.ClientDriver)
# This just removes any existing datasource of this name, and will fail if none exists.
data-source remove --name=DerbyDS
# Now add the datasource. The -name must match the name used in the second
# command above for both jdbc-driver and driver-name. "driver-name" need not match anything.
# You need to have defined tables in Derby that match your Entity Bean descriptions.
# It's interesting that the schema name given in the "connection-url" doesn't have to
# match the schema you actually use (as you will see below, I used "DVD").
#
# However, the jndi-name has to match "java:jboss/datasources/" plus the datasource
# name. Other places on the net suggest that it should be "java:jboss/jdbc", but
# displaying the info in the admin console datasource description for the shipped
# ExampleDS shows that "datasources" is the required value. "--user-name" and
# "--password" should match whatever you defined in Derby for the tables.
data-source add --name=DerbyDS --driver-name=derbyDS --connection-url=jdbc:derby
://localhost:1527/DerbyDS --connection-properties=[create=>true] --jndi-name=jav
a:jboss/datasources/DerbyDS --user-name=sa --password=sa
# This is just a sanity test to see if DerbyDS can be connected to.
/subsystem=datasources/data-source=DerbyDS:test-connection-in-pool
The persistence.xml in your project should look something like:
<?xml version="1.0" encoding="UTF-8"?>
It's not clear that all of these properties are needed, but if they are
they must match what was given in the CLI above. Note that here we use
the actual schema name "DVD" used to create the tables.
-->
<property name="javax.persistence.jdbc.driver"
value="org.apache.derby.jdbc.ClientDriver"/>
<property name="javax.persistence.jdbc.url"
value="jdbc:derby://localhost:1527/DVD;create=true"/>
<property name="javax.persistence.jdbc.user" value="sa"/>
<property name="javax.persistence.jdbc.password" value="sa"/>
<!--
The following are possibly optional, with the possible exception of
"dialect". I'm not sure how much of Derby processing gets filtered
through Hibernate processing.
-->
<property name="javax.persistence.schema-generation.database.action"
value="drop-and-create"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.DerbyDialect"/>
<property name="show_sql" value="true"/>
<property name="hibernate.temp.use_jdbc_metadata_defaults" value="false"/>
</properties>
</persistence-unit>
</persistence>
and finally, here is the "ij" input used to create the tables. Obviously most of this
won't match your application, but the schema name needs to match what you put
in persistence.xml:
/bin/ksh $DERBY_HOME/bin/ij -p /tmp/ij.properties <<EOF2
Connect 'DVD;create=true';
CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY('derby.database.sqlAuthorization','T
RUE');
CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY('derby.user.dvd', $DVD_PASSWORD);
DROP TABLE DVD.DBUTDVDDISKSENTITYBEAN;
DROP TABLE DVD.DBUTDVDACTORSENTITYBEAN;
DROP TABLE DVD.DBUTDVDSTATEENTITYBEAN;
DROP SCHEMA DVD RESTRICT;
CREATE SCHEMA DVD AUTHORIZATION dvd;
CREATE TABLE DVD.DBUTDVDDISKSENTITYBEAN (title VARCHAR(64), season INTEGER, case
numbers VARCHAR(256), lcasenumbers BLOB(64K), tv CHAR(1), url VARCHAR(64), PRIMA
RY KEY(title,season));
CREATE TABLE DVD.DBUTDVDACTORSENTITYBEAN (id VARCHAR(64), lastname VARCHAR(64),
middlename VARCHAR(64), firstname VARCHAR(64), qualifier VARCHAR(64), titles BLO
B(64K));
CREATE TABLE DVD.DBUTDVDSTATEENTITYBEAN (id BIGINT, changestate BIGINT);
exit
EOF2