1

Another update... After uploading the sapjco3.jar file into my local maven repository, I can successfully get my code to compile. After deploying this code to my linux tomcat server, I get an error something like "not allowed to rename jar file". Apparently this is a common problem with the sapjco3.jar file version 3.0.10 and above. Still looking for a solution to this.

Update... After adjusting the pom.xml file and changing the project compiler to java 1.8, I'm no longer getting the "bootstrap class path not set in conjunction with -source 1.6" error. However, I'm still getting "package com.sap.conn.jco does not exist" when compiling. Any other thoughts on what I need to do to get this jar file to show up when compiling?

Original message: I'm trying to get a Spring MVC application to compile using Maven in Spring Tool Suite, and I'm getting a 'bootstrap class path not set in conjunction with -source 1.6' error.

I'm using Spring Tool Suite 3.7.2 and I'm issuing Maven commands through the Spring Tool Suite content menus to do the clean, compile, install, and deploy commands (in other words, I'm not using Maven command line). The JRE System Library that is configured in the build path by default is JavaSE-1.6. I'm working with a Spring MVC framework application, and the java version in the pom.xml file is 1.6.

I've created a folder called 'lib' in the root of the project, and I've added a third party jar file (sapjco3.jar) to that folder. I've added that jar file to the build path of the project.

When I run the 'Maven compile' goal, I'm getting a compile error, and here is the top of the error:

[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] bootstrap class path not set in conjunction with -source 1.6
C:\Users\user\Documents\workspace-sts- 3.7.2.RELEASE\JCOTest\src\main\java\com\graybar\jcotest\query\SAPDAO.java: [10,23] error: package com.sap.conn.jco does not exist

In the classes of my project where I'm referencing the code in the sapjco3.jar file, they are showing up just fine, and my code works just fine locally. However, to get my code to run locally, I had to add the windows version of the sapjco3 driver, sapjco3.dll, to the c:\windows\system32 folder on my workstation.

I suspect that my problem has to do with the sapjco3 code not being seen when compiling. I've tried adding both the sapjco3.jar and sapjco3.dll files to my jdk 1.6 lib folder, and I've added the same files to the lib folder in the jre folder for jdk 1.6.

I've also tried switching out java 1.6 for java 1.8 with no success.

Am I on the right track here regarding the sapjco3.jar code not being seen during the compile process? My end goal here is to deploy this code to a linux based version of tomcat 1.8.

Here is my complete pom.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0    http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
<groupId>com.graybar</groupId>
<artifactId>jcotest</artifactId>
<name>JCOTest</name>
<packaging>war</packaging>
<version>1.0.0-BUILD-SNAPSHOT</version>
<properties>
    <java-version>1.8</java-version>
    <org.springframework-version>3.1.1.RELEASE</org.springframework-version>
    <org.aspectj-version>1.6.10</org.aspectj-version>
    <org.slf4j-version>1.6.6</org.slf4j-version>
</properties>
<dependencies>
    <!-- Spring -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${org.springframework-version}</version>
        <exclusions>
            <!-- Exclude Commons Logging in favor of SLF4j -->
            <exclusion>
                <groupId>commons-logging</groupId>
                <artifactId>commons-logging</artifactId>
             </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${org.springframework-version}</version>
    </dependency>

    <!-- AspectJ -->
    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjrt</artifactId>
        <version>${org.aspectj-version}</version>
    </dependency>   

    <!-- Logging -->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>${org.slf4j-version}</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>jcl-over-slf4j</artifactId>
        <version>${org.slf4j-version}</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>${org.slf4j-version}</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.15</version>
        <exclusions>
            <exclusion>
                <groupId>javax.mail</groupId>
                <artifactId>mail</artifactId>
            </exclusion>
            <exclusion>
                <groupId>javax.jms</groupId>
                <artifactId>jms</artifactId>
            </exclusion>
            <exclusion>
                <groupId>com.sun.jdmk</groupId>
                <artifactId>jmxtools</artifactId>
            </exclusion>
            <exclusion>
                <groupId>com.sun.jmx</groupId>
                <artifactId>jmxri</artifactId>
            </exclusion>
        </exclusions>
        <scope>runtime</scope>
    </dependency>

    <!-- @Inject -->
    <dependency>
        <groupId>javax.inject</groupId>
        <artifactId>javax.inject</artifactId>
        <version>1</version>
    </dependency>

    <!-- Servlet -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>

    <!-- Test -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.7</version>
        <scope>test</scope>
    </dependency>        

</dependencies>
<build>
    <plugins>
        <plugin>
            <artifactId>maven-eclipse-plugin</artifactId>
            <version>2.9</version>
            <configuration>
                <additionalProjectnatures>
                    <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
                </additionalProjectnatures>
                <additionalBuildcommands>
                    <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
                </additionalBuildcommands>
                <downloadSources>true</downloadSources>
                <downloadJavadocs>true</downloadJavadocs>
            </configuration>
        </plugin>
        <plugin> 
            <artifactId>maven-compiler-plugin</artifactId> 
            <version>3.1</version> 
            <configuration> 
            <source>1.8</source> 
            <target>1.8</target> 
            </configuration> 
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.2.1</version>
            <configuration>
                <mainClass>org.test.int1.Main</mainClass>
            </configuration>
        </plugin>
    </plugins>
</build>

Thanks!

-Stephen Spalding

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Stephen
  • 1,977
  • 2
  • 15
  • 19
  • You should set the jdk version 8 in windows -> preference -> java -> compiler – SMA Sep 12 '16 at 14:52
  • As per your suggestion, I've gone into Windows -> Preferences -> Java -> Compiler, and I've changed the 'Compiler compliance level' to 1.8. I've also updated the JRE System library to jdk 1.8, and I've also removed the other jdks from the Windows -> Preferences -> Java -> Installed JREs area. Unfortunately I'm still having the same problem. – Stephen Sep 12 '16 at 15:10
  • right click on your project -> properties -> java compiler, set jdk level to 1.8 – SMA Sep 12 '16 at 15:11
  • I've done that too. Unfortunately, no change. Still not compiling. – Stephen Sep 12 '16 at 15:20
  • I didnt read your output before. Its more to do with maven. Please add following plugin to your pom.xml ` maven-compiler-plugin 3.1 1.8 1.8 ` – SMA Sep 12 '16 at 15:28
  • I've replaced the maven-compiler-plugin tag with what you've suggested, and I'm still getting the same error. Something that I've tried that has helped is adding the sapjco3.jar file to my local maven repository and referencing it via my pom.xml file. The code does compile. The problem is that when I then deploy the code to my linux tomcat server, I'm now getting an error stating: '...It is not allowed to rename or repackage the original archive "sapjco3.jar"' – Stephen Sep 12 '16 at 15:46
  • Can you paste your pom.xml here. – SMA Sep 12 '16 at 15:47
  • Updated main message with full pom.xml file. BTW - I really appreciate the help today. – Stephen Sep 12 '16 at 15:53
  • Any more thoughts on what I need to do to get this working? Like I mentioned before, after adding the sapjco3.jar file to my local Maven repository, I can successfully compile the project. However, after deploying the application to my linux Tomcat server, it's erroring out with a message saying that I'm not allowed to rename the jar file. – Stephen Sep 13 '16 at 12:48

1 Answers1

0

You can use a custom project repository

<!– In Project repository –>
<repository>
    <id>in-project</id>
    <name>In Project Repo</name>
    <url>file://${project.basedir}/libs</url>
</repository>

and then call your jar

<dependency>
    <groupId>sapjco3</groupId>
    <artifactId>sapjco3</artifactId>
    <version>1.3.1</version>
</dependency>

another option is put the jar file in your .m2 folder, but is not a good practice. You can read this article how to add a custom jar in maven.

Other way is add the path of your jar on the dependency block:

<dependency>
    <groupId>sapjco3</groupId>
    <artifactId>com.sapjco3</artifactId>
    <version>1.0</version>
    <scope>system</scope>
    <systemPath>${project.basedir}/src/main/resources/sapjco3.jar</systemPath>
</dependency>

I hope it helps.

Diego Rojas
  • 237
  • 5
  • 11
  • Thanks Diego! I've tried your last suggestion of adding the path of the jar as a dependency. I added the sapjco3.jar file to the src/main/resources folder to accomodate. The trouble that I have now is that after deploying to my dev linux server, I'm getting 'HTTP Status 500 - Handler processing failed; nested exception is java.lang.NoClassDefFoundError: com/sap/conn/jco/AbapException'. Any thoughts? – Stephen Sep 14 '16 at 14:41
  • I assume that AbabException is a class from sapjco3.jar. Try to run a maven clean-install before export your war file, or export the war with their own resources. You have to be sure of all the libraries that you need are in your dev server too. – Diego Rojas Sep 14 '16 at 14:46
  • Yeah, I always do a clean before I compile, install, and redeploy to tomcat. I've copied the sapjco3.jar file to the /opt/tomcat/lib folder and restarted the server there. The application just isn't seeing it. When looking at the exploded folder on the dev tomcat server, I can see all of my dependencies in the WEB-INF/lib folder, but the sapjco3.jar file is not there. I'm wondering how to put it there without adding the version number. – Stephen Sep 14 '16 at 15:03