Developing Applications with WebLogic SIP Server

     Previous  Next    Open TOC in new window    View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

Developing SIP Servlets Using Eclipse

The following sections describe how to use Eclipse to develop SIP Servlets for use with WebLogic SIP Server:

 


Overview

This document provides detailed instructions for using the Eclipse IDE as a tool for developing and deploying SIP Servlets with WebLogic SIP Server. The full development environment requires the following components, which you must obtain and install before proceeding:

SIP Servlet Organization

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 13-1.

Figure 13-1 SIP Servlet WAR Contents

SIP Servlet WAR Contents

 


Setting Up the Development Environment

Follow these steps to set up the development environment for a new SIP Servlet project:

  1. Create a new WebLogic SIP Server Domain.
  2. Create a new Eclipse project.
  3. Create an Ant build file.

The sections that follow describe each step in detail.

Creating a WebLogic SIP Server Domain

In order to deploy and test your SIP Servlet, you need access to a WebLogic SIP Server domain that you can reconfigure and restart as necessary. Follow the instructions in Create an Administrative Domain in the Installation Guide to create a new domain using the Configuration Wizard. When generating a new domain:

Configure the Default Eclipse JVM

The latest versions of Eclipse use the version 1.5 JRE by default. Follow these steps to configure Eclipse to use the version 1.4.2 JRE installed with WebLogic SIP Server:

  1. Start Eclipse.
  2. Select Window->Preferences
  3. Expand the Java category in the left pane, and select Installed JREs.
  4. Click Add... to add the new JRE.
  5. Enter a name to use for the new JRE in the JRE name field.
  6. Click the Browse... button next to the JRE home directory field. Then navigate to the BEA_HOME/jdk142_08 directory and click OK.
  7. Click OK to add the new JRE.
  8. Select the check box next to the new JRE to make it the default.
  9. Click OK to dismiss the preferences dialog.

Creating a New Eclipse Project

Follow these steps to create a new Eclipse project for your SIP Servlet development, adding the WebLogic SIP Server libraries required for building and deploying the application:

  1. Start Eclipse.
  2. Select File->New->Project...
  3. Select Java Project and click Next.
  4. Enter a name for your project in the Project Name field.
  5. 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.
  6. Click the Libraries tab and follow these steps to add required JARs to your project:
    1. Click Add External JARs...
    2. Use the JAR selection dialog to add the BEA_HOME/sipserver31/server/lib/weblogic.jar file to your project.
    3. Click Add External JARs... once again.
    4. Use the JAR selection dialog to add the BEA_HOME/sipserver31/telco/auxlib/sipservlet.jar file to your project.
    5. (Optional.) If your application needs to access WebLogic SIP Server MBeans using JMX, also use the JAR selection dialog to add BEA_HOME/sipserver31/telco/lib/wcp_sip_core.jar to your project.
  7. Add any additional JAR files that you may require for your project.
  8. Click Finish to create the new project. Eclipse displays your new project name in the Package Explorer.
  9. Right-click on the name of your project and use the New->Folder command to recreate the directory structure shown in Figure 13-1, SIP Servlet WAR Contents, on page 13-2.

Creating an Ant Build File

Follow these steps to create an Ant build file that you can use for building and deploying your project:

  1. Right-click on the name of your project in Eclipse, and select New->File
  2. Enter the name build.xml and click Finish. Eclipse opens the empty file in a new window.
  3. Copy the sample text from Listing 13-1, substituting your domain name and application name for myDomain and myApplication.
  4. Listing 13-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>
  5. Close the build.xml file and save your changes.
  6. Verify that the build.xml file is valid by selecting Window->Show View->Ant and dragging the build.xml file into the Ant view. Correct any problems before proceeding.
  7. Right-click on the project name and select Properties.
  8. Select the Builders property in the left column, and click New.
  9. Select the Ant Build tool type and click OK to add an Ant builder.
  10. In the Buildfile field, click Browse Workspace and select the build.xml file you created.
  11. In the Base Directory field, click Browse Workspace and select the top-level directory for your project.
  12. 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.4.2 JRE.
  13. Click the Environment tab, and 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 WebLogic SIP Server directory. For example:
    • Name: BEA_HOME
    • Value: c:\bea
  14. Click OK to add the new Ant builder to the project.
  15. De-select Java Builder in the builder list to remove the Java builder from the project.
  16. Click OK to finish configuring Builders for the project.

 


Building and Deploying 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. WebLogic SIP Server automatically deploys valid applications located in the /applications subdirectory.

 


Debugging SIP Servlets

In order to debug SIP Servlets, you must enable certain debug options when you start WebLogic SIP Server. Follow these steps to add the required debug options to the script used to start WebLogic SIP Server:

  1. Use a text editor to open the StartWebLogic.cmd script for your development domain.
  2. Beneath the line that reads:
  3. set JAVA_OPTIONS=

    Enter the following line:

    set DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=9000,server=y,suspend=n
  4. In the last line of the file, add the %DEBUG_OPTS% variable in the place indicated below:
  5. "%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
  6. Save the file and use the script to restart WebLogic SIP Server.

  Back to Top       Previous  Next