As of JAG 3.3 initial support for the Sun ONE Application Server 7 has been added. CMP With Container Managed Relations have been tested on a MySQL database.
To use the Sun ONE Application Server 7 with JAG a small example will be described using a mysql database. Use the following instructions to setup a mysql database for this Example. Create a "test" database and run the following sql scripts:
You must run the mySQL server in ANSI mode for CMP to work.
Add the option ansi to your mySQL command line startup, or add it in the "my.ini" options file
Now we can configure JAG to use this database. In the Datasource section set the following:
Set the JNDI name of the Datasource to: jdbc/CDPlayer
Select as database type: MySQL
Select as jdbc url: jdbc:mysql://localhost/test (in case the mysql runs on the same machine as the appserver).
In the default setup the test database of MySQL doesn't need any username/password. So keep them empty.
Start S1AS 7 and goto the admin webpages.
Select your server, and click on the "JVM Settings" tab Then select the "Path Settings". In the "Classpath suffix" add a line containing:
Save, and apply changes
Goto the "JDBC", then "Connection Pools" and create a new one. JNDI name: "CDPlayerConnectionPool"
Set the following properties for the Connection Pool.
Goto the "JDBC", then "JDBC Resources" and create a new one.
And finally a Plugable Persistence Manger has to be created: Create the PPM: jdbc/CDPlayerPPM and selected the previously create connection pool.
Save, apply changes & stop/start server
Now the datasource have been configure, also log4j has to be added to the classpath of the appserver, even if the generated application used jdk logging because struts1-1 will need it.
In the "Classpath suffix" add a line containing: C:\...path_to_log4j\log4j.jar
Also add a -D parameter to the JVM Options that specifies a logging directory: -Dcom.finalist.LogDir=c:/temp
If this parameter isn't set, S1AS 7 will throw Security Exceptions because a System properies is being set.
Save, and apply changes
When creating new EntityEJBs the sequence generator should be deployed as an EJB Module. The Sequence Generator EJB jar has been distributed along with jag and can be found in the lib dir of the generated project.
Now JAG can be used to create 2 entity EJBs (CD and Song) and add a session Facade to them. Run JAG and build the generated project
One thing required by the S1AS is a database schema. This can be done by running the capture-schema script in the bin directory of the S1AS. This script will be called from the ANT build, but it may be necessary to put the JDBC driver in the classpath of the capture script. This can be done easily by adding it once to the script.
For an Entity EJB the Primary key must be defined in the database to make it work! It is not enought to tell JAG what should be the primary key.
MySQL can only be used in ansi mode, otherwise CMP won't work with S1AS.
For CMR to work, both the foreign key and the primary key of the foreign table should have the same column name.