title: Apache Mina and JSch can't set home dir
body: <p>I'm trying to write a unit test using Apache Mina and JSch and I'm hitting a problem that I'm sure has to do with the way I've set up the filesystem on Mina.</p>
  
  <p>Here is <strong>the Mina setup code:</strong></p>
  
  <pre><code>sshd = SshServer.setUpDefaultServer();
  sshd.setPort(8002);
  
  sshd.setFileSystemFactory(new NativeFileSystemFactory() {
    @Override
    public void setCreateHome(boolean createHome)
    {
      super.setCreateHome(true);
    }
    @Override
    public FileSystemView createFileSystemView(final Session session) {
  
      String userName = session.getUsername();
      // create home if does not exist
      String homeDirStr = "/home/testusr";                    
      File homeDir = new File(homeDirStr);
  
      if ((!homeDir.exists()) &amp;&amp; (!homeDir.mkdirs())) {
        System.out.println("Cannot create user home :: " + homeDirStr);
      }
  
      return new NativeFileSystemView(session.getUsername(), false) {
        @Override
        public String getVirtualUserDir() {        
          return "/home/testusr";        
        }
      };
    };
  });
  
  sshd.setSubsystemFactories(Arrays.&lt;NamedFactory&lt;Command&gt;&gt;asList(new SftpSubsystem.Factory()));
  sshd.setCommandFactory(new ScpCommandFactory());
  sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider("hostkey.ser"));
  List&lt;NamedFactory&lt;UserAuth&gt;&gt; userAuthFactories = new ArrayList&lt;NamedFactory&lt;UserAuth&gt;&gt;();
      userAuthFactories.add(new UserAuthNone.Factory());
      sshd.setUserAuthFactories(userAuthFactories);
  sshd.setPublickeyAuthenticator(new PublickeyAuthenticator() {
      public boolean authenticate(String username, PublicKey key, ServerSession session) {
             return true;
         }
  });
  sshd.start();
  </code></pre>
  
  <p><strong>JSch code:</strong></p>
  
  <pre><code>JSch jsch = new JSch();
  
  String appPublicKey = "c:\\conf\\test_private";
  jsch.addIdentity(new File(appPublicKey).getAbsolutePath());
  
  com.jcraft.jsch.Session session = jsch.getSession("testusr","localhost", 8002);
  session.setConfig("StrictHostKeyChecking", "no");
  session.setTimeout(30000);
  session.connect();
  Channel channel = session.openChannel("sftp");
  channel.connect();
  ChannelSftp sftpChannel = (ChannelSftp) channel;
  
  String filename = "c:\\temp\\test.tar.gz";
  File f = new File(filename);
  sftpChannel.put(new FileInputStream(f), "/home/testusr");
  </code></pre>
  
  <p><strong>Exception:</strong></p>
  
  <pre><code>    4: 
      at com.jcraft.jsch.ChannelSftp.getHome(ChannelSftp.java:2403)
      at com.jcraft.jsch.ChannelSftp.getCwd(ChannelSftp.java:2412)
      at com.jcraft.jsch.ChannelSftp.remoteAbsolutePath(ChannelSftp.java:2904)
      at com.jcraft.jsch.ChannelSftp.put(ChannelSftp.java:517)
      at com.jcraft.jsch.ChannelSftp.put(ChannelSftp.java:492)
      at com.SftpServiceTest.sendFile(SftpServiceTest.java:183)
      at com.SftpServiceTest.main(SftpServiceTest.java:218)
  Caused by: java.io.IOException: inputstream is closed
      at com.jcraft.jsch.ChannelSftp.fill(ChannelSftp.java:2871)
      at com.jcraft.jsch.ChannelSftp.header(ChannelSftp.java:2895)
      at com.jcraft.jsch.ChannelSftp._realpath(ChannelSftp.java:2315)
      at com.jcraft.jsch.ChannelSftp.getHome(ChannelSftp.java:2397)
      ... 6 more
  </code></pre>
  
  <p>I can't seem to find any good examples of creating a FileSystemView.  Hoping someone can help me out, I've been stuck on this for days! </p>
  
  <p>Thanks in advance.</p>