Creating a WAR File with the Reference Details

Procedure

  1. Create a WTP or dynamic project for the WAR project.

  2. Generate the interface JAR files (using JAXB or XMLBeans) using the WSDL.
    1. Select the WSDL file associated with the WebApp component.
    2. Right-click and select Generate XML Data Bindings. The XML Data Binding Classes dialog is displayed. For more information about the fields in the XML Data Binding Classes dialog box, see XML Data Binding Classes Dialog.

    3. Select the Type as JAXB or XMLBeans. The default is XMLBeans.
    4. Note the location of the JAR file in the JAR File field.
    5. Click Finish.
  3. Add the JAR file mentioned in the location in step 2d to the WEB-INF/lib folder of the WTP project.
  4. Create the reference in the servlet file using the @Reference annotation (Java resources > src > <name>.wtp). For example, for the <TIBCO_HOME>/amx/<version>/samples/webapp/helloworld2 sample, copy the code as documented below.
    • From:

      Java resources > src > com.webapp.helloworld2.wtp > AbstractWebAppHelloComponent.java

    • Copy code:
      private HelloWorldPT HelloWorldPT;
      @Reference(name = "HelloWorldPT")
      public void setHelloWorldPT(HelloWorldPT HelloWorldPT) 
      {
      this.HelloWorldPT = HelloWorldPT;
      }
      public HelloWorldPT getHelloWorldPT() 
      {
      return this.HelloWorldPT;
      }
    • To:

      Java resources > src > com.webapp.helloworld2.wtp > WebAppHelloComponent.java

  5. Add the code to call the reference. (to WebAppHelloComponent.java in this example).

  6. Make sure all the servlets using the @Reference annotation are declared in the web.xml file. For example:
    <servlet>
    <display-name>WebAppHelloComponent</display-name>
    <servlet-name>WebAppHelloComponent</servlet-name>
    <servlet-class>com.webapp.helloworld2.wtp.WebAppHelloComponent</servlet-class>
    </servlet>
    
    <servlet>
    <display-name>AbstractWebAppHelloComponent</display-name>
    <servlet-name>AbstractWebAppHelloComponent</servlet-name>
    <servlet-class>com.webapp.helloworld2.wtp. AbstractWebAppHelloComponent</servlet-class>
    </servlet>
  7. Export the WTP project or dynamic project to WAR file. Right-click on the composite and select Export > WAR file.

  8. Click Finish.