|
The examples provided with WebNMS SNMP API are for one of the following application server.
BEA Weblogic server is one of many EJB capable application servers in the market. These examples can easily be migrated to other EJB application servers. For the client example, this is usually done by simply changing imports for JNDI. The SNMP server startup class needs to be modified for each application server. Future releases of WebNMS SNMP will provide detailed instructions on using other EJB application servers.
First, obtain and install the EJB application server: The BEA Weblogic server can be obtained from the BEA web site. Follow the instructions for application server installation.
The user should follow the steps given below to successfully use the examples provided in the ejbclient directory for SNMP operations.
Configure the SnmpEJBServer factory: The SnmpEJBServer factory is responsible for the creation of the various SNMP Bean components required by the EJB components to perform SNMP operations. This module handles all the SNMP-specific operations, interfacing with the EJB components on one side and the SNMP agent on the other side. The user should start the SnmpEJBServer within the application server. This is done for BEA Weblogic using an SNMP server startup class that is configured in the weblogic.properties file. Refer "Plug in the startup class in the application server".
However, initially the you should create a startup class to start SnmpEJBServer in the application server. This is specific to the application server you intend to use. A sample application SnmpStarter is packaged for your reference and you can modify this class if required. Compile this class in <WebNMS\SNMPAPI\reference\ejb> directory.
A sample code snippet for starting the SnmpEJBServer factory is as follows.
|
public String startup(String name, Hashtable args) throws Exception { try { SnmpEJBServerImpl factory = null; String usage = "java SnmpEJBServerImpl [-hp host:port]"; factory = new SnmpEJBServerImpl(); Environment env = new Environment(); Context ctx = env.getInitialContext(); ctx.bind(name, factory); } catch( Exception e ) { System.err.println("SnmpEJBServerImpl: "+ e.getMessage()); e.printStackTrace(); } } |
Plug in the startup class in the application server: You need to make the desired changes in the application server's property file for plugging the startup class. For example in BEA Weblogic, the SNMP server startup class is configured using the weblogic.properties server configuration file. The configuration should specify the name to be used for JNDI lookups that is consistent with the names provided to the EJB components during deployment in the deployment descriptors. A sample property file entry for launching the SNMP server in the application server can be as follows.
|
weblogic.system.startupClass.SnmpEJBServer=com.adventnet.snmp.weblogic.SnmpStarter |
Start the application server: The user should start the application server. This also starts the SnmpEJBServer factory. Check for error messages during startup.
|
|
Note: Users should ensure that the required jar files are available in the CLASSPATH of the server. For example for BEA Weblogic on NT, the following command in the startWeblogic.cmd batch file sets up the path to include AdventNetSnmp.jar, AdventNetRMI.jar, AdventNetEJB.jar, AdventNetLogging.jar, a jar file containing SnmpStarter.class.
It is assumed that the com.adventnet.snmp.weblogic.SnmpStarter class is available in <WebNMS\SNMPAPI\reference\ejb> directory. If it is in a different directory, include it in the PRE_CLASSPATH. |
Deploy the EJB component into the application server: The user needs to deploy the EJB components, such as SnmpTargetEJB, SnmpTableEJB, and MibOperationsEJB within the application server before executing the example applications. BEA Weblogic, as well as other application servers, provide a deployment tool with the application server for this purpose. WebNMS provides three jar files namely std_SnmpTargetEJB.jar, std_SnmpTableEJB.jar, and std_MibOperationsEJB.jar in the <WebNMS\SNMPAPI\reference\ejb> directory. These are the jar files required for the deployment tools. Follow the instructions to use the individual deployment tools corresponding to the application server.
|
The jar file std_SnmpTargetEJB.jar contains : SnmpTargetEJB component SnmpTarget interface SnmpTargetHome interface ejb-jar.xml |
|
The jar file std_SnmpTableEJB.jar contains : SnmpTableEJB component, SnmpTable interface SnmpTableHome interface ejb-jar.xml |
|
The jar file std_MibOperationsEJB.jar contains : MibOperationsEJB component, MibOperations interface MibOperationsHome interface ejb-jar.xml |
|
|
Note:
|
Test example applications: After the above steps are completed, client applications can communicate with the EJB components to perform SNMP operations. Compile and test the example applications and include the application server's classes in your CLASSPATH.
The following are the steps involved in deployment and usage of AdventNetSNMP EJB jar in WebLogic 7.0 edition.
Standard Setting
Copy the following jars from the WebNMS SNMP API package and drop them under <WebLogic HOME>\server\ext directory.
AdventNetSnmp.jar
AdventNetRMI.jar
AdventNetEJB.jar
AdventNetLogging.jar
A jar file containing SnmpStarter.class (explained later).
Edit the startWLS.bat file (at <WebLogic HOME>\server\bin directory) and include the above mentioned AdventNetSNMP jar files in the CLASSPATH environment variable.
|
|
Note: The AdventNetSNMP jar files should be present before the weblogic.jar in the CLASSPATH. |
Deployment Steps
Ensure the standard settings are performed.
Update the AdventNet SNMP EJB jar file with a valid weblogic-ejb-jar.xml file into the META-INF directory.
Save the updated jar file.
Drop the above jar file into the <WebLogic HOME>\samples\server\config\examples\applications directory. When the WebLogic Server starts the jar will get deployed automatically.
Steps to start the SnmpStarter class with the WebLogic server
Ensure the standard settings are performed.
Compile the SnmpStarter.java at <WebNMS\SNMPAPI\reference\ejb> directory. Create a jar file, say SnmpStarter.jar, with the compiled SnmpStarter.class.
Example: javac SnmpStarter.java -d temp
From the tempdirectory execute the following.
jar -cvf SnmpStarter.jar com
Add the following line in the config.xml file.(<WebLogic_HOME>\samples\server\config\examples directory). <StartupClass ClassName="com.adventnet.snmp.weblogic.SnmpStarter"
FailureIsFatal="true" Name="SnmpEJBServer" Targets="examplesServer"/>
Steps to run the client examples
Ensure the standard settings are performed, EJB bean is deployed successfully, and the SnmpStarter class is running.
Now, run the client examples (present in <WebNMS\examples\ejbclient> directory).
Example:java ejbget localhost 1.1.0
The above command fetches the data successfully.
Deployment in Weblogic 6.1 Beta
The following are the steps involved in deployment and usage of AdventNetSNMP EJB jar in WebLogic 6.1 beta edition.
Standard Setting
Edit the setEnv.bat file (at <WebLogic HOME>\config\mydomain directory) and include the following in the CLASSPATH.
AdventNetSnmp.jar
AdventNetRMI.jar
AdventNetEJB.jar
AdventNetLogging.jar
Jar file containing SnmpStarter.class
Edit the startWebLogic.cmd file and include above-mentioned jar files in the CLASSPATH.
Deployment Steps
Ensure the standard settings are performed.
Update the AdventNetSNMP EJB jar files with a valid weblogic-ejb-jar.xml file into the META-INF directory.
Save the updated jar file.
To the above jar file, run weblogic.ejbc to generate the container classes.
Usage: java weblogic.ejbc [options] < source jar file > < target directory or jar file >
Example: java weblogic.ejbc c:\EJBJars\std_SnmpTarget.jar c:\weblogic\mydomain\applications\SnmpTarget.jar
The example command would generate container classes and put them in the SnmpTarget.jar file. This SnmpTarget.jar file is deployed into the WebLogic container.
Now deploy the jar containing the generated container classes and other user-defined classes into the container using the following command.
Usage:java weblogic.deploy [options] [list|deploy|undeploy|update] password {name} {source}
Example: java weblogic.deploy deploy <password> SnmpTargetEJB c:\weblogic\mydomain\applications\SnmpTarget.jar
The above command deploys the EJB into the container.
|
|
Note: The WebLogic server should be running while deploying the EJB. |
Steps to start the SnmpStarter class with the WebLogic Server
Ensure the standard settings are performed.
Compile the SnmpStarter.java present in <AdventNet\SNMPAPI\reference\ejb> directory.
Example: javac SnmpStarter.java -d temp
Add the following line in the config.xml file.(<WebLogic_HOME>\config\mydomain directory)
<StartupClass ClassName="com.adventnet.snmp.weblogic.SnmpStarter" Name="SnmpEJBServer" Targets="myserver"/>
Now, run the script startWebLogic.cmd. This starts the SnmpStarter class with the WebLogic server. /p>
|
|
Note: If the WebLogic server is already running while doing the changes to the config.xml file, the changes would not take effect. Therefore, shut down the server before making the changes and then restart after the changes are made. |
Steps to run the client examples
Ensure the standard settings are performed, EJB bean is deployed successfully and the SnmpStarter class is running.
Now, run the client examples (<WebNMS\SNMPAPI\examples\ejbclient> directory).
Example: java ejbget localhost 1.1.0
The above command fetches the data successfully.
For further information on using weblogic.ejbc and weblogic.deploy, refer the following URLs.
http://e-docs.bea.com/wls/docs61/ejb/EJB_utilities.html#1075296
http://e-docs.bea.com/wls/docs61/ejb/EJB_deployover.html
The following are the steps involved in deployment and usage of AdventNetSNMP EJB jar WebLogic 5.1 edition.
Standard Setting
Edit the setEnv.bat file (<WebLogic HOME> directory) and include the following jars in the CLASSPATH variable.
AdventNetSnmp.jar
AdventNetRMI.jar
AdventNetEJB.jar
AdventNetLogging.jar
Jar file containing SnmpStarter.class
Steps to start the SnmpStarter class with the WebLogic server
Ensure the standard settings are performed.
Compile SnmpStarter.java at <WebNMS\SNMPAPI\reference\ejb> directory.
Example: javac SnmpStarter.java -d temp
Edit the weblogic.properties file in <Weblogic-Home> directory.
weblogic.system.startupClass.SnmpEJBServer=com.adventnet.snmp.weblogic.SnmpStarter
Now, run the scriptstartWebLogic.cmd. This starts the SnmpStarter class with the WebLogic Server.
Deployment Steps
Ensure the standard settings are performed.
Update the AdventNet SNMP EJB jar file with a valid weblogic-ejb-jar.xml file into the META-INF directory.
Save the updated jar file.
To the above jar file, run weblogic.ejbc to generate the container classes.
Usage: java weblogic.ejbc [options] <source jar file> <target directory or jar file>
Example:java weblogic.ejbc c:\EJBJars\std_SnmpTarget.jar
c:\ejbExamples\temp\SnmpTarget.jar
The example command generates container classes and puts them in the SnmpTarget.jar file. This SnmpTarget.jar file is deployed into the WebLogic container.
Now deploy the jar containing the generated container classes and other user-defined classes into the container using the following command.
Usage: java weblogic.deploy [options] [list|deploy|undeploy|update] password {name} {source}
Example: java weblogic.deploy deploy <password> SnmpTargetEJB c:\ejbExamples\temp\SnmpTarget.jar
The above command deploys the EJB into the container.
|
|
Note: The WebLogic server should be running while deploying the EJB. |
Steps to run the client examples
Make sure the standard settings are performed, EJB bean is deployed successfully, and the SnmpStarter class is running.
Now, run the client examples (at <WebNMS>\SNMPAPI\examples\ejbclient directory).
Example: java ejbget localhost 1.1.0
The above command fetches the data successfully.
|