I am using Apache Wicket with Apache Commons Net. But when I define
new FTPClient(); //apache commons net library
I get an exception
org.apache.commons.net.ftp.FTPClient at.erpel.as2connector.testtool.protocols.FTP.client
[class=org.apache.commons.net.ftp.FTPClient] <----- field that is not serializable
What can I do?
Thank you for your suggestions!
I also have solved it with 2 possibilites:
1) you can make the field transient:
transient FTPClient() client;
2) Make a Singleton of parent class where FTPClient will be used
public class AnyClass implements Serializable {
private static AnyClass instance;
private AnyClass() {
}
public static AnyClass getInstance() {
if (instance == null) {
instance = new AnyClass();
}
return instance;
}
FTPClient client = new FTPClient();
...
}
3) As suggested by biziclop: Create an own Class only for FTP Communication.