Как исправить исключение в потоке Java "main": java.lang.NoClassDefFoundError? - PullRequest
0 голосов
/ 15 октября 2018

Я пытаюсь создать файл jar с помощью maven. Я импортировал библиотеки из CA Pam для приложения, которое я разрабатываю.Однако всякий раз, когда я импортирую зависимости в maven, а затем упаковываю их в файл jar.Это дает мне эту ошибку

Исключение

Exception in thread "main" java.lang.NoClassDefFoundError:com/cloakware/cspm/cient/CSPMClient
            at Driver.main(Driver.java:12)
    Caused by: java.lang.ClassNotFoundException: com.cloakware.cspm.client.CSPMClient
            at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinCl
    ssLoader.java:582)
            at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(
    lassLoaders.java:190)
            at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
            ... 1 more

Java-код

import com.cloakware.cspm.client.CSPMClient;

public class Driver {

    public static void main(String[] args) {

        try {
            //initialize
            String targetAlias = "emc_grab";
            String bypassCache = "true";

            CSPMClient testInterface = new CSPMClient(targetAlias,true);


            //get the result
            String statusCode = testInterface.getStatusCode();
            String userId     = testInterface.getUserId();
            String password   = testInterface.getPassword();
            String xmlData    = testInterface.getXMLData();

            System.out.println("Status Code: " + statusCode);
            System.out.println("UsedId:      " + userId);
            System.out.println("Password:    " + password);
            System.out.println("XML Data:    " + xmlData);




            //set the return value
            if ( statusCode.equals("400") ) {
                System.out.println("PASSED");
                System.exit(0);
            } else {
                System.out.println("FAILED");
                System.exit(Integer.parseInt(statusCode));
            }

        } catch (Exception e) {
            e.printStackTrace();
            System.exit(100);
        }
    }

Переменные среды

PATH=C:\cspm\cloakware\cspmclient\lib

В настоящее время я использую Intellij, я потратил много дней на то, чтобы понять, почему он не работает.Также ниже находится мой файл pom.xml

Pom

<?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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.harriott</groupId>
    <artifactId>GrabTest</artifactId>
    <version>1.0</version>



    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>





    <build>
        <plugins>
            <plugin>
                <!-- Build an executable JAR -->
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <classpathPrefix>lib/</classpathPrefix>
                            <mainClass>Driver</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>



    <dependencies>


        <dependency>
            <groupId>com.cloakware.cspm.client</groupId>
            <artifactId>CommonLogging</artifactId>
            <version>1.00</version>

        </dependency>

        <dependency>
            <groupId>com.cloakware.cspm.client</groupId>
            <artifactId>CommonsNet</artifactId>
            <version>1.00</version>

        </dependency>

        <dependency>
            <groupId>com.cloakware.cspm.client</groupId>
            <artifactId>cwjcafips</artifactId>
            <version>1.00</version>

        </dependency>

        <dependency>
            <groupId>com.cloakware.cspm.client</groupId>
            <artifactId>cwjssefips</artifactId>
            <version>1.00</version>

        </dependency>

        <dependency>
            <groupId>com.cloakware.cspm.client</groupId>
            <artifactId>MortbayJetty</artifactId>
            <version>1.00</version>

        </dependency>

        <dependency>
            <groupId>com.cloakware.cspm.client</groupId>
            <artifactId>JavaxServlet</artifactId>
            <version>1.00</version>

        </dependency>

        <dependency>
            <groupId>com.cloakware.cspm.client</groupId>
            <artifactId>CSPMClient</artifactId>
            <version>1.00</version>

        </dependency>

    </dependencies>

</project>
...