FAQs and Programming Hints
Answers to frequently asked questions (FAQs) and programming hints are given into the following topics:
•General Topics
•Daemon Manager
•Online Help
General Topics
This topic addresses typical questions that do not apply to any particular CWCS component.
Q. How do I obtain the CWCS web protocol and port number from a JSP?
A. You can do this for an application running under Tomcat by querying the md.properties file located at NMSROOT/lib/classpath/, using the following code:
<%@ page import = "com.cisco.core.ccr.CCRInterface" %>
<%@ page import = "java.util.Properties" %>
<%@ page import = "java.io.FileInputStream" %>
ccr = new CCRInterface();
String propFile = ccr.getCCRData("CMFSSLInfoFile", "Custom");
FileInputStream fis = new FileInputStream(propFile);
Properties prop = new Properties();
String port = prop.getProperty ("PX_PORT");
String protocol = prop.getProperty ("PX_PROTOCOL");
Q. Can CWCS support applications that must manage devices using multiple community strings?
A. Yes. The SnmpOnJava library in CWCS contains a property and API calls that support multiple SNMP credentials for IP ranges. The API and guidelines on implementing it, see the "Using CWCS SNMP Services" section on page 24-3.
Q. What do I need to know about casuser and upgrading?
A. If you are installing your application onto CiscoWorks for the first time, you do not need to worry about the casuser. If you are upgrading an existing application, you need to review the "Understanding and Implementing the casuser" section on page 21-21.
Remember that, because of the strengthening of security, you can only use port 1741. If you have port 80 hard coded, you need to update your code.
Q. How is the CD structured and where can I locate information on it?
A. The CD comprises the following directories:
•CodeSamples
•printdocs
•sdkhelp
•image_nt or image_sol
•readme_nt.txt or readme_unix.txt
Q. Can I pre-compile JSPs with CWCS? If so, how can I do it? What are the advantages of doing so?
A. A Java Server Page is normally compiled into its implementation class the first time a user accesses the page. Pre-compiling JSPs improves their performance in first-time accesses, and also reveals any syntax errors they may contain. You can precompile JSPs in a couple of ways:
–During Build Time: You use ANT or JSPC scripts given with Tomcast to precompile the JSPs into Java files, then use javac to compile them into class files and place them in the working directories.
–During Runtime/Install Time: You call each JSP with the pre-compiled option. The JSPServlet will interpret the request and compile each JSP into a class file.
CWCS pre-compiles JSP during build time, by creating the Tomcast runtime structure and using the JSPC script provided by Tomcat to compile into java files. It then changes the package of java files into "org.apache.jsp", compiles them into class files, and makes them part of the protopackages. All these class files are copied into the working directory during installation.
The CWCS scripts are at /vob/ismg-core/install/image/extract /bin. The CWCS build script calls the main precompile script prejsp.sh, which in turn uses jspc.sh and prejsp-build.sch. These scripts are specific to Common Services, but you can follow the same approach using these scripts as a reference.
Q. What do I enter during installation and when running commands on Windows platforms? This book provides only UNIX references.
A. Enter C:\Progra~1\CSCOpx to reference the Windows platform directory. Do not spell out "Program Files", since this will cause installation and command errors.
Q. When running Java server-side applications, should we use the cwjava command or directly reference the Java binaries?
A. Use the cwjava command. It provides a controlled runtime environment for CWCS-based Java server applications. For more information about cwjava, see the "Launching a Java Application" section on page 4-2.
Q. When I try running cwjava, I get the error message, Unable to locate CW2000 installation directory
.
A. When running cwjava from the command line, you must provide the -cw parameter. For example:
cwjava -cw /opt/CSCOpx ...
cwjava -cw C:\Progra~1\CSCOpx\ ...
Note On Windows platforms, the install directory should be specified without spaces (as shown above).
Q. When SSL is enabled on the server, the HTTP call from a device is blocked. Why does this happen? How can I fix this?
A. When SSL is enabled on the CWCS WebServer, access to the webserver is through HTTPS only. This means the HTTP port is blocked when SSL is enabled on the server. When the server is running in SSL (https mode), any HTTP call will fail.
An API is provided to fix this problem. This API defines necessary rules in the webserver configuration file by reading the list of entries (identified case-sensitive) from a file (addSetEnvIf.txt) under disk1 of the application's image. This API provides http access to the URLs of specified patterns.
SSL-complaint applications must identify scenarios where HTTP calls are made to the server, while running in the SSL enabled mode. The applications should do the following:
1. Identify the list of unique patterns in the URLs which should be accessible via HTTP when SSL is enabled.
2. If there are any such scenarios, create a file, addSetEnvIf.txt in disk1. This file should contain all such patterns.
Note During the application install, the install framework will define the required rules in the webserver configuration file based on the contents of addSetEnvIf.txt.
For example:
In RME's SWIM module, some devices (CSS11000 and NAM) contact the server through HTTP for image upgrading.
The format of the url would be http://servername:1741/swimtemp/c6nam.2- 1-2.bin.gz These images reside under /opt/CSCOpx/htdocs/swimtemp. In SSL mode, the above url request fails since port 1741 (used for HTTP connections) is blocked. In this case you have to allow the URLs that contain swimtemp, for which the contents of the addSetEnvIf.txt should be: swimtemp
Q. I installed CWCS on my system, but I don't see any database engine service running as part of CWCS. What must I do to start this service?
A. Installing CWCS does not automatically start the CWCS database. The CWCS database engine is only running when the CWCS System Services bundle is enabled.
To enable the CWCS System Services bundle, see the "Enabling New Service Bundles from the Command Line" section on page 5-7 or "Using CMFEnable" section on page 5-9.
Q. When I create my application, what methods should I use to report errors?
A. The method you use to report errors depends on where the error occurs:
•The UI component of an application should provide popup error dialog boxes.
•Server components of an application should log errors to a log file. Log files are stored in the LOG directory (see Chapter 3, "Understanding the CWCS Directory Structure").
Q. Are the application IDs passed in CAM authorization and registered with CCR case-sensitive?
A. Yes. Authorization will fail if if the application ID in the CAM API doesn't match exactly with the application ID registered in CCR.
Q. How can I enable MICE debugging?
A. In the NMSROOT/MDC/tomcat/webapps/classic/WEB-INF/web.xml file, change the DEBUG parameter value to read as follows:
<param-name>DEBUG</param-name>
<param-value>true</param-value>
<description>MICE debug enabling</description>
Daemon Manager
This topic answers typical questions about the Daemon Manager (also known as Process Manager).
Q. On Windows, we can integrate our GUI server with the Daemon Manager. It runs, but the GUI does not appear. We registered Notepad as a test and that did not appear either.
A. The Daemon Manager's job is to run programs that are typically background processes, which do not have a user interface, but takes up a lot of computing resources. In fact, part of the command line that the Daemon Manager uses to start a process redirects the stdout and stderr outputs to log files. If your application has both user interface and backend processing combined into one binary, then you should not register it with the Daemon Manager. If the application is web-enabled (can run in a browser), then you can register it with the desktop.
Q. Can I register a Windows NT Service using pdreg?
A. Yes. In order to register the service ServiceName with the Daemon Manager, you have to run: pdreg -r ServiceName where ServiceName is the name used to register this service with NT Service Manager.
Note The pdreg command allows you to register a process as a service, but you first have to create a Windows NT service (by registering it with Windows NT Service Manager) and then register the service with the Daemon Manager.
The Daemon Manager currently does not support Windows NT services completely: it will not restart the Windows NT Service if it fails. The Daemon Manager does that for normal processes. This may be a bug.
Q. Where in my program should I define the "Process Name" defined in pdreg and pdshow ?
A. The process name you use to instantiate the Daemon Manager object is the process name that appears in pdreg and pdshow command.For example, in Java, if you use dMgt theMgr = new dMgt(myDaemon);
then myDaemon is the process name used in pdreg and pdshow.
Q. Should I stop the Daemon Manager to register a new process?
A. No. You can register a process while the Daemon Manager is still running. However, the Daemon Manager will not start the execution of the newly-registered process. You must run the pdexec command to start this newly-registered process.
Q. If processes P2 and P3 depend on process P1, why do I have to run the pdexec for both P2 and P3 after P1 terminates?
A. After process P1 terminates, processes P2 and P3 will be brought down since they depend on P1. Daemon Manager will restart the crashed process P1. However, Daemon Manager does not keep the active process list when P1 terminates. Therefore, only P1 will be brought up again. P2 and P3 must be brought up manually using pdexec.
Q. If I use kill -9 to kill a process, why is the process not restarted automatically by the Daemon Manager?
A. This happens because signal -9 is the forced termination request issued by an operator.
Online Help
This topic answers typical questions about implementing online help.
Q. When the search engine displays the results, there is a blue column on the right that says In:Unknown
. I would like this to state the name of my book. Is there a parameter I can set that will do this for me? I am implementing a client-only help system without any drop-ins.
A. Add the SEARCH line to your mapping file, as follows:
SEARCH, "YOUR APP NAME", "searchfile.sch"
Then you should see YOUR APP NAME instead of Unknown.
Q. Must the DROPINPLACE lines always reference the index.html file? Even if I have more than one DROPINPLACE line in the mapping file? For example, I have three such lines in my help system's mapfile:
DROPINPLACE,"1","Server Configuration"
DROPINPLACE,"2","Server Configuration","What's New", /cmf/index.html
DROPINPLACE,"3","Server Configuration","Desktop", /cmf/index.html
A. Your DROPINPLACE
lines can point to any file, even the same file. If you choose to have these lines point to no file, make sure the line is a folder, just like your first example. Otherwise nothing happens when a reader clicks on the node. For more information about mapping files, see the "Understanding Mapping Files" section on page 11-14.