Common knowledge in Java

A few notes, observations that I would like to document about Java. This may be common,trivial knowledge, but I just want it to be in one place.

Thursday, July 14, 2005 ParserInitializationException

We use the jakarta/apache (don't know what they call it these days) commons net jar as our ftp client and this seems to be failing with a TANDEM ftp box. Looks like someone else was running into the same error at about the same time.
This is the error I was running into:
Error initializing parser at
createFileEntryParser( at
initiateListParsing( at at at

After taking a look at the commons code, here's what I figured out, the TANDEM box was returning
an empty string on a FTP SYST command. Our good people at commons don't handle a null, assuming
the FTPClient.getSystemName() always returns something. So here's my hack to get around it.

if(null == ftpClient.getSystemName()) {
//use parserKey,pathName method signature
ftpFileArray = ftpClient.listFiles("UNIX",(String)null);
} else {
ftpFileArray = ftpClient.listFiles();

Thursday, June 30, 2005

MySQL: access denied for user: (Using password: YES)

More experimenting with struts. So I got ambitious, downloaded MySQL and tried to wire a database into my simple struts app. Setting up MySQL was a breeze, although it was my first time, except that some time was wasted googling for user account creation etc.
So, I set up a datasource in Tomcat, which could be looked up by JNDI. I added this in server.xml.
But was getting errors with Context.lookup, indicating there was no "java:comp/env/jdbc" in the Context. Realized I forgot to add the resource-ref in my web descriptor.
This done, I was getting a different error.
Access denied for user 'blah': (Using password: YES).
What the ..., I didn't set the password as YES, what the heck was going on?
So googled again (one of these days, when someone asks me what tools, IDE I use for development, I will be sure to add 'Google' in there, in fact this should come integrated with the IDE, any Exception or Error message should be linked to Google search), anyway I digress.
So this seems to be a common problem. I tweak the user account a bit in MySQL, apparently the host shouldn't be set as '%', you are better off setting it to 'localhost'. I also deleted the default user account '', which is an empty string. So either of these fixed it for me and I am on my way.

Wednesday, June 29, 2005

Gripe about the parameter attribute in Struts action config

My gripe about this generic attribute called 'parameter' in the struts action config.
So I have something like:
<action path="/logonProcess"

Now someone pray tell me what this 'parameter' is supposed to do.
I looked up on the Apache site and it says:
"action general purpose configuration parameter".
Alright, but what is that supposed to mean. Well it means different things to different action type classes, if it is a ForwardAction it can be the url you want the action to be forwarded to. For DispatchAction it is the key to the different method values. Someone ought to document this, instead of making you run in circles, dammit. But that is what they say about struts, very little documentation. What do I know, anyway.