-1

This is the first time I am setting up a java project and I have almost understood the problem. I am facing bouncycastle not found issue while building the project with maven build. I need to extract a .war file out of it.

While running maven build - clean install I got :

[ERROR] /home/.../CrlServlet.java:[36,34] package org.bouncycastle.asn1.x509 does not exist
[ERROR] /home/.../CrlServlet.java:[37,29] package org.bouncycastle.cert does not exist
[ERROR] /home/.../CrlServlet.java:[38,29] package org.bouncycastle.cert does not exist
[ERROR] /home/.../CrlServlet.java:[39,29] package org.bouncycastle.cert does not exist
[ERROR] /home/.../CrlServlet.java:[40,36] package org.bouncycastle.cert.jcajce does not exist
[ERROR] /home/.../CrlServlet.java:[41,39] package org.bouncycastle.openssl.jcajce does not exist
[ERROR] /home/.../CrlServlet.java:[42,33] package org.bouncycastle.operator does not exist
[ERROR] /home/.../CrlServlet.java:[43,40] package org.bouncycastle.operator.jcajce does not exist
[ERROR] /home/.../LocalCertificateAdapter.java:[12,29] package org.bouncycastle.cert does not exist
[ERROR] /home/.../LocalCertificateAdapter.java:[13,36] package org.bouncycastle.cert.jcajce does not exist
[ERROR] /home/.../LocalCertificateAdapter.java:[14,32] package org.bouncycastle.openssl does not exist
[ERROR] /home/.../LocalCertificateAdapter.java:[15,39] package org.bouncycastle.openssl.jcajce does not exist

I checked my project documentation, there it's written - bcprov-jdkXXon-XXX.jar into the lib/ext.

I looked into the openjdk path in my ubuntu machine and there is no ext folder inside /usr/lib/jvm/java-11-openjdk-amd64/lib. I got one security folder tho.

Since I have openjdk java 11 version installed, I have a doubt as the project doc is old as per this.

openjdk version "11.0.15" 2022-04-19
OpenJDK Runtime Environment (build 11.0.15+10-Ubuntu-0ubuntu0.20.04.1)
OpenJDK 64-Bit Server VM (build 11.0.15+10-Ubuntu-0ubuntu0.20.04.1, mixed mode, sharing)

Also, when I am dockering the app ,I found extracted war is not working may be of this compilation failure. While checking the docker file it was bcprov-jdk15on-155.jar used.

So my question is :

  1. How to resolve this compilation failure ?
  2. Where I can download the exact version of bouncycastle jar file ?
  3. How and where I can put the jar library to make it work ? Do I need to downgrade the openjdk package to 7-8 ?

EDIT:- added pom file

<modelVersion>4.0.0</modelVersion>
    <groupId>serv.back</groupId>
    <artifactId>xxxx</artifactId>
    <version>0.1.6</version>
    <packaging>war</packaging>
    <name>xxxx</name>

    <dependencies>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.5</version>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.8.0</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>eclipselink</artifactId>
            <version>2.5.2</version>
        </dependency>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>9.4.1212.jre7</version>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.22</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>4.0.0-b01</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-dbcp</artifactId>
            <version>9.0.0.M15</version>
        </dependency>
        <dependency>
            <groupId>commons-digester</groupId>
            <artifactId>commons-digester</artifactId>
            <version>2.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.3</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpmime</artifactId>
            <version>4.5.3</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
            </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.5</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <sourceDirectory>src</sourceDirectory>
        <resources>
            <resource>
                <directory>src</directory>
                <excludes>
                    <exclude>**/*.java</exclude>
                </excludes>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                    <debug>true</debug>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.3.1</version>
                <configuration>
                    <warSourceDirectory>WebContent</warSourceDirectory>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>tomcat-maven-plugin</artifactId>
                <configuration>
                    <url>http://localhost:8080/manager/text</url>
                    <path>/xxxx</path>
                    <username>tomcat</username>
                    <password>xxxx</password>
                </configuration>
            </plugin>
        </plugins>
    </build>
NoobCoder
  • 493
  • 8
  • 25

1 Answers1

2

It seems you don't have bouncy castle dependency in your pom.xml:

this is for java 1.8 onwards:

https://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk18on/1.71

There are other versions also in this mvnrepository, and there is possibility to manually download the jar as well.

Maybe you need to put this library to the path specified by your project requirements -as you mentioned this lib/ext, but I don't know your project requirements so it is just my gues.

Krzysztof Cichocki
  • 6,294
  • 1
  • 16
  • 32
  • I am sorry but I am new to java setup and I dont have idea how to put into the path specified. Also, I don't have lib/ext folder as from java 9 they have removed. So not sure how to add this on classpath. Do I need to downgrade the openjdk to 7 or 8 ? – NoobCoder Aug 01 '22 at 12:37
  • Which jdk do you use, from what i see it is java 11, correct? This library is for java 8 onwards, and you seemd to have for java 5. If it need to be in lib/ext and there is no such folder, then create it. maven has a "provided" scope, so you can use the api for compilation and provide the library on classpath for runtime yourself. – Krzysztof Cichocki Aug 01 '22 at 12:38
  • ok, so do I need to add the dependency in pom file ? or in the path folder ? As now after adding in pom as dependency , I am getting same errors – NoobCoder Aug 01 '22 at 12:54
  • what means "same errors", during compilation or during runtime? How do you determine if these are same? – Krzysztof Cichocki Aug 02 '22 at 12:02
  • Meaning I am getting 'does not exist' during compilation. – NoobCoder Aug 02 '22 at 13:54