Search code examples
javaeclipsejarwebmethods

How to add an external jars for developing a java service in webMethods Integration Server and webMethods Designer


I would like to use an external jar in some Java Service (WebMethod designer 9.7). I see in Internet documentation that I have to put my jar in the package /code/jars/ path on the Integration Server, and also in the build path of my project in eclipse. But I dont know how to do this.

I have attempted to put my jar in $swag_instance$/packages/$package_name$/code/jars, with restarting IS, but I have compile time errors.

Could you please help me to understand what actions i have to do to doing that, using an external jar in a java service ?


Solution

  • The SoftwareAG webMethods Designer needs you to to add your external JARs to both:

    1. The Integration Server package, in either the ./packages/<package>/code/jars/ or ./packages/<package>/code/jars/static/ folders depending on whether you need the JARs loaded dynamically and only available to the owning package or loaded statically at server startup and available to all packages respectively, and
    2. The Service Development Project that Designer creates for the package in your Eclipse workspace folder.

    You probably haven't done the second step and that's why your service won't compile or has errors.

    Page 312 of the webMethods Service Development Help guide (version 9.8) has the following advice:

    If your Java service requires additional classes to compile, you must add them, either as individual class files or in jar files, to both the Service Development Project and to Integration Server. If you set up IS package dependencies for the Java service in Integration Server and there are classes and/or jar files in the IS packages required so that the service can compile, you must manually add them to Service Development Project. For more information, see "Adding Classes to the Service Development Project" on page 317. For more information about adding classes to Integration Server and how Integration Server stores package information, see webMethods Integration Server Administrator’s Guide.

    Page 317 then describes how to add classes and JARs to the Service Development Project:

    Adding Classes to the Service Development Project

    If a Java service requires additional classes to compile, you must add them to the following locations:

    • Service Development Project in the local workspace so that Designer can compile the service.
    • Integration Server so that the server can compile the service. Designer does not automatically propagate classes that you add to the Service Development Project to Integration Server; you must add them to Integration Server manually. For more information about adding classes to Integration Server, see information about managing IS packages and how Integration Server stores IS package information in webMethods Integration Server Administrator’s Guide.

    Keep the following points in mind when adding classes to the Service Development Project:

    • You add individual class files to the classes folder of the Service Development Project.
    • If you have Java classes that are packaged together in jar files, you add the jar files to the lib folder of the Service Development Project.
    • If you set up IS package dependencies for a Java service in Integration Server and there are classes and/or jar files in the IS packages required so that the service can compile, you must manually add them to Service Development Project.

    To add classes and jar files to the Service Development Project:

    1. Open the Project Explorer view.
    2. Expand the Service Development Project for the Java service. Service Development Project names use the following format, where packageName is the name of the IS package where the service resides, hostName is the host name of the Integration Server on which the service resides, and portNumber is the port number of the Integration Server:

      <packageName >[<hostName >_<portNumber >]

      For example, if you want to add class and jar files for the order.orderStatus:checkStatus service that resides in the IS package Accounting on the Integration Server with the host name and port number ServerA:5555, you would expand the Service Development Project with the following name:

      Accounting[ServerA_5555]

      For more information, see "Service Development Projects in the Local Workspace" on page 308.

    3. If you want to add class files to the Service Development Project, drag them from the file system into the classes folder of the Service Development Project in the Project Explorer view.

      When adding class files, ensure that you keep the structure of the Java package intact. For example, if you want to add com.accounting.orders.statusClass.class, you must first create the com, accounting, and orders folders within the classes folder as shown below:

      • classes
        • com
          • accounting
            • orders

      Then add the statusClass.class file to the orders folder.

    4. If you want to add jar files to the Service Development Project, drag them from the file system into the lib folder of the Service Development Project in the Project Explorer view.