为UIMA AS应用程序设置第三方库

时间:2011-11-15 14:00:19

标签: classpath setup-deployment uima

我有一个使用第三方库的UIMA AS应用程序。我想知道以下内容: 1.在哪里(位置)我们可以添加这些第三个库,以便部署的应用程序能够了解它们而不是抛出“ClassNotFoundException”?    对我来说,一个强力解决方案是将它们直接添加到UIMA AS“lib /”文件夹中,但这个解决方案仅用于测试,在生产中是不可接受的。 2.如何在生成PEAR文件时设置此第三方库,以便部署应用程序将考虑它们并且不需要手动将它们添加到类路径中?

我期待你的回答。谢谢。

2 个答案:

答案 0 :(得分:1)

对于第一个问题:我的方法是 1.为第三个库创建一个lib文件夹 2.创建一个脚本,将脚本文件夹添加到UIMACLASSPATH

@set UIMA_CLASSPATH =%UIMA_CLASSPATH%; ../../ lib; ../../ bin 调用deployAsyncService.cmd 对于第二个问题:  我使用maven插件生成梨文件。

摘自pom.xml(与maven相关)

<plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-dependency-plugin</artifactId>
      <executions>
        <!-- Copy the dependencies to the lib folder for the PEAR to 
          copy -->
        <execution>
          <id>copy-dependencies</id>
          <phase>package</phase>
          <goals>
            <goal>copy-dependencies</goal>
          </goals>
          <configuration>
            <outputDirectory>${basedir}/lib</outputDirectory>
            <overWriteSnapshots>true</overWriteSnapshots>
            <includeScope>runtime</includeScope>
          </configuration>
        </execution>
      </executions>
    </plugin>
    <plugin>
      <groupId>org.apache.uima</groupId>
      <artifactId>PearPackagingMavenPlugin</artifactId>
      <version>2.3.1</version>

      <!-- if version is omitted, then -->
      <!-- version is inherited from parent's pluginManagement section -->
      <!-- otherwise, include a version element here -->

      <!-- says to load Maven extensions (such as packaging and type 
        handlers) from this plugin -->
      <extensions>true</extensions>
      <executions>
        <execution>
          <configuration>
            <classpath>
              <!-- PEAR file component classpath settings -->
              $main_root/lib/*.jar
            </classpath>

            <mainComponentDesc>
              <!-- PEAR file main component descriptor -->
            </mainComponentDesc>

            <componentId>
              <!-- PEAR file component ID -->
              ${project.artifactId}
            </componentId>

            <datapath>
              <!-- PEAR file UIMA datapath settings -->
              $main_root/
            </datapath>

          </configuration>
          <goals>
            <goal>package</goal>
          </goals>
        </execution>
      </executions>
    </plugin>

    <plugin>
      <artifactId>maven-antrun-plugin</artifactId>
      <executions>
        <!-- Clean the libraries after packaging -->
        <execution>
          <id>CleanLib</id>
          <phase>clean</phase>
          <configuration>
            <tasks>
              <delete quiet="false" failOnError="false">
                <fileset dir="${basedir}/lib" includes="**/*.jar" />
              </delete>
            </tasks>
          </configuration>
          <goals>
            <goal>run</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  </plugins>

答案 1 :(得分:0)

您可以从外部jar中提取已编译的类,并将它们打包到UIMA组件jar中。对于PEAR文件,您可能会发现类似的方法有效(解压缩梨,添加.class文件,重新打包)