带有Maven的SapJco 3.0.11:不允许重命名或重新打包原始存档"sapjco3.jar". [英] SapJco 3.0.11 with Maven: It is not allowed to rename or repackage the original archive "sapjco3.jar"

查看:1257
本文介绍了带有Maven的SapJco 3.0.11:不允许重命名或重新打包原始存档"sapjco3.jar".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

sap jco连接器的当前版本在运行时强制执行包含jar的名称.如果名称不匹配(sapjco3.jar),将导致异常.

The current version of the sap jco connector enforces the name of the containing jar at runtime. This will lead to exceptions, if it doesn't match the name (sapjco3.jar).

JCo初始化失败,并出现java.lang.ExceptionInInitializerError:非法JCo 存档"sap-jco-win-amd-64-3.0.11.jar".不允许重命名或重新打包原始存档"sapjco3.jar"

JCo initialization fails with java.lang.ExceptionInInitializerError: Illegal JCo archive "sap-jco-win-amd-64-3.0.11.jar". It is not allowed to rename or repackage the original archive "sapjco3.jar"

我们包装了这些库,并使用自定义pom将它们部署在我们的nexus存储库中.由于这种更改/标准的maven命名方式,标准的maven构建是无法使用的atm.

We wrapped these libraries and deployed them with a custom pom in our nexus repository. The standard maven build is unusable atm, as a result of this change/the standard maven way of naming artifacts.

当前解决方法将系统范围用于此依赖项,并将sapjco maven工件复制到项目内的指定文件夹中,因为这是强制执行jar文件名称并将其作为依赖项保留在构建中的唯一方法.这在同一模块中起作用.系统范围的缺点之一是传递伪像的停用/失败解析.我们将需要它,因为sap连接器模块包含在应用程序战争模块中.由于打包的工件中不包含系统范围的依赖项,因此我们必须将它们复制到web-inf/lib文件夹,然后将一个类路径条目添加到清单中.

The current workaround uses system scope for this dependency and copies the sapjco maven artifact to a specified folder within the project, as this is the only way to enforce the name of an jar file and also keep it in the build as a dependency. This works within the same module. One of the disadvantages of the system scope is the deactivated/failing resolution of transitive artifacts. We would need that, as the sap connector module is included in an application war module. As system scope dependencies aren't included in the packaged artifacts, we had to copy them to the web-inf/lib folder and add a classpath entry to the manifest.

当我从父/根模块启动构建时,该构建工作正常,但由于系统范围的依赖性,在子模块中启动该构建时,构建失败.我们现在可以使用该解决方案,但是我对此绝对不满意.

The build works, when i start it from the parent/root module, but fails when it is started in submodules due to the system scope dependency. We could live with that solution for now, but i'm definitely not happy with it.

是否有推荐的方法将sapjco与maven结合使用,或更简单的方法来生成依赖于平台的工件,包括本地库和具有指定名称的jar? SAP是否正在重新考虑此检查,因为以前的版本未包含该检查?

Is there a recommended way to use sapjco with maven or a simpler approach to produce platform dependent artifacts, which include the native library and the jar with a specified name? Is SAP reconsidering this check, as the previous versions did not include it?

推荐答案

我遇到了同样的问题,下面是我如何解决它(总之解决): 1.在命令提示符下运行命令

I had the same issue, and below is how I fixed it (in short work around it): 1. Run the command in command prompt

mvn install:install-file 
-Dfile=sapjco3.jar 
-DgroupId=com.company.sap 
-DartifactId=com.sap.conn.jco.sapjco 
-Dversion=1.0 
-Dpackaging=jar

  1. 这将创建一个本地工件,或者您也可以在远程存储库中创建它
  2. 从maven下载此依赖项,如下所示:

  1. This will create a local artifact, or you can also create it in remote repository
  2. Download this dependency from maven as shown below:

<dependency> <groupId>com.company.sap</groupId> <artifactId>com.sap.conn.jco.sapjco</artifactId> <version>1.0</version> </dependency>

<dependency> <groupId>com.company.sap</groupId> <artifactId>com.sap.conn.jco.sapjco</artifactId> <version>1.0</version> </dependency>

此解决方法将避免sapjco3错误:

This work around would avoid the sapjco3 error:

if (!jarname.equals("sapjco3.jar") 
&& !jarname.startsWith("com.sap.conn.jco") 
&& !jarname.equals("sapjco3_IDE.jar") 
&& Package.getPackage("org.apache.maven.surefire.booter") == null 
&& Package.getPackage("org.eclipse.jdt.internal.junit.runner") == null) {
    throw new ExceptionInInitializerError("Illegal JCo archive \"" + jarname + "\". It is not allowed to rename or repackage the original archive \"" + "sapjco3.jar" + "\".");
}

这篇关于带有Maven的SapJco 3.0.11:不允许重命名或重新打包原始存档"sapjco3.jar".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆