HI Chris,

thanks for your response, and I'll update the code as you suggest.
However, I actually have problems even when the -onLogin function is
empty, returns nil, or returns FtpletResult/DEFAULT. It seems it
causes trouble once it's defined.

I'll post an update tomorrow

Raphaël

On Mar 10, 6:50 pm, chris <cnuern...@gmail.com> wrote:
> I can see one possible difference, depending on how you are loading
> the code into the ftp server.
>
> In your clojure example you are accessing the logger through a top-
> level define.  I believe this will run *during the file loading
> process* as static code.
>
> In your working java example, you aren't accessing the logger until
> the actual onLogin function is called.
>
> If the logger is in an odd state (like null) or god forbid the runtime
> sets up the logger just before it calls into your function then you
> may get different results.  I would recommend calling the getlogger
> call in the function perhaps; change the 'def logger' to 'defn logger
> []' and work out the resulting details.  This would make the clojure
> example a little closer to your java example and at least eliminate
> one possible problem.
>
> Chris
>
> On Mar 10, 7:35 am, rb <raphi...@gmail.com> wrote:
>
> > Hi,
>
> > I'm experimenting withhttp://mina.apache.org/ftpserver
> > I have written a small java class that gets used by the ftp server,
> > and am trying to transpose it to clojure, but unsuccessfully until
> > now....
>
> > The class generated with clojure is detected and used by the server,
> > but the code of the method implemented is not run, and even worse, the
> > ftp server isn't functional anymore (though I don't see any exception
> > raised).
>
> > Does anyone have an idea about what I'm doing wrong?
>
> > Thanks
>
> > Raphaël
>
> > Here's the java code:
>
> > package com.raphinou;
>
> > import java.io.IOException;
> > import org.apache.ftpserver.*;
> > import org.apache.ftpserver.ftplet.*;
>
> > public class Ftplet extends DefaultFtplet {
> >     public FtpletResult onLogin(FtpSession session, FtpRequest
> > request)
> >             throws FtpException, IOException {
> >         java.util.logging.Logger logger=
> > java.util.logging.Logger.getLogger("com.raphinou");
> >         logger.addHandler( new java.util.logging.FileHandler("/tmp/
> > ftp.log"));
> >         logger.severe("Logging in!!");
> >         return FtpletResult.DEFAULT;
> >     }
>
> > }
>
> > and here's the clojure code:
>
> >  (ns com.raphinou.ftplet
> >   (:gen-class :name com.raphinou.Ftplet
> >    :extends org.apache.ftpserver.ftplet.DefaultFtplet)
> >   (:import [org.apache.ftpserver.ftplet DefaultFtpReply
> > FtpletResult]))
>
> > (def logger (java.util.logging.Logger/getLogger "com.raphinou"))
> > (.addHandler logger (java.util.logging.FileHandler. "/tmp/ftp.log"))
>
> > (defn -onLogin [session request]
> >   (.severe logger "Logging in, clj")
> >   FtpletResult/DEFAULT)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to