Home > Back-end >  java.lang.NoClassDefFoundError: com/jcraft/jzlib/ZStream With Spring Boot Maven
java.lang.NoClassDefFoundError: com/jcraft/jzlib/ZStream With Spring Boot Maven

Time:08-24

JSch jsch = new JSch();  
session = jsch.getSession(variable1,variable2); 
session.setPassword(abcd);  
session.setConfig(config);  
session.connect();  
channel = session.openChannel("sftp");  
channel.connect();

I'm using this code with this POM dependency

<dependency>
    <groupId>com.jcraft</groupId>
    <artifactId>jsch</artifactId>
    <version>0.1.55</version>
    <scope>provided</scope>
</dependency>

I'm facing this error in the runtime environment:

java.lang.NoClassDefFoundError: com/jcraft/jzlib/ZStream

CodePudding user response:

The scope provided means, that the library will not be packed into your application. Remove the scope:

<dependency>
    <groupId>com.jcraft</groupId>
    <artifactId>jsch</artifactId>
    <version>0.1.55</version>
</dependency>

or put the jar into your runtime environment

CodePudding user response:

enter image description here

when I saw the source code of downloaded Jar in the Library didn't reach out this com/jcraft/jzlib/ZStream path then i'll find out another Maven Dependency of jcraft

    <dependency>
        <groupId>com.jcraft</groupId>
        <artifactId>jzlib</artifactId>
        <version>1.1.3</version>
    </dependency>

enter image description here

and they have the same classes which are missing in base dependency. Now its work for me.

  • Related