0

The below behavior occurs when i call the getSftpUtil(). I have also ensured that all the appropriate jars are in the maven project's external libraries and are available in the WEB-INF/lib folder of the project

code

net.sf.opensftp.SftpUtil util = SftpUtilFactory.getSftpUtil();

stacktrace

SftpUtilFactory: Trying to get SftpUtil class name from the system property net.sf.opensftp.SftpUtil
SftpUtilFactory  - Trying to get SftpUtil class name from the system property net.sf.opensftp.SftpUtil
SftpUtilFactory: The system property net.sf.opensftp.SftpUtil is not set.
SftpUtilFactory  - The system property net.sf.opensftp.SftpUtil is not set.
SftpUtilFactory: Use the default one.
SftpUtilFactory  - Use the default one.

Caused by: java.lang.NoSuchMethodError: com.jcraft.jsch.JSch.setLogger(Lcom/jcraft/jsch/Logger;)V
at net.sf.opensftp.impl.SftpUtil.<clinit>(SftpUtil.java:110)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at net.sf.opensftp.SftpUtilFactory.getSftpUtil(SftpUtilFactory.java:184)
bouncingHippo
  • 5,940
  • 21
  • 67
  • 107
  • The () is the method name for the class initialisation called the first time the class is used. It calls the static { } blocks and static initialisation. – AllTooSir Jun 13 '13 at 18:16
  • @TheNewIdiot how is the related to `jcraft` error, and how should i fix it? – bouncingHippo Jun 13 '13 at 18:35

2 Answers2

0

Well, I guess you are missing this dependency or the proper version:

<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.49</version> <!--latest version -->
darijan
  • 9,725
  • 25
  • 38
0

Based on jcraft's change log, setLogger is a method added to JSch.java in jsch-0.1.30. So the jar under your WEB-INF/lib should be an older version.

You can run

mvn dependency:tree

to see which of your dependencies is using the older version, and then exclude it with something like this:

<dependency>
    <groupId>...</groupId>
    <artifactId>...</artifactId>
    <version>...</version>
    <exclusions>
        <exclusion>
            <groupId>com.jcraft</groupId>
            <artifactId>jsch</artifactId>
        </exclusion>
    </exclusions>
</dependency>

You probably have another dependency refer to a more recent version of jsch, so your problem should be solved at this point. However, if that's not the case, you can add this to pom.xml:

<dependency>
    <groupId>com.jcraft</groupId>
    <artifactId>jsch</artifactId>
    <version>0.1.50</version>
</dependency>
su-
  • 3,116
  • 3
  • 32
  • 42
  • its odd, as none of my dependencies are using an older version. Currently the latest is `0.1.47`. What's more odd is that this piece of code worked perfectly the last time. And when i changed workspace, this error came up – bouncingHippo Jun 13 '13 at 19:01
  • 1
    You must have an older version somewhere, that's what java.lang.NoSuchMethodError usually indicates. It could be from your app server, server cache, or something else. I don't have enough information to help you find out. Good luck anyway. – su- Jun 13 '13 at 19:07