如何在 webMethods Integration Server 和 webMethods Designer 中添加用于开发 java 服务的外部 jar

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

我想在某些 Java 服务(WebMethod 设计器 9.7)中使用外部 jar。我在 Internet 文档中看到我必须将我的 jar 放在 Integration Server 上的包 /code/jars/ 路径中,以及我在 eclipse 中的项目的构建路径中。 但我不知道该怎么做。

我试图通过重新启动 IS 将我的 jar 放入 $swag_instance$/packages/$package_name$/code/jars,但是我有编译时错误。

你能帮我理解我必须做些什么吗,在 java 服务中使用外部 jar?

建议通常将 jar 与使用它的 IS 包捆绑在一起,这样更容易作为一个独立的单元进行部署,并与其依赖项一起迁移。

因此,将它放在 packages/(package name)/code/jars 中应该足以让它可以从该 IS 包的 Java 服务中调用。

或者,如果您想让整个 IS 中的所有 Java 服务都可以使用该 jar,packages/(package name)/code/jars/static 是放置它的好地方。

在此处查看一个有趣的 wiki 页面,该页面描述了 webMethods Integration Server Class-Loading 机制以及搜索 jar、类 和库的顺序中的几个位置。

SoftwareAG webMethods Designer 需要您将外部 JAR 添加到以下两者:

  1. Integration Server 包,位于 ./packages/<package>/code/jars/./packages/<package>/code/jars/static/ 文件夹中,具体取决于您是需要动态加载 JAR 且仅供拥有包使用,还是在服务器启动时静态加载并可用于所有包分别,和
  2. 服务开发项目 Designer 在 Eclipse 工作区中为包创建的 文件夹.

您可能还没有完成第二步,这就是您的服务无法编译或出现错误的原因。

webMethods 服务开发帮助 指南(9.8 版)的第 312 页有以下建议:

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.

第 317 页然后描述了如何将 类 和 JAR 添加到服务 开发项目:

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.