Tuesday, December 28, 2004

Servlet Mini-Annoyance

Was just putting together a test servlet, and was trying to get some values from a form. Spent about 30 minutes trying to figure out what I was doing wrong; in the end, I was calling getAttribute() when I should have been calling getParameter(). I still don't know what attributes are; in my case, they're coming up empty (i.e. getAttributeNames() returns an empty enumeration). Ah well.

Monday, December 20, 2004

Moving NB Project to Eclipse

Having accomplished the task of getting my build.xml to work under NetBeans, I need to go the other way, and get the same thing working under Eclipse. So I copy the NB folder over, and try to create an Eclipse project from it.

First thing Eclipse does is try to create src/com/foo/Hello packages, and gives errors on all files. That's not what I want. I try to delete the files from the project. Whoops, that actually deletes the files. I copy them back over.

Let's try importing. Hmm. That complains that it's trying to import into the same place that it's importing from. Let's create a new project. Okay, that imports okay, but doesn't place the files into a ./src folder. Scrap that idea.

Let's copy the project from scratch again. Still gives me the src/com/foo/Hello packages. Maybe we can move things around. I create a ./src source folder. It warns me about the overlap, but then fixes the packages, and puts things where I want them. But there are compile errors. Ah, just things missing from the classpath. Fixed that, and life is good. I can run my JUnit tests, and I can run build.xml.

Much easier going from NB to Eclipse than vice versa, for this particular test, at least.

Friday, December 17, 2004

First Look at NetBeans 4.0 Final Release

Back to NetBeans. I have a project with a custom Ant script that I want to get working under NetBeans. I do the New/FreeForm Project thing, and get to the part that asks for the source folder. I specify 'com/foo/hello', and it loads both .java and .class files (at present, I leave both in the same place, which is probably bad practice, but works fine under Eclipse, and Ant doesn't mind either). Loading both seems bad, so I delete the .class files, then open a source file. It marks an 'implements' line as being an error, even though the interface I'm implementing is in the same package (and same directory). Something's wrong; I remove the project.

2nd attempt: specify the top-level path as the source folder. This time, no source files show up, and I can't find anywhere to add or import an existing file. It won't let me add the existing package, (which makes sense, as it already exists, but I was hoping it'd see it and use it, or something). I remove the project.

3rd attempt: RTFM. The docs say to specify the top part of the path, which in this case is './com'. Huh? How counterintuitive is that?! Okay, I'll play along. I figure I'll come back to the classpath thing, and just click Finish. Nothing happens. Ah, on the status bar it's giving me an error message: "java.lang.reflect.InvocationTargetException". Cancel, try again, same thing. Restart, it won't even go past the project location page. Restart, try again, now it works. Odd.

Well, sort of works, as the project list shows a 'com' folder, with 'foo.hello' and 'foo.hello.client'; I would have expected to see 'com.foo.hello' under the project name ("HelloWorld", in this case). I expand 'foo.hello', and see both my .java files and my .class files. Also not what I expected; maybe under the Files tab, but not on the Project tab. I delete the .class files.

Then I run the build, (i.e. run the 'main' target of my build.xml, which builds the whole thing). It complains about not finding the 'cc' task; it's in a jar in ~/.ant/lib. Ant from the cmdline finds it fine, but this is okay. Adding the jar to my project classpath does nothing; ah, it wants it under the additional classpath under Options/Ant Settings. Makes sense. The project compiles, and deploys. Of course, the .class files are back as part of my project. Hrm.

Sidebar: In trying to add cpptasks.jar to the Ant buildpath, NB's "Add JAR File" dialog didn't pick up my ~/.ant dir, making me type it in by hand. And not just ".ant" and hit Enter, either, as that closes the dialog; I had to navigate to "~" and type ".ant/lib/cpptasks.jar". Kind of defeats the purpose of having a dialog.

Next odd thing: Hover over a .java filename under the Project tab, and it says 'Invalid package declaration: "com.foo.hello"'. Probably because it's separated 'com' and 'foo.hello' as two separate things. Probably wants me to have a ./src dir, and com/foo/hello under that. Let's see ... okay, that project gives me a ./src dir, with com.foo.hello and .client packages underneath. Grr. Making me do things your way isn't very friendly.

So I need to alter build.xml to get at my source in ./src. Fixed my javac task, so now things compile okay. Fixed my javah task, but now javah gives java.lang.reflect.InvocationTargetException. Well, actually it also said it couldn't find my class; silly me, I pointed it at ./src, while it wanted ./build. So why on earth does it say "Error starting javah", when javah started fine, but just couldn't find the classfile?!

Okay, now my build.xml runs fine. Interestingly, an empty build (i.e. I just ran it, so there's nothing to do) runs in 2 seconds under NB and 6 seconds from the command line. I guess NB is using the existing JVM. Repeated clean builds take 6-10 seconds in NB, while cmdline takes 15-16 seconds. (Of course, Eclipse recompiles .java behind the scenes, which is what I usually want to build...)

Bottom line is that I got NB to work, but I'm barely whelmed. The next task will be to work in it for a few days and see if it grows on me. My boss is attracted to it, and we both would like to make an informed decision about it, or at least verify that one project can be developed by folks split between IDE's.

.desktop Files and KMenuEdit

In an attempt to properly evaluate the IDE that we'll be using, I pulled down the final release of NetBeans 4.0, and installed it. I then went to load it, which in my case meant going to the KDE menu (on my SuSE box). I found the menu item for NetBeans, but assumed that it was still pointing to my old install, 4.0b2.

So I went to SuSE's Control Center, and tried to remember where they put the config tool for changing the menu. It's hidden under the 2nd or 3rd tab under Panels (which only makes sense if you really strain hard; in this area, Windows has it nice, just right-click on the menu item to edit it). Anyway, I then click the Edit K Menu button, which brings up KMenuEdit.

Only KMenuEdit doesn't show any entries under Development/IDE, which is where I have both NetBeans and Eclipse. Both show up on the KMenu, but neither do under KMenuEdit. I search the KDE bug database, and it appears that this is a SuSE bug, already fixed in a later version. (Mighty nice to be able to search a product's bug database.)

So where does KDE store this info? Apparently in .desktop files. I found netbeans.desktop in /usr/share/applications, updated to reflect the newly installed app. I'm guessing that the installer took care of that, pleasantly enough. The Eclipse one, that I added manually, was in ~/.local/share/applications/Eclipse.desktop.

So, it turned out that I needn't have gone to this trouble, but I figured I'd post this in case others have this difficulty, or are new to KDE and are curious.

Thursday, December 16, 2004

ssh Without a Password

Okay, I have access to another box. I can ssh into it, but it requires a password, so I copy id_dsa.pub to server, put it in a .ssh dir, rename it to authorized_keys, but ssh still requires password; ssh -vvv says:

debug1: Offering public key: /home/djaquay/.ssh/id_dsa

debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply

then a delay, then:

debug1: Authentications that can continue: publickey,gssapi-with-mic,password

debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password

I'm not sure what that "debug2: we did not send a packet" means, especially as the earlier debug2 says "we sent", (past tense). I've verified the authorized_keys in ~/.ssh, and it looks fine. I vaguely remember something like this happening a while back, but don't recall how i solved it (should have blogged it then; will blog it now).

I changed sshd_config on host to only use protocol 2, and uncommented the 'PubkeyAuthentication yes' and 'AuthorizedKeysFile .ssh/authorized_keys' lines, to no avail.

Odd thing: doing '/etc/init.d/sshd restart' doesn't drop my current connection; ah, it forks the process for each connection, so it restarts the main process, making new connections off the restarted one. I drop my own connection after doing each restart.

Talked to my network guy after suspecting that my box didn't have a proper name or DNS entry; he fixed that, and now there's no delay before being asked for my password.

Finally broke down and Googled for that "we did not send a packet" message, and voila (as they say in France), up turned a message on the SecurityFocus forum saying that my .ssh directory and authorized_keys file must both not be group or world writeable; both were, and once fixed, no password was required.


This post talks about using System.setOut() to change where System.out sends its output. Useful, as the article mentions, when you don't really want everything going to stdout.

Bootchart and Visualization

From Slashdot recently comes this article on Linux boot performance visualization. In addition to being somewhat interested in boot time optimization, I was quite intrigued by the images that bootchart puts out.

I'm fascinated by the power of visualization, especially as it relates (or possibly might relate) to coding. From simple stuff like editors that collapse method bodies to the use of UML and beyond, it's something that I just have this gut feel could really be powerful in comprehending a system and making informed, meaningful changes to it.

(OTOH, I could also just be fascinated by small, shiny objects...)

Friday, December 10, 2004

Eclipse and the Mouse Scroll Wheel

In getting back accustomed to using Eclipse, I was playing around with the mouse wheel. Seems that when I scroll with it, the page moves by half of the page height, which is counter to how just about every other app uses the scroll wheel. I Googled for a solution, but found none, and went to the Eclipse IRC channel on Freenode and got an answer.

Seems that Eclipse on Linux uses GTK+, and the version of GTK+ I have (2.2.4) is what's making Eclipse do that. Apparently it's not something that Eclipse controls, and that has been fixed in more recent versions of GTK+. Oh well, guess I won't be using the scroll wheel for now.

Loads of Fun

Well, I've been busy, and haven't posted as things have been going fairly swimmingly. So let's see, what have I done?

I got a test servlet and test JSP page running under Tomcat, and a simple object coded, using Eclipse. (Eclipse is way cool, BTW. More on that later.)

I got Spring's MVC running and forwarding a request to that JSP as a view. Spring is way cool as well.

I also got Spring to expose that simple object via SOAP, using Axis. One little oddity there: I had setup Spring to handle requests to Axis under a ./axis path; Axis puts a default page at that location with links to request the WSDL files, but the links assume that you're running under a ./services path. I tried them out first thing, and they broke, leading me to think something more serious was wrong. I switched my web.xml servlet-mapping to put the Axis servlet under ./services, and all was well.

I then got an object talking to PostgreSQL via their JDBC drivers. Actually, jdbc.postgres.org was down, but I managed to get fairly current drivers from someone off of the IRC channel on Freenode.

Lastly, I got some data objects coded up for my sample database, using JNI to make calls into a company-internal library that we have. It's been a while since I've done any C coding, but it brought back some mostly-good memories. (Although I'm not giving up Java to go back, that's for sure.)

Friday, December 03, 2004

khubd in "uninterruptible sleep"

Curious thing. My load average is hovering around 1.0, but nothing is taking up any CPU time. Makes sense, sort of, as the load average is (I believe) the average number of processes active, and not a measure of CPU usage. So I look at top, and see that no processes are in run state.

But there is one, khubd, that's in D state. The top manual reports that this is "uninterruptable sleep". I Google (of course) for khubd, and find that it's a kernel thread, and a suggestion that removing usbcore will kill it. Curiously enough, I'm not able to automount my USB MP3 player (it worked on my old machine, last week, but not on this one). Probably not a coincidence.

So I go to unload usbcore. usbcore is used by three other modules: usb_storage, usbserial, and uhci_hcd. I remove usbserial; no problem. I rmmod uhci_hcd, and now I have two processes in D mode, the new one being rmmod. Can't kill or kill -9 rmmod; the kernel is serious about the uninterruptible thing. Hrm. Time to reboot?

Bounced my machine, khubd came back, but is now in S mode, or just sleeping. I suppose the next thing to try is plugging in my MP3 player again, and see if that's what wedged khubd.

Thursday, December 02, 2004

Moving up to Firefox

I've been using Mozilla for a while now. Probably since version 1.1, IIRC. I've been interested in Firefox since it was announced, but not interested enough to give it a try. Well, coming into a new job, I decided to try it out. Peer pressure, and all that.

I love it.

I had been thinking all along that it really wouldn't be that much of a change from Mozilla, but I was wrong. It's got much nicer fonts, for starters. Much easier on the eyes.

The search bar is really cool; Ctrl-K takes you to a search field that defaults to searching Google, but has several other search engines as well, including Amazon and eBay. And you can add more. There are hundreds (!) of search engine plugins that you can get from Mozilla.org. I added Wikipedia and SourceForge; you can get CDDB or IMDB, Creative Commons, and a huge number of specialty sites. Nifty.

It's a small download, too. Less than 5MB. It does this by not having many of the standard plugins like Flash and Shockwave, but it makes getting them a snap, if you want to. (I don't. At least not yet.)

Of course, it still has tabbed browsing and popup blocking, but now popups are blocked by default, which is nice. The preferences are leaner as well, and better organized. Much more like OS X than Windows. (Mr. Bill hasn't innovated his way back up to Apple yet, apparently.)

Finding on the page is really neat; Ctrl-F opens an unobtrusive little find bar at the bottom of the page, which stays there until you close it by pressing Esc. Beats the Ctrl-F, type-a-term, Cancel, Ctrl-G dance I used to do.

Anyway, Firefox is a really nice browser, and really worth the trivial amount of time it took to install it. I can really see why all of the early adopters have been switched to this for months, and why IE is losing percentage points so fast. Way, way cool.