Previous Contents Index DocHome Next |
iPlanet Application Server 6.0 Programmer's Guide (C++) |
Chapter 11 Running and Debugging Applications
This chapter describes how to set up a test version of your application, as well as how to use the debugging tools in your C++ development toolkit.The following topics are included in this chapter:
Getting Ready to Run an Application
Getting Ready to Run an Application
Before you can execute the AppLogic objects in your application, you must set up a test version of your application. This involves copying your application files to the appropriate locations and registering the AppLogics, other code modules, and security information needed in the application. For the purposes of testing, you will probably set up the application on a single iPlanet Application Server.This manual does not describe application deployment in detail. In general, the procedure for setting up an application for testing is similar to that for deploying production applications. This section describes only those procedures that are specific to setting up an application for testing.
Alternatively, if you are using iPlanet Application Builder, you can deploy applications using its deployment feature. This procedure is described in User's Guide.
Compiling Applications
This section assumes that you are already familiar with creating makefiles and compiling source files on your development platform. It also assumes that you have already installed the entire Calhoops sample application on your development system using the iPlanet Application Server installation procedure described on the product CD.This section lists relevant libraries to link to and describes creating a makefile for your AppLogic, using examples of makefiles from the Calhoops sample application for the Sun Solaris, Hewlett-Packard HP-UX, and Microsoft Windows NT platforms.
Setting the GX_ROOTDIR Environment Variable
Before compiling, you need to set the $GX_ROOTDIR environment variable to point to the root directory for the iPlanet Application Builder. For instructions on how to do this, see the system documentation for your particular development platform.
Creating a Makefile
Use your C++ application development tools to generate the makefile for your project. The following examples show the makefile for the Calhoops sample application on the Sun Solaris, Hewlett-Packard HP-UX, and Microsoft Windows NT platforms.
Sun Solaris
## Sample makefile for C, C++ applogics
# Run 'make debuggable' or simply 'make'
# to build shared library with debug info.
# Run 'make release' to build optimized shared library
OBJS = calhoops.o # list of all object files to be generated
SHO = libcalhoops.so # name of shared object file to generate
debuggable := TARGET = debuggable
CPPFLAGS = -KPIC -mt -DUNIX -DGXPUBLIC_BUILD -D$(PLATFORM) $(DEBUG) $(INCLUDES)
CFLAGS = -KPIC -mt -DUNIX -DGXPUBLIC_BUILD -D$(PLATFORM) $(DEBUG) $(INCLUDES)
SHOFLAGS = -G -Bsymbolic -mt -z text -L $(LIBDIR)
[ -d $(LIBDIR) ] && cp $(SHO) $(LIBDIR)
$(CPP) $(SHOFLAGS) -o $(SHO) $(OBJS) -lgxagent -lgxidl -lgxutil
@rm -f $(SHO) $(LIBDIR)/$(SHO)
Hewlett-Packard HP-UX
## Sample makefile for C, C++ applogics
# Run 'make debuggable' or simply 'make'
# to build shared library with debug info.
# Run 'make release' to build optimized shared library
OBJS = calhoops.o # list of all object files to be generated
SHO = libcalhoops.sl # name of shared object file to generate
debuggable := TARGET = debuggable
CPPFLAGS = +Z +a1 -DUNIX -D$(PLATFORM) -DGXPUBLIC_BUILD $(DEBUG) $(INCLUDES)
CFLAGS = +Z -Ae -DUNIX -D$(PLATFORM) -DGXPUBLIC_BUILD $(DEBUG) $(INCLUDES)
SHOFLAGS = -b -q -Wl,+s,+b:,+vshlibunsats $(CPPFLAGS) -L $(LIBDIR)
[ -d $(LIBDIR) ] && cp $(SHO) $(LIBDIR)
$(CPP) $(SHOFLAGS) -o $(SHO) $(OBJS) -lgxagent -lgxidl -lgxutil
@rm -f $(SHO) $(LIBDIR)/$(SHO)
Microsoft Windows NT
PROJECT=calhoops.dll##############################################################
CC_FLAGS =$(MYCFLAGS) /c /nologo /MTd /W3 /GX -DWIN32 -DWINDOWS
CC_FLAGS_DBG=/Od /Zi /Gm -DDEBUG -D_DEBUG
LINK_FLAGS =$(MYLFLAGS) /MAP /subsystem:windows /dll /incremental:no
LINK_FLAGS_DBG=/DEBUG:FULL /DEBUGTYPE:BOTH
INCLUDE=$(KIVA_ROOT)\include;$(INCLUDE)
LIB =$(KIVA_ROOT)\lib\c;$(LIB)
LIBS=gxagent.lib gxutil.lib gxidl.lib kernel32.lib user32.lib uuid.lib
CC_FLAGS=$(CC_FLAGS) $(CC_FLAGS_DBG)
LINK_FLAGS=$(LINK_FLAGS) $(LINK_FLAGS_DBG)
CC_FLAGS=$(CC_FLAGS) $(CC_FLAGS_REL)
LINK_FLAGS=$(LINK_FLAGS) $(LINK_FLAGS_REL)
$(LINK) $(LINK_FLAGS) $(PROJECT_OBJS) /OUT:$(PROJECT) $(LIBS)
Placing Files on the iPlanet Application Server
This section uses the following abbreviations to refer to directories on your file system:
When placing shared libraries and HTML template files (for HTML-based clients) on your iPlanet Application Server, consider storing them in the following locations, where $GX_ROOTDIR is the Netscape Application Server root installation directory:
For example, the Calhoops sample application shared library files might be stored in the following locations:
Placing Files on the Web Server (HTML Client)
When placing web pages and graphics files on your Web server, consider storing them in the following locations, where <Code>$WS_DOCROOTDIR is the document root directory of the web server:
For example, the query selection form for the Calhoops sample application (index.html) might be in the following path:
<Code>$WS_DOCROOTDIR/GXApp/CCalhoops/index.html
Registering Code And Security Information
Before you can execute your application, you must set up a test version. As one of the steps in this procedure, you must register certain application items with the iPlanet Application Server. When setting up an application for testing, you might need to register any of the following types of items with the iPlanet Application Server:By registering users, user groups, and ACLs, you can set up security for the application. During testing and initial deployment, you must define these items yourself if your application includes security features, such as calls to LoginSession( ). During production deployment, the system administrator can also manage the security information, using the iPlanet Application Server Administrator tools.
Using Utilities to Register Application Information
The iPlanet Application Server maintains a record of registered application items in local registry storage. You can use the kreg utility to populate the registry. To do so, edit one or more files with a .gxr extension. These files are the input to kreg.To register code or security information using utilities
For an AppLogic object or other code module, you must generate a unique GUID. To do so, run the kguidgen utility from a command line or window by typing the following command:
Add lines to the .gxr file for the items you want to register. The syntax for each type of item is given later in this section. Each item uses four lines.
Make sure you assign a unique name to the item. Unlike the GUIDs, which are sure to be unique since they are generated automatically, there is a possibility for duplicates when you assign names yourself. For example, prefix the names of your AppLogics with the application name to reduce the possibility of name collisions.
Run the kreg utility from a command line or window using the following syntax:For an AppLogic object or other code module, paste in the GUID that was generated by kguidgen.
AppLogic .gxr Syntax
The entry in a .gxr file to register an AppLogic object uses the following syntax (the portion from AppLogic to group is all on one line):AppLogic name [:type=c][:enable=y|n][:encrypt=y|n]
[:lb=y|n][:descr[:AppName;group;...]]
GUID [:server;...[acl=user,[!]EXECUTE;...]]
The items in the syntax are as follows:
name: Name of the AppLogic object.
:type=c: Optional letter c to indicate that the AppLogic object is written in C++.
:enable=y|n: Optional flag to indicate whether the AppLogic is enabled.
:encrypt=y|n: Optional flag to indicate whether the communications to the AppLogic are encrypted.
:lb=y|n : Optional flag to indicate whether sticky load balancing is set.
:descr: Optional description of the AppLogic, which will appear in the Application Administrator.
:AppName;group;...: Optional semicolon-separated list of groups to which the AppLogic belongs. The first group should be the name of the application.
Globally unique identifier (GUID) that was generated by kguidgen.
:server;...: Optional semicolon-separated list of server descriptions. Each server description uses the following syntax:
<SERVER_IP_ADDR>:<SERVER_IP_PORT>[=<SERVER_FLAGS>]
acl=user,[!]EXECUTE;...: Optional semicolon-separated list of access control list (ACL) entries, to specify which users can execute the AppLogic. Each ACL entry uses the following syntax:
- SERVER_IP_ADDR is a decimal-dotted IP address, such as 192.23.43.15. SERVER_IP_PORT is the Executive Server port number, in decimal. SERVER_FLAGS is an optional decimal number. The flags, in hexadecimal, are 0x8000000 to set sticky load balancing and 0x00000001 to set the enable flag. Note that you can turn these on using the lb and enable flags on the first line.
Path to AppLogic object. For cross-platform compatibility, you can omit the extension of the file (such as .dll or .so) and, on UNIX platforms, you can also omit the lib prefix of the file. For increased portability, it is advisable to use relative paths in the .gxr file.
- User is the name of a User or UserGroup, as specified by the system administrator. Permission is an operation name. For AppLogics, EXECUTE is the only operation that is checked automatically by the system. An exclamation point in front of EXECUTE means the user or user group can not run the AppLogic.
(Optional) Comments. Each line can end with a comment preceded by the vertical bar character |.
Example
The following lines show the .gxr file entry for an AppLogic object (the portion from AppLogic to digibanker is all on one line):AppLogic CalculateBalancesLogic:Updates account balance
{e248ecd0-9bfd-bc32-00a024d1709f}
Code Module .gxr Syntax
The entry in a .gxr file to register a code module (that is not an AppLogic object or an iPlanet Extension) uses the following syntax:Module name [:type=c][:descr[:AppName;group;...]]
The items in the syntax are as follows:
name: Name of the module.
:type=c: Optional letter c to indicate that the module is written in C++.
:descr: Optional description which will appear in the Application Administrator.
:AppName;group;...: Optional semicolon-separated list of groups to which the module belongs. The first group should be the name of the application.
Globally unique identifier (GUID) that was generated by kguidgen.
Relative path to the code module. For cross-platform compatibility, you can omit the extension of the file (such as .dll or .so). For increased portability, it is advisable to use relative paths in the .gxr file.
(Optional) Comments. Each line can end with a comment preceded by the vertical bar character |.
Example
The following lines show the .gxr file entry for a code module:Module DigiBank CICS Integration:type = c
{e248ecd0-9bfd-bc32-00a024d1709f}
User .gxr Syntax
The entry in a .gxr file to register a user has the following syntax:The items in the syntax are as follows:
name: Name of the user.
Password: The user's password.
group;...: Optional semicolon-separated list of groups to which the user belongs. These groups are defined elsewhere in the .gxr file, using the syntax described later in this section.
(Optional) Comments. Each line can end with a comment preceded by the vertical bar character |.
Example
The following lines show the .gxr file entry for a user:DigiBankUsers;DigiBankAdministrators
User Group .gxr Syntax
The entry in a .gxr file to register a user group has the following syntax:The items in the syntax are as follows:
name: Name of the user group.
(Optional) Comments. Each line can end with a comment preceded by the vertical bar character |.
Example
The following lines show the .gxr file entry for a user group:
ACL .gxr Syntax
The entry in a .gxr file to register a named access control list (ACL) uses the following syntax:The items in the syntax are as follows:
name: Name of the ACL.
user,[!]permission;...: Optional semicolon-separated list of ACL entries, to specify which users can perform operations. Each ACL entry uses the following syntax:
(Optional) Comments. Each line can end with a comment preceded by the vertical bar character |.
- User is the name of a user or user group, as specified by the system administrator. Permission is an operation name, such as EXECUTE, READ, or WRITE . An exclamation point in front of the permission means the user or user group can not perform that operation.
Example
The following lines show the .gxr file entry for an ACL:DigiBankAdmin,ADMIN;DigiBankPartner,!READ
Saving and Restoring Registry Configurations
As described in the previous section, the iPlanet Application Server maintains a record of registered application items in local registry storage. You can save and restore snapshots of the registry by using the kreg utility. You might want to do this for the following reasons:
Back up registry settings.
More easily bring up secondary, replicated servers.
More easily bring up replicated engines or control sets.
Save, replicate, and manually synchronize registry information about users, user groups, ACLs, AppLogics, and iPlanet Extensions across multiple machines.
Debug administration settings.
Remotely view and debug a configuration.
Allow various groups in your organization to swap between saved configurations, especially if certain registry configurations are required for certain tests, such as load balancing, partitioning, and stress testing.
Replicate AppLogic information to the Web server tier. This supports better AppLogic load balancing from the Web server. It also allows encryption of AppLogic requests on a per-AppLogic basis between a Web server and Executive Server.
To Save the Registry
To save a snapshot of the current registry settings, run the kreg utility from a command line or window using the following syntax:kreg -save fileName key1 [key2...]
The fileName is the file in which the registry settings are saved. The key is the path to a registry key, starting from the root key. For example:
kreg -save mytest.data SOFTWARE\KIVA\Enterprise\2.0\CCS0\DAE
To Restore the Registry
To save a snapshot of the current registry settings, run the kreg utility from a command line or window using the following syntax:kreg -load fileName [fileName2...]
The fileName is the file in which the registry settings were saved. For example:
Debugging with Third-Party Tools
You can test and debug AppLogic objects using the debugging tools in your C++ development toolkit. The tools available vary depending on the machine and operating system you are using. iPlanet Application Builder integrates with several debugging tools.The following steps give a general outline of the debugging process. Specific procedures for each debugging tool follow.
General steps to debug AppLogic
Compile the AppLogic using the debug option.
Start your debugging tool.
Determine the process ID of the C++ Server process you want to debug.
Using this process ID, attach to the C++ Server process from within your debugging tool.
Set a breakpoint in your AppLogic.
- For example, if you are using msdev on Microsoft Windows NT, use the menus. If you are using dbx on UNIX, use the command attach PID.
- Note: The AppLogic you are trying to debug may not yet be loaded into the C++ Server. Most debugging tools will still allow you to set the breakpoint in the AppLogic before it has been loaded. If not, execute the AppLogic once so that it is loaded.
Execute your AppLogic.
At the breakpoint, begin stepping through your AppLogic code.
Debugging with MSVC (Version 4.2 or Higher)
To debug code using Microsoft Visual C++, in addition to any projects that you use to build your AppLogic code, you must create a project of type "Console Application" that contains no code files at all, but simply specifies the C++ Server .EXE file of your Netscape Application Server installation as its executable. After invoking your AppLogic once, you will be able to open its source files in the MSVC's editor and set breakpoints in these files.
Create the Project
File - New- Project Workspace.
Console Application; any name you like; Location can be any directory, but it will be convenient to use the root directory of your AppLogic tree.
Set Up the Project
Build - Settings (Alt-F7)
Select the "Win32 Debug" configuration.
In "Category", select General.
As "Executable for debug session" supply the path to the C++ Server .EXE file in your Runtime Environment.
"Program arguments": -debug (may not be necessary).
In "Category", select Additional DLLs.
In the Modules list, add one or more DLLs from your AppLogic and check the boxes to the left of their names.
Run the Project
Start the Netscape Application Builder Runtime Environment and shut down the C engine once initialization is complete.
"One or more files are out of date ...?": choose No.
"One or more breakpoints cannot be set ....": choose OK.
"First-chance exception ....": choose OK.
"Pass exception on to the program being debugged?": choose Yes.
File - Open and open one or more source files from the additional DLLs you specified in "Set up" above.
Set breakpoints in these files, as needed.
Bring up a suitable form in a Web browser or somehow cause your AppLogic to execute, and debug normally.
Previous Contents Index DocHome Next
Copyright © 2000 Sun Microsystems, Inc. Some preexisting portions Copyright © 2000 Netscape Communications Corp. All rights reserved.
Last Updated April 26, 2000