Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Installing JCOSap on spring project using maven

I want to use SAP JCO library in my spring project to connect with sap-gateway-system for pull/push document using JCo IDoc function.

I have below configuration in my pom.xml file for SAP JCO lib, And also i want to run some test case on it.

<!-- JCO dependencies -->
<dependency>
  <groupId>com.sap.conn.jco</groupId>
  <artifactId>sapjco3</artifactId>
  <version>${sapjco3.version}</version>
</dependency>
<dependency>
    <groupId>${idoc.group.id}</groupId>
    <artifactId>${idoc.artifact.id}</artifactId>
</dependency>

The library ends up being called sapjco3-3.0.jar
My platform is Windows OS.
When i try to run the spring project in my local, I am getting the below error :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

JCo initialization failed with java.lang.ExceptionInInitializerError: Illegal JCo archive
"sapjco3-3.0.jar". It is not allowed to rename or repackage the
original archive "sapjco3.jar".

>Solution :

One possible solution for this problem was for me to rename the dependency with the maven-dependency-plugin. For the tests I removed the original maven dependency from classpath and added the renamed (now sapjco3.jar) to the classpath again.

Step-1 : My local configuration is looks like this in pom.xml:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
  <!-- Add the native JCO libraries to the class path -->
  <classpathDependencyExcludes>
    <classpathDependencyExcludes>${jco.group.id}:${jco.artifact.id}</classpathDependencyExcludes>
  </classpathDependencyExcludes>
  <additionalClasspathElements>
    <additionalClasspathElement>${project.build.directory}/dependency/sapjco3.jar</additionalClasspathElement>
  </additionalClasspathElements>
</configuration>

Step-2 : Add Jco libraries in build classpath as below :
enter image description here

Step-3 : If you have Jco maven dependency com.sap present in pom.xml then please remove it, because application will read JCO lib from build classpath.

Step-3 : Also if sapjco3-3.0.jar & sapidoc3-3.0.jar present in your maven-dependencies then please remove both jars from there as well and then try to run your project.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading