If your input JAR or EAR file contains CMP beans, the EJB deployment tool looks for an existing schema and map to use when generating deployment code. If no existing schema and map are found, a schema and map are created using top-down mapping rules.
In the top-down mapping approach, you already have existing enterprise beans and their design determines the database design. The generated schema contains one table for each CMP entity bean. In these tables, each column corresponds to a CMP field of the enterprise bean, and the generated mapping maps the field to the column.
Syntax
Use the following command and the optional parameters, when the schema and map are provided in the input EAR file:
ejbdeploy
input_JAR_name
working_directory
output_JAR_name[
-cp
classpath] [
-codegen] [
-debug] [
-keep] [
-ignoreErrors ] [
-quiet] [
-nowarn] [
-noinform] [
-rmic
"options"] [
-target
name] [
-trace ] [
-sqlj]
Use the following command and the optional parameters, when the schema and map are not available in the input EAR file, and a top-down mapping approach is needed:
ejbdeploy
input_JAR_name
working_directory
output_JAR_name[
-cp
classpath] [
-codegen] [
-dbname
name] [
-dbschema
name] [
-dbvendor
name] [
-debug ] [
-keep] [
-ignoreErrors] [
-quiet] [
-nowarn ] [
-noinform] [
-rmic
"options"] [
-35 ] [
-40] [
-target
name] [
-trace] [
-sqlj ][
-OCCColumn]
Note:
ejbdeploy command. If you want to set a different database backend, use the
-dbname ,
-dbschema, and
-dbvendor options to specify your choice. However, you can have only one backend defined. If the JAR file already contains a DB2 backend, and you specify -dbvendor ORACLE on the command line, rather than getting a second backend, the dbvendor specification is ignored.
ejbdeploy
ejbdeploy command displays a list of arguments that can be run with the command.
input_JAR_name or
input_EAR_name
c:\ejb\inputJARs\myEJBs.jar . (This argument is required.)
The
ejbdeploy command no longer uses what is specified on the system class path. Instead, the dependent classes need to be contained in a JAR file or included in the command processing using the
-cp option. You must ensure that the .class files of each enterprise bean's home and remote classes are packaged in the input JAR or EAR file.
You should not include source files in the input JAR or EAR file. If there are source files in the input JAR or EAR file, the EJBDeploy tools runs a rebuild before generating the deployment code. Recommendation : Either remove the source files, or include all dependent classes and resource files on the class path. Otherwise, this might cause problems during rebuild of your application on the server.
working_directory
ejbdeploy command, the temporary files are generated into the working directory (as an Eclipse workspace). However, if the working directory does not already exist prior to running the command, the directory is created and the Eclipse workspace is generated into it. In both cases, the workspace and all of its files are automatically removed when the deployment code generation is complete unless you specify the
-keep option. (Retaining the workspace is useful for problem determination.)
output_JAR_name or
output_EAR_name
ejbdeploy command and that contains the generated classes required for deployment; for example:
c:\ejb\outputJARs\myEJBs.jar . (This argument is required.) The directories specified in the fully-qualified name must already exist before you run the
ejbdeploy command. (Note that when you specify a name for the output JAR or EAR file and then run the
ejbdeploy command, any existing output JAR or EAR file of the same name will be overwritten without warning.)
-cp
classpath
ejbdeploy command against JAR or EAR files that have dependencies on other zipped or JAR files, you can use the
-cp option to specify the class path of the other JAR or zipped files. Using the
-cp option, you can specify multiple zipped and JAR files as arguments. However, the zipped and JAR file names must be fully qualified, separated by semicolons, and enclosed in double quotation marks. For example: -cp "path\myJar1.jar;path\myJar2.jar; path\myJar3.jar"
Tip: You need to specify the location of the SQLJ translator classes,
sqlj.zip . The default path for this file is
x:\java , where x is the installation directory of DB2, for example,
d:\sqllib\java\sqlj.zip on Windows.
-codegen
ejbdeploy command to just (a) importing code from the input JAR or EAR file (b) generating the deployment code, and (c) exporting code to the output JAR or EAR file. It will not compile the generated deployment code or run RMIC. Since JavaTM source code is not usually exported in the output EAR or JAR, this is the only way to save the generated code.
-bindear
"options"
-dbname
"name"
-dbschema
"name"
-dbvendor
name
Note:
-sqlj is specified, it supports DB2UDB_V82 (DB2 for Windows, V8.2 and UNIX), DB2UDB_V81 (DB2 for Windows, V8.1 and UNIX), DB2UDBOS390_V8 (DB2 for OS/390, V8) and DB2UDBOS390_V7 (DB2 for OS/390, V7).
-debug
-keep
ejbdeploy command has run. Without this option, the Eclipse workspace is deleted when the command has completed.
-ignoreErrors
-quiet
-nowarn
-noinform
-rmic
"options"
-35
-35 option. This may be desirable in some situations. However, if you do not specify the
-35 option, a form of top-down mapping is used that is an improvement over what has previously been available.
-40
-target
name
-trace
-sqlj
Note: This option is valid only on enterprise beans compliant with the 2.0 specification.
Enables you to use SQLJ instead of JDBC to make calls to a DB2 database. With the
-sqlj option specified, the EJB deployment tool generates SQLJ code for your CMP beans to use SQLJ to access the database. It also automatically invokes the SQLJ translator to translate the SQLJ source files. Finally, an Ant script will be created by the EJB deployment tool to help you to customize the SQLJ profiles easily. You can run the Ant script against the profile to produce a DB2 package. These DB2 packages can be used at runtime to avoid extensive runtime checking. Once you have generated the deployment code for SQLJ using the EJB deployment tool, you will need to run the DB2 SQLJ profile customizer, db2sqljcustomize, against the generated .ser file, which is found in the subfolder of the websphere_deploy folder associated with the DB2 backend. Consult the DB2 documentation for more information on running the DB2 SQLJ profile customizer, or visit www7b.boulder.ibm.com/dmdd/zones/java/bigpicture.html (section SQLJ support).
-OCCColumn
Note: This option is valid only on EJB 2.x CMP entity beans when generating top-down mapping. Enables you to add a column to your relational database table for collision detection. The collision detection column is the additional database column reserved to determine if a record has been updated. Adding a column for collision detection is an alternative optimistic concurrency control scheme of including attributes in a predicate for optimistic access intents. To manage the collision detection column, you will need to provide your own database trigger implementation. The following are the result of adding a column for collision detection:
ejbdeploy AccessEmployee.ear d:\deploydir AccessEmployee_sqlj.ear -dbvendor DB2UDB_V81 -keep -sqlj -cp "e:\sqllib\java\sqlj.zip"
Explanation:
We have DB2 Universal database (version 8.1 for Windows and UNIX) installed in
e:\sqllib .
The ejbdeploy command takes the AccessEmployee.ear file (which has enterprise beans that are compliant with the EJB 2.0 specification) as input and produces the AccessEmployee_sqlj.ear as output. Since the
-sqlj option is used, SQLJ is used instead of JDBC in the generated code to make calls to DB2.
When ejbdeploy runs, it creates an Eclipse workspace in the directory that you specify as the working directory:
d:\deploydir . When it has completed running, it deletes this workspace. However, the
-keep option causes
ejbdeploy to end without deleting the workspace.
Parent topic: EJB deployment tool
Related tasks
Generating deployment code for enterprise beans from the command line