Oracle® Communications Converged Application Server SIP Application Development Guide Release 5.0 Part Number E17654-02 |
|
|
View PDF |
This chapter describes how to use Eclipse to develop SIP Servlets for use with Oracle Communications Converged Application Server:
This document provides detailed instructions for using the Eclipse IDE as a tool for developing and deploying SIP Servlets with Converged Application Server. The full development environment requires the following components, which you must obtain and install before proceeding:
Converged Application Server
JDK 1.6.05
Ant (installed with Converged Application Server)
Eclipse version 3.4 or Eclipse 3.3 Europe. This includes a CVS client and server (required only for version control).
Building a SIP Servlet produces a Web Archive (WAR file or directory) as an end product. A basic SIP Servlet WAR file contains the subdirectories and contents described in Figure 10-1.
Follow these steps to set up the development environment for a new SIP Servlet project:
Create a new Converged Application Server Domain.
Create a new Eclipse project.
Create an Ant build file.
The sections that follow describe each step in detail.
In order to deploy and test your SIP Servlet, you need access to a Converged Application Server domain that you can reconfigure and restart as necessary. Follow the instructions in "Create an Administrative Domain" in Converged Application Server Installation Guide to create a new domain using the Configuration Wizard. When generating a new domain:
Select Development Mode as the startup mode for the new domain.
Select Sun SDK 1.6.05 as the SDK for the new domain.
Eclipse 3.4 uses the required version Java 6 (1.6) by default. Follow these steps to verify the configured JVM:
Start Eclipse.
Select the Window menu, then select Preferences.
Expand the Java category in the left pane, and select Installed JREs.
Verify that Java 6 (1.6) is configured. If it is, proceed to step 5; if it is not, do the following:
Click Add to add a new JRE.
Enter a name to use for the new JRE in the JRE name field.
Click Browse (next to the JRE home directory field), navigate to the jdk160_18
directory under the Converged Application Server installation directory, and click OK.
Click OK to add the new JRE.
Select the check box next to the new JRE to make it the default.
Click OK to dismiss the preferences dialog.
Follow these steps to create a new Eclipse project for your SIP Servlet development, adding the Converged Application Server libraries required for building and deploying the application:
Start Eclipse.
Select the File menu, then select New, and then select Project.
Select Java Project and click Next.
Enter a name for your project in the Project Name field.
In the Location field, select Create project in workspace if you have not yet begun writing the SIP Servlet code. If you already have source code available in another location, select Create project at external location and specify the directory. Click Next.
Click the Libraries tab and follow these steps to add required JARs to your project:
Click Add External JARs.
Use the JAR selection dialog to add the WL_HOME/server/lib/weblogic.jar
file to your project.
Repeat the process to add the WLSS_HOME/sip/server/lib/sipservlet.jar
and WLSS_HOME/sip/server/lib/wlssapi.jar
files to your project.
Add any additional JAR files that you may require for your project.
To enable deploying directly from Eclipse, change the build folder from /src/build to /src/WebContent/WEB-INF/classes. This means that you do not have to package the application before deploying it.
Click Finish to create the new project. Eclipse displays your new project name in the Package Explorer.
Right-click on the name of your project and select New, and then Folder to recreate the directory structure shown in Figure 10-1, "SIP Servlet WAR Contents".
Follow these steps to create an Ant build file that you can use for building and deploying your project:
Right-click on the name of your project in Eclipse, and select New, and then select File.
Enter the name build.xml
and click Finish. Eclipse opens the empty file in a new window.
Copy the sample text from Example 10-1, substituting your domain name and application name for myDomain
and myApplication
.
Example 10-1 Ant Build File Contents
<?xml version="1.0" encoding="ISO-8859-1"?> <project default="all"> <property environment="env"/> <property name="beahome" value="${env.BEA_HOME}"/> <target name="all" depends="compile,install"/> <target name="compile"> <mkdir dir="WEB-INF/classes"/> <javac destdir="WEB-INF/classes" srcdir="src" debug="true" debuglevel="lines,vars,source"> <classpath> <pathelement path="${weblogic.jar}"/> </classpath> </javac> </target> <target name="install"> <jar destfile="${beahome}/user_projects/domains/myDomain/applications/myApplication.war"> <zipfileset dir="WEB-INF" prefix="WEB-INF"/> <zipfileset dir="WEB-INF" includes="*.html"/> <zipfileset dir="WEB-INF" includes="*.jsp"/> </jar> </target> </project>
Close the build.xml
file and save your changes.
Verify that the build.xml
file is valid by selecting the Window menu, then select Show View, and then select Ant and dragging the build.xml
file into the Ant view. Correct any problems before proceeding.
Right-click on the project name and select Properties.
Select the Builders property in the left column, and click New.
Select the Ant Build tool type and click OK to add an Ant builder.
In the Buildfile field, click Browse Workspace and select the build.xml
file you created.
In the Base Directory field, click Browse Workspace and select the top-level directory for your project.
Click the JRE tab and choose Separate JRE in the Runtime JRE field. Use the drop-down list or the Installed JREs... button to select an installed version 1.6 JRE.
Click the Environment tab, and then click New. Enter a new name/value pair to define the BEA_HOME
variable. The BEA_HOME
variable must point to the home directory of the Converged Application Server directory. For example:
Name: BEA_HOME
Value: c:\bea
Click OK to add the new Ant builder to the project.
De-select Java Builder in the builder list to remove the Java builder from the project.
Click OK to finish configuring Builders for the project.
The build.xml
file that you created compiles your code, packages the WAR, and copies the WAR file to the /applications
subdirectory of your development domain. Converged Application Server automatically deploys valid applications located in the /applications
subdirectory.
In order to debug SIP Servlets, you must enable certain debug options when you start Converged Application Server. Follow these steps to add the required debug options to the script used to start Converged Application Server and to attach the debugger from within Eclipse.
Note:
On Linux, debug is enabled by default if you install in developer mode. However, the port is set to 8453.Use a text editor to open the StartWebLogic.cmd
script for your development domain.
Beneath the line that reads:
set JAVA_OPTIONS= Enter the following line: set DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=9000,server=y,suspend=n
In the last line of the file, add the %DEBUG_OPTS%
variable in the place indicated below:
"%JAVA_HOME%\bin\java" %JAVA_VM% %MEM_ARGS% %JAVA_OPTIONS% %DEBUG_OPTS%
-Dweblogic.Name=%SERVER_NAME% -Dweblogic.management.username=%WLS_USER%
-Dweblogic.management.password=%WLS_PW%
-Dweblogic.management.server=%ADMIN_URL%
-Djava.security.policy="%WL_HOME%\server\lib\weblogic.policy" weblogic.Server
Save the file and use the script to restart Converged Application Server.
To attach the debugger from within Eclipse select Run, and then select the Open debug dialog box.
Create a new "Remote Java Application".
Enter the host and port corresponding to the DEBUG_OPTS.