tag:blogger.com,1999:blog-89557552024-03-07T10:57:41.442-05:00Dave's Code BlogWhat I'm coding for fun.Davehttp://www.blogger.com/profile/08701649145513988342noreply@blogger.comBlogger98125tag:blogger.com,1999:blog-8955755.post-78845037354885440732012-05-11T15:05:00.000-04:002012-05-11T15:05:27.777-04:00SOAP/WSDL WranglingWent looking for how to do client-side SOAP in Java, given a WSDL file. Found a couple of tutorials on how to create the server side; not what I wanted. Down at the end, they mentioned "oh yeah, to test the server, write a client, and here's how to do that in Netbeans". We don't use Netbeans. Grrr.<br />
<br />
Back to StackOverflow. Found mention of wsimport. Hey, I've already got that installed. Apparently, wsimport is part of JAX-WS, and Glassfish is the reference implementation. So how do I use it? Finally <a href="http://jax-ws.java.net/jax-ws-ea3/docs/UsersGuide.html">found docs</a> for using wsimport to generate client-side stub classes, and sample client code to call it.<br />
<br />
Initially, I thought running wsimport was as simple as <code>wsimport foo.wsdl</code>; doing that creates classfiles under the current directory. <code>jar cf foo.jar com</code> packs those up in a jar (minus the manifest; is that a problem?). Add that jar to your project, and start writing Java code with them.<br />
<br />
It seems a typical JAX-WS pattern is to instantiate a Service class, and use it to get a Port class. From there, calls from the client to the server involve calling methods on the Port class, i.e.:
<br />
<br />
<pre>FreightRateService svc = new FreightRateService();
FreightRatePortType port = svc.getFreightRatePort();
FreightRateResponse frResp = port.processFreightRate( frReq, upsSec );
</pre>
<br />
In this example, the frReq and upsSec objects are instantiated from other classes in the generated jars, that are used to pass data from the client to the server. frResp can then be examined for return data. It's actually not much more complicated than that.<br />
<br />
<b>Except!</b><br />
<br />
Except, when you run wsimport on a local WSDL, the generated class files contain an absolute path to your WSDL file in them. Not sure why the class files aren't enough, but apparently the WSDL is also needed at runtime. Apparently there are a few different ways to go about getting the WSDL file loaded:<br />
<ol>
<li>Make sure the absolute path is correct and sufficient. This might be the case if you're building the WSDL jar on the same box that you're deploying on.
</li>
<li>Use wsimport's -wsdllocation parameter. This might work if you can put the WSDL file in the same place on all boxes (i.e. development and production) that you intend to run the system on. In my case, I develop on Linux and deploy to Windows, so no dice.</li>
<li>Use wsimport's -wsdllocation and -catalog parameter. Never got this to work, but saw <a href="http://stackoverflow.com/questions/4163586/jax-ws-client-whats-the-correct-path-to-access-the-local-wsdl">a StackOverflow post</a> that mentioned it, that was quite highly voted up.</li>
<li>Pass in a URL to the Service constructor, with your own path. This is what I settled on for Suzuki (see UPSRating.java), as it lets us put the file wherever we want, and (in theory) put the location into a properties file. You also need to pass in a QName (whatever that is), which I copied verbatim from the generated Service source file (i.e. FreightRateService.java); looks like it points to the WSDL's xsd or dtd or somesuch, maybe.</li>
</ol>
One last thing to mention, that I never solved. While working on options 2 and 3 up there, I tried just specifying a bare filename, i.e.<code>-wsdllocation FreightRate.wsdl</code>. On my Linux box, running under Eclipse, it was looking for the WSDL in my home directory, and when the file wasn't there, it said so with a nice, clear error message. Something like <i>FileNotFoundException: /home/djaquay/FreightRate.wsdl</i>. Polite. Then I deployed it to Windows, thinking/hoping that it'd tell me in like fashion where it was looking for the WSDL. But there, I got the following:<br />
<br />
<pre>No wsdl metadata with the Service, cant create proxy! Try creating Service by providing a WSDL URL
</pre>
<br />
And Google, for once, wasn't my friend. No matches at all, outside of one lone forum post asking, essentially, WTF?, and getting no real answer. So if anybody knows what's up with that error, leave a comment. I ran out of time to get stuff working, and went with option 4, but I'd still like to know what that error is about.<br />
<br />
So yeah, SOAP is nice in theory, and a hassle in practice. Have fun.<br />
<br />Davehttp://www.blogger.com/profile/08701649145513988342noreply@blogger.com0tag:blogger.com,1999:blog-8955755.post-7779989095742519252012-03-05T13:33:00.000-05:002012-03-05T13:33:20.990-05:00GDB BasicsNot gonna try to do a GDB tutorial, but rather just post what I learned in trying to debug a C program that I had to modify. Some simple stuff:<br />
<br />
<b>break <line|method></b> - set breakpoint at the start of that method<br />
<b>bt</b> - print stack trace at current point<br />
<b>p <var></b> - print (contents of) variable<br />
<b>l(ist) [nn]</b> - print code around current point, or around line nn<br />
<b>run</b> - start running program<br />
<b>c</b> - continue (running freely)<br />
<b>n</b> - next, step over<br />
<b>s</b> - step into<br />
<b>quit</b> - go home, all done<br />
<br />
That'll get you pretty far, but the code I was modifying was using fork() to daemonize itself, and gdb was quitting as the initial process quit. So I used:<br />
<br />
<b>set follow-fork-mode <parent|child></b><br />
<br />
to get it to debug the child. Except, the child was forking as well, and I went the wrong way into that child. So I did the following:<br />
<br />
1: set follow-fork-mode child<br />
2: break forkChildProcesses<br />
3: run<br />
4: set follow-fork-mode parent<br />
5: break 520<br />
6: c<br />
<br />
(1) set the follow mode, (2) set a breakpoint in the daemon, (3) ran to that breakpoint, (4) set the follow mode back, so I would stay in the daemon and not go into the daemon's children, (5) set a new breakpoint at line 520, where I thought the problem started, and (6) continued execution.<br />
<br />
And yeah, <b>run</b> starts the program running, while <b>c</b> continues it. Got confused the first time I tried to <b>run</b> a program I'd already started, and it tried to confirm that I wanted to restart. Oops.Davehttp://www.blogger.com/profile/08701649145513988342noreply@blogger.com0tag:blogger.com,1999:blog-8955755.post-49583740198529585582011-07-05T18:09:00.000-04:002011-07-05T18:09:21.802-04:00HP Laptop Headphone FixLove my HP Pavilion DV6 laptop, and love Ubuntu running on it, but found an issue with my headphone, that plugging into the jack didn't turn off the speakers. Did some poking around, and found that adding:<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">options snd-hda-intel model=hp-dv5</span><br />
<br />
to my <i>/etc/modprobe.d/alsa-base.conf</i> took care of it. There are other values for model that can solve issues with other machines. For reference, <i>lspci</i> reports:<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">00:1b.0 Audio device: Intel Corporation 5 Series/3400 Series Chipset High Definition Audio (rev 05)</span><br />
<br />
for my audio card, and <i>cat /proc/asound/card0/codec* | grep Codec</i> reports:<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">Codec: IDT 92HD75B3X5</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">Codec: Intel IbexPeak HDMI</span><br />
<br />
for my codec(s).Davehttp://www.blogger.com/profile/08701649145513988342noreply@blogger.com0tag:blogger.com,1999:blog-8955755.post-20578209927656555412010-11-23T15:53:00.002-05:002010-11-23T15:56:15.419-05:00SQL Server 2000 notesA place for stuff that I don't want to forget. (There's stuff I only do with it once a year, and I'm perpetually looking this stuff back up.)<br /><br />1) bcp.exe will let you dump a table at a time to a CSV file. DTS absolutely sucks for the same task, as it's a stinkin' wizard, that doesn't remember what you did last time, etc., etc., blah blah freakin' blah. You can at least script bcp with a .bat file, and have a record of what you did, for next time.Davehttp://www.blogger.com/profile/08701649145513988342noreply@blogger.com0tag:blogger.com,1999:blog-8955755.post-19012586920831929022010-11-18T13:12:00.002-05:002010-12-03T09:06:00.881-05:00Ubuntu 10.10 Upgrade<span style="font-weight: bold;">SpongeBob (my laptop): 10.04 -> 10.10</span><br /><br />Done, no issues yet, love the new font.<br /><br /><span style="font-weight: bold;">Patrick (downstairs desktop): 9.10 -> 10.04 -> 10.10</span><br /><br />9.10 to 10.4 went smoothly.<br /><br />10.4 to 10.10 wouldn't bring up X. Poked around on forums, found "no screens found" message in /var/log/Xorg.0.log, moved xorg.conf out of /etc/X11, did "restart gdm" and it worked. Rebooted, and it worked.<br /><br /><span style="font-weight: bold;">MrCrabs (Son's laptop): 9.10 -> 10.04 -> 10.10</span><br /><br />Done, no issues yet.<br /><br /><span style="font-weight: bold;">(work laptop): 10.04 -> 10.10</span><br /><br />Screen started working again, wireless works on reboot (both were problems with 10.04). alsamixer still doesn't retail settings over a reboot (which it hasn't done since at least 9.10, maybe 9.04).<br /><br />New problems:<br /><br />1) Audio cuts out in just a few minutes of use.<br /><br />2) CPU usage is up. Looking at top, appears to be processes called kslowd000 and kslowd001. Googled them, and apparently they're kernel daemons used for background processing (so as not to interfere with main CPU processing?). Looking further, this might be related to my GPU, as others with kslowd issues were also using an Intel 855GM.<br /><br />Decided to reboot; didn't fix #2. Decided to boot into 2.6.32-25 (was running 2.6.35, which is apparently when the kslowd problems started, at least for Ted T'so on the kernel mailing list). Not only did kslowd stop showing up in top, but now problem #1, with the audit, seems to be fixed as well (quite possibly unrelated to #2, except by differing code between the two kernels).<br /><br />So, for now, will stay in 2.6.32, as it's nice to not need to schlep MP3's over to my phone to listen to music at work. Will try out 2.6.36 when it comes down the pipe, probably.<br /><br />Update: went up to 2.6.35-23-generic, and it seems to have improved both issues. Will keep this updated, but for now, I'm back up to 2.6.35.<br /><br />Another update: while my audio and CPU usage issues were better, laptop was locked up with a blank screen for the past two mornings when I came into work. So I'm back to 2.6.32 for now.<br /><br /><span style="font-weight: bold;">(work desktop): 10.04 -> 10.10</span><br /><br />Done, no issues yet. Well, except for that odd thing with my 2nd HD coming up randomly as /dev/sda and /dev/sdc. Fixed it by putting the drive's UUID in /etc/fstab.Davehttp://www.blogger.com/profile/08701649145513988342noreply@blogger.com0tag:blogger.com,1999:blog-8955755.post-52515048242593059612010-08-20T08:00:00.001-04:002010-11-18T16:58:02.852-05:00Bind for LoggingTalked to Rob and Nate, and both agree that to log internal web requests, setting up my own bind is the easy way to go, then set the router to set all internal machines to it via static dns on dhcp.<br /><br />Installing was a snap (straight out of Synaptic), and it just worked, right out of the box. Logging wasn't turned on, but that took 5 mins. Don't need logrotate, as bind9 logging has that built in. Manually, I wrote a cut/sort/uniq/grep script, but I didn't have mail installed, (or the brainpower left at end of day), so the script will have to wait briefly.<br /><br />I set the router's static DNS to this box, and by this morning, was getting requests from the XBox and Wii, as well as Wife's Macbook.<br /><br />I added an entry to my crontab to generate the filtered list, putting it into ~/bin (for no real good reason). Given the size of it, I'll probably generate it nightly, but only mail it out weekly, and just poke around with adding things to the grep filter.<br /><br />Installed first mailutils, then exim4, then mutt, then finally sendemail until the latter let me send email from the command line simply, without configuring an MTA. Configuring an MTA just isn't something I have the brainpower for tonight. Anyway, my ISP doesn't require authentication from within their network, so sendemail worked like a charm, after bzipping the file down, (apparently they have a size limit, or something?)<br /><br />So crontab is setup to mail the log out weekly, and we'll see how it goes.Davehttp://www.blogger.com/profile/08701649145513988342noreply@blogger.com0tag:blogger.com,1999:blog-8955755.post-51538214281496163082010-08-19T08:00:00.002-04:002010-11-23T15:49:37.981-05:00Kicking Ivy out of EclipseTo make Ivy-less operation easier, I:<br /><ul><li>Removed all of the jars from my development project in Eclipse<br /></li><li>Created a directory (outside of the project)<br /></li><li>Made symbolic links from that directory to my common jar path (i.e. "ln -s /usr/share/java/spring.jar ~/dist/project", etc.)<br /></li><li>Added all of the jars to my Eclipse project in one operation (by clicking Add External JARs and highlighting all of the jars in that dir)<br /></li><li>Scripted the creation of the symlinks, and added the script to SVN.<br /></li></ul>It might also be worth looking into how SVN handles symbolic links, which could make it feasible to add the symlinks into the projects as well.Davehttp://www.blogger.com/profile/08701649145513988342noreply@blogger.com0tag:blogger.com,1999:blog-8955755.post-5611469032883974562010-08-18T16:22:00.001-04:002010-11-18T16:24:05.036-05:00Fixing a hosed GRUB<br /><br />Full details (and years of old fixes) at: <a href="http://ubuntuforums.org/archive/index.php/t-24113.html">http://ubuntuforums.org/archive/index.php/t-24113.html</a><br /><br />Ubuntu Karmic:<br /><br />make changes to partitions locations below<br />boot from cd/usb/network/yomomma<br />open terminal<br /><br />type:<br /><br />sudo mkdir /mnt/fixboot<br />sudo mount -t ext4 /dev/sda5 /mnt/fixboot<br />sudo mount -t proc non /mnt/fixboot/proc<br />sudo mount -o bind /dev /mnt/fixboot/dev<br />sudo chroot /mnt/fixboot /bin/bash<br />sudo grub-install /dev/sda<br />sudo update-grub<br />sudo umount /mnt/fixboot/dev<br />sudo umount /mnt/fixboot/proc<br />sudo umount /mnt/fixboot<br />reboot<br />:D<br /><br />The first time around, it didn't find Windows, but after booting Ubuntu, ran update-grub, and it picked it up fine.Davehttp://www.blogger.com/profile/08701649145513988342noreply@blogger.com0tag:blogger.com,1999:blog-8955755.post-65848844752135689672010-08-17T08:00:00.001-04:002010-11-18T16:19:39.486-05:00Rsync NotesCouldn't get rsync to work. Message was "connection refused", among other things. Realized that rsyncd wasn't running on other box. Realized that RSYNC_ENABLE in /etc/default/rsync wasn't set. Set that.<br /><br />It then complained about a missing /etc/rsyncd.conf file. Did a locate for it, and found a sample one in /usr/share/doc/rsync/examples. Copied that into place, and tried again. rsyncd would start, and rsync on the other box then connected to it, but complained about a missing module (I think). So I copied lines that looked interesting out of the sample ("ftp") module, and created "home", which is what my old original command was looking for.<br /><br />That got me to a point where it would connect to the module, but was unable to read any of the files. Seems I added uid/gid lines, but left them set to nobody/nogroup, which didn't work so well. Changed them to my user/group, and things worked fine.<br /><br />Update: Nate suggests using ssh public keys and rsync -auv, instead of the rsync daemon.Davehttp://www.blogger.com/profile/08701649145513988342noreply@blogger.com0tag:blogger.com,1999:blog-8955755.post-90981883906717029212010-08-16T08:00:00.000-04:002010-11-18T13:11:10.904-05:00Dia HasslesUpgraded Ubuntu to 9.10, and Dia got upgraded to 0.97. This update included a change to the file format for associations elements, (which breaks tedia2sql.pl, which is fully unsupported/orphaned at this point), and apparently changed the default font, which skewed all of our diagrams.<br /><br />So I removed 0.97, and pulled down the 0.96 .debs from packages.ubuntu.com, and installed them, but then Ubuntu kept asking to upgrade them, since it saw 0.97 out there in Karmic. So, taking a page from my angel upgrade, I edited /var/lib/dpkg/status, and removed the three 0.96 dia entries from that, and now I have 0.96 installed, but Synaptic doesn't know about it, and doesn't ask to upgrade it. Hackish, but it appears to work.Davehttp://www.blogger.com/profile/08701649145513988342noreply@blogger.com0tag:blogger.com,1999:blog-8955755.post-49588041850288384812009-12-30T10:41:00.005-05:002010-11-23T15:50:02.312-05:00Java and IBM 6400 Line FeedsI've got a client with several IBM 6400 line printers, and I started out printing to them with code that looks like this:<br /><br /><span style="font-family:courier new;">buf.append( stuff );</span><br /><span style="font-family:courier new;">buf.append( "\n" );</span><br /><br />So far, so good, until I print to a 2nd printer, which in some places double-spaces the printout, and in others, just gives line feeds. So I ask them to send me a printout of the printer config, and it shows that the printer is in Proprinter Emulation mode, which has an AUTO LF setting that is enabled. Okay, so I'm thinking I should be just sending carriage returns, and let it generate the line feeds.<br /><br />No good. For whatever reason, when I just:<br /><br /><span style="font-family:courier new;">buf.append( stuff );</span><br /><span style="font-family:courier new;">buf.append( "\r" );</span><br /><br />to send just the CR, nothing comes out. Just to say I've tried all the combinations, I change the code to:<br /><br /><span style="font-family:courier new;">buf.append( stuff );</span><br /><span style="font-family:courier new;">buf.append( "\r\n" );</span><br /><br />expecting to get rid of my just-line-feed issue, but also expecting the whole report to be double-spaced, and to my surprise, it works.<br /><br />My guess is that Java was doing something with the line-end characters, doing me a favor when I didn't want it to, and being explicit with \r\n turned that off? I don't know. And because both printers are some distance away from my office, I didn't bother to get the folks at the 1st printer to send me their config, so I'm still guessing that they have emulation set to something with AUTO LF disabled. Maybe next time I'm out there, I'll check...<br /><br />(Oh, and yeah, looks like I just managed to squeak in my one post to this blog for the year. I've been making tech notes in Google Wave recently, so when that comes out of preview mode and integrates w/Blogger publicly, I should be reviving this blog somewhat...)Davehttp://www.blogger.com/profile/08701649145513988342noreply@blogger.com0tag:blogger.com,1999:blog-8955755.post-30630017008592839382008-10-20T22:13:00.002-04:002008-10-20T22:17:39.070-04:00CPOSC '08Went yesterday to CPOSC, the Central Pennsylvania Open Source Conference. There were three talks going on at any one time, and I attended talks on: Asterisk, Blender, Android, Drupal, MozDev, jQuery and O/S project participation. All were at least good, and most were very good. I was already planning to get into JS/jQuery, and Asterisk, and now I'm thinking about Android as well (although I'm apparently one of the few attendees not standing in line for a TMobile G1).<br /><br />Anyway, it was a day well spent, and I can't wait for CPOSC '09!Davehttp://www.blogger.com/profile/08701649145513988342noreply@blogger.com0tag:blogger.com,1999:blog-8955755.post-63688919524370018182008-09-13T08:49:00.004-04:002008-09-13T10:17:57.528-04:00JavascriptOkay, every now and then I get to be embarrassed. Many years ago (probably around 2001), I looked into Javascript, and only saw that it was a toy language, inconsistent between browsers (there were only two back then) and not worth learning. (IIRC, I fell in love with Python shortly thereafter.)<br /><br />In my defense, a) there were only two browsers back then :), and b) JS was quite inconsistent between them (and possibly still is). But I've spent a few hours recently looking at JS again, and I'm seeing that it <span style="font-weight: bold;">*IS*</span> a real language, every bit as much as Python. And with add-ons like Firebug that provide a debugger and great visibility to what's going on in the browser, and jsUnit to provide unit testing for JS code, it's a full-fledged programming environment.<br /><br />And while at work, we've done quite a bit with JS that's centered on AJAX and UI, we've more recently put together some prototype stuff that's looking a lot more like a full fledged application, which looks quite interesting, and as I dive in, I may well get to be involved in that.<br /><br />Yup, I'm thinking it's time to shed some of my JS misconceptions, and join in the fun!Davehttp://www.blogger.com/profile/08701649145513988342noreply@blogger.com0tag:blogger.com,1999:blog-8955755.post-85726107306368623632008-09-01T14:30:00.009-04:002008-09-01T16:03:24.506-04:00DWL-520 Wireless WoesGot a new machine that I'm trying to setup for MythTV. Decided to put a wireless NIC into it, and ran into install problems. Followed the directions at:<br /><br />https://help.ubuntu.com/community/WifiDocs/Device/DWL-520vE1<br /><br />then continued the process with the directions at:<br /><br />http://ubuntuforums.org/showthread.php?t=643467<br />http://ubuntuforums.org/showthread.php?t=606861<br /><br />and still didn't succeed. Figured I'd better make a note of it, in case I ever care to try again.Davehttp://www.blogger.com/profile/08701649145513988342noreply@blogger.com0tag:blogger.com,1999:blog-8955755.post-91187100481419693012008-06-27T12:55:00.002-04:002010-11-23T15:50:51.684-05:00Java WoesYes, I'm thinking back this day to the good old days of programming. Back to my C++ days. Back when, if a piece of code that you called didn't exist or wasn't available, it gave a nice, sensible link error and refused to create your executable.<br /><br />Yes, I'm in an "I hate Java" moment.<br /><br />We need to connect to a DB2 database. This particular database insists on encrypted connections, and because it's an IBM database, (and because they can, I suppose), DB2 insists on having client apps use THEIR encryption algorithms. Which either means using their Java runtime entirely, or messing with the /etc/java/security/java.security file in my Sun JRE install. Yup, red flags are waving, buzzers are going off. Danger, Will Robinson, danger!<br /><br />So I replace the entries in java.security with IBM's classes. At this point, everything Java on my box stops working, complaining about not finding SHA-1 and/or MD5. I mean, Eclipse won't save my source files, for crying out loud. So I put the Sun stuff back, and add the IBM stuff at the end. A sample command line program that connects to DB2 now works (as does Eclipse, once again), but the same code in Tomcat 5.5 doesn't work. Gives error of "Prime size must be multiple of 64, and can only range from 512 to 1024".<br /><br />After poking around a good bit further, it finally dawns on my boss, who was also troubleshooting this, that not only do we need to specify the classes in java.security, but we also need to make 6 new jarfiles available on the classpath for Tomcat (and presumably every other Java app that uses that runtime).<br /><br />Which brings me back to my pining for the good old days. The days when, if I forgot a library, I got a message saying "Dude, you forgot a library", not something completely orthogonal like the above "Prime size ..." hooey.<br /><br />I'm gonna go do something that makes sense, like C++. Grrrr...Davehttp://www.blogger.com/profile/08701649145513988342noreply@blogger.com0tag:blogger.com,1999:blog-8955755.post-68324733876440641482008-06-26T16:02:00.002-04:002010-11-23T15:51:06.827-05:00Hardy Heron and My BCM4306It seems like every iteration of Ubuntu breaks my wireless, and every iteration requires something new to fix it. This iteration (Hardy Heron) requires the steps that can be found <a href="http://ubuntuforums.org/showthread.php?t=766560&highlight=bcm4306">in this post on the Ubuntu Forums</a>. I hate that it breaks; I love it that the forums (almost) always have the answer waiting for me when I get there.Davehttp://www.blogger.com/profile/08701649145513988342noreply@blogger.com0tag:blogger.com,1999:blog-8955755.post-72151133055919284982008-02-12T13:32:00.000-05:002008-02-12T13:50:17.688-05:00Secure Wireless ProxyAfter reading a <a href="http://lifehacker.com/software/ssh/geek-to-live--encrypt-your-web-browsing-session-with-an-ssh-socks-proxy-237227.php">Lifehacker post</a> a while back on more secure wireless browsing, I decided to setup an <a href="http://ubuntu.wordpress.com/2006/12/08/ssh-tunnel-socks-proxy-forwarding-secure-browsing/">SSH Tunnel + SOCKS Proxy</a> for Firefox, including (optionally) using <a href="http://foxyproxy.mozdev.org/">FoxyProxy</a> to make things easier.<br /><br />The short of it is:<br /><ul><li>Use <span style="font-style: italic;">"ssh -D 9999 user@server"</span> to establish a connection to a remote server.</li><li>Use FoxyProxy to point to a SOCKS proxy on localhost.</li></ul>The long of it is that the "-D" option causes ssh to setup a proxy server on your local box that redirects your browser requests to the remote box, then from the remote box out to the 'net. All of your wireless http transmissions will be encrypted and hence unreadable by sneaky folks in the airport (or Panera's, or Starbucks, or wherever), and your browsing will be as secure as if you were sitting on the remote box. (Not that that's secure by default, but it's at least not being broadcast all over your surroundings.)<br /><br />Using FoxyProxy in this case simply makes it easier to switch back and forth between proxied and direct connections if you need to. FoxyProxy sits on the bottom toolbar in Firefox, and with a couple of clicks will let you switch between proxy setups (including a "no proxy" setup, if desired).Davehttp://www.blogger.com/profile/08701649145513988342noreply@blogger.com0tag:blogger.com,1999:blog-8955755.post-13073124998779356442007-08-10T14:53:00.001-04:002010-11-23T15:51:19.660-05:00SQL Server Timestamp FieldIt's been so long since I've had a decent Microsoft rant, I guess it must just be time. A while back, in a SQL Server database (don't laugh, the client insisted), I needed to have a timestamp for when a row is created. Silly me, I actually looked through the data type list, saw "timestamp", and thought, "Hey, that must be a timestamp!". Yeah, silly me.<br /><br />The timestamp type? It isn't even a usable type. It gets set whenever the row gets updated, is binary data, and has nothing to do with dates or times. What I really wanted was a Datetime field with a default value of getdate(). Not a timestamp.<br /><br />I'm so glad that the REST of my coding life, I get to be in Postgres. In Ubuntu. On Linux. Away from Microsoft. Harumph!Davehttp://www.blogger.com/profile/08701649145513988342noreply@blogger.com0tag:blogger.com,1999:blog-8955755.post-57941352472006672882007-08-02T16:10:00.001-04:002007-08-02T16:10:41.655-04:00A Minor Rails Hiccup, With SolutionAs mentioned, I've been working through Agile Web Development With Rails, 2E. I got to p. 88, which talks about adding data via a migration. So I download the data for 003_add_test_data.rb, and run rake on it. Nothing. All of my rows get deleted, but no new ones get added. I add some print lines, which get displayed when rake runs, so I know the code is getting executed. But no data gets added. Harumph!<br /><br />Well, let's back up a bit. A few pages prior, I added validation to the model. Pretty cool stuff, being able to throw in some regular expressions and have a pretty error message show up on the page. So I did a little extra-curricular playing around, and life was good.<br /><br />After looking around a bit, I discovered that the data that the book wants me to add wasn't passing my validation tests. Okay, fine. So why wasn't rake showing any of the validation exceptions?<br /><br />Well, a quick post to the Rails forum later, it turns out that create() won't throw exceptions, it just adds entries into the 'errors' list and continues. create!() will throw an exception with the same error text that the Rails app shows, and stops the migration. Problem solved.Davehttp://www.blogger.com/profile/08701649145513988342noreply@blogger.com0tag:blogger.com,1999:blog-8955755.post-29116849829022572982007-07-21T15:10:00.000-04:002010-11-23T15:48:35.606-05:00Getting Rails Running on UbuntuTime to check out the Rails hype. I borrowed Agile Web Development With Rails, 2nd Edition, from a coworker, and have started working my way through it. So far, so fun. The details:<br /><br />I'm doing this under Ubuntu, so I figured I'd install via Synaptic. I grabbed just about everything I thought I might need, and started through the book. I got to p. 39, which has a couple of rake commands. These commands failed, and as part of troubleshooting, found https://help.ubuntu.com/community/RubyOnRails. Following its advice, I removed rails and gems from Synaptic, and ran #1, #2 "Install RubyGems via source (recommended)", then #3 and #4. I then tried the commands again, and they worked just fine.<br /><br />Well, almost fine. When I got around to running <i>gem update --system</i>, I got the following:<br /><br /><pre><br />Updating RubyGems...<br />Bulk updating Gem source index for: http://gems.rubyforge.org<br />Attempting remote update of rubygems-update<br />ERROR: While executing gem ... (Gem::GemNotFoundException)<br /> Could not find rubygems-update (> 0) in any repository<br /></pre><br /><br />On a lark, I ran the same command again, and it ran just fine. Go figure.<br /><br />I then generated my own rails api docs with the <i>rake doc:rails</i> command, and was able to proceed.<br /><br />So far, so fun.Davehttp://www.blogger.com/profile/08701649145513988342noreply@blogger.com0tag:blogger.com,1999:blog-8955755.post-19220199869620858032007-07-13T10:28:00.000-04:002010-11-23T15:51:27.586-05:00Feisty + Tomcat5.5 HowToI got the following off of the Ubuntu Forums, and include it here so I know where it is, for next time. (Yes, there's always a next time.) In particular, #2 solved my present issue of not being able to restart Tomcat via the /etc/init.d/ script.<br /><br />Thanks to <i>Emblem Parade</i> for this:<br /><br />Argh. So, if you tried installing tomcat5.5 from the repositories, you may have noticed that it's broken. You get a configuration error about JAVA_HOME not being set. Actually, there are three problems! Here's what you can do to get it to work:<br /><br />1) Install<br /><br /><code>sudo aptitude install sun-java6-jdk tomcat5.5</code><br /><br />(Note that you absolutely need the JDK, not just the JRE.)<br /><br />2) Set Tomcat's default JAVA_HOME<br /><br /><code>sudo gedit /etc/default/tomcat5.5</code><br /><br />Uncomment the JAVA_HOME line and set it to your JDK path. For Java 6 installed from the repositories, it's as so:<br /><br /><code>JAVA_HOME=/usr/lib/jvm/java-6-sun</code><br /><br />3) Fix catalina.out<br /><br />Unfortunately, it seems that Tomcat's log file is set to be a pipe, but Tomcat can't seem to start with it. We'll recreate it as a regular file with the same security settings:<br /><br /><pre><br />cd /var/log/tomcat5.5/<br />sudo rm catalina.out<br />sudo touch catalina.out<br />sudo chown tomcat55:nogroup catalina.out<br />sudo chmod uo-wrx catalina.out<br /></pre><br /><br />Tomcat should work now as a daemon. Start it like this:<br /><br /><code>sudo /etc/init.d/tomcat5.5 start</code><br /><br />And point your browser at http://localhost:8180/<br /><br />Hooray!Davehttp://www.blogger.com/profile/08701649145513988342noreply@blogger.com0tag:blogger.com,1999:blog-8955755.post-61871825255998217572007-07-11T11:31:00.000-04:002010-11-23T15:51:27.586-05:00Been Running UbuntuSince Novell drank the Microsoft Kool-Aid, we've been replacing our SuSE servers and desktops here at work with Ubuntu. Overall, it's been a very pleasant experience. I got Ubuntu 6.10 Edgy running on my work laptop and desktop, and on my home desktop as well. I then upgraded all three to 7.04 Feisty with no problems on any box except my 64-bit desktop, and that seemed to only be a problem with some X fonts. <br /><br />I then had the hard drive crash on my home desktop, so I reinstalled 6.10 and immediately upgraded it to 7.04. (I was too lazy to download the 7.04 install CD.)<br /><br />The only minor annoyance I had with upgrading to 7.04 the first time was that I clicked Go and went to sleep, only to find the next morning that it had stopped awaiting confirmation to something about 10 minutes in. The 2nd 6.10->7.04 upgrade didn't do that, so I'm guessing it was from something that I had installed. But if you're upgrading, you might want to babysit it, and not assume it can run unattended. (YMMV.)<br /><br />Comparing Ubuntu with all other distros I've used (Gentoo, SuSE, Red Hat, and Slackware way back when), this is very sweet. I had been limping along with wireless on my laptop under SuSE. Under 6.10, I followed some info from the forums, and it just worked. (Admittedly, 7.04 has seen a minor step backwards in wireless, but it still works, and I just haven't taken the time to ask/troubleshoot it yet.)<br /><br />Synaptic is much nicer than Yast. Not sure how to explain it, but it's just a much more comfortable experience. Gnome is also very nice. I was expecting to try to figure out how to get back to fluxbox, but after a few hotkey tweaks, I'm enjoying Gnome pretty well, and prefer it over KDE, which I used briefly when I installed SuSE.<br /><br />Bottom line on Ubuntu: I wouldn't go back. Much nicer experience than I was having with SuSE.Davehttp://www.blogger.com/profile/08701649145513988342noreply@blogger.com0tag:blogger.com,1999:blog-8955755.post-1155748989917961582006-08-16T13:21:00.000-04:002010-11-23T15:51:45.025-05:00Background Threads in TomcatI have a task that I want to run once a minute. I have it coded as a command-line app, but getting that app to run as a Windows service is getting to be a pain. And, we also have an instance of Tomcat running on that server, so I started looking at how to get it to run within Tomcat.<br /><br />This made me a bit nervous at first, as Tomcat does a lot of threaded stuff on its own, and I'd really rather not step on its toes, but after a bit of searching, I found that kicking off your own threads is a fine thing to do in Tomcat, but with a couple of caveats.<br /><br />First, Tomcat lets apps ("contexts" in Tomcat lingo) be hotswapped, i.e. restarted or removed and replaced with new code, without stopping the VM. This means that you need to wire up your thread to stop when the app (sorry, "context") is stopped. You can write a servlet to watch over your thread (that can actually be the thread itself, too), and have Tomcat instantiate it, by configuring it in web.xml with "<load-on-startup />" included.<br /><br />The servlet itself will extend HttpServlet (of course), and implement Runnable (if it's to have the thread code in it as well, which is handy. Then, when the destroy() method is called on your servlet, you tell your thread to stop itself (i.e. via a call to Thread.interrupt(), perhaps), as the context is going away.<br /><br />I found a code sample at <a href="http://classes.eclab.byu.edu/462/demos/PrimeSearcher.java">http://classes.eclab.byu.edu/462/demos/PrimeSearcher.java</a> that helped, although that sample is coded to call Thread.stop(), which is now deprecated.<br /><br />Anyway, I now have simple thread doing background processing, nicely cooperating with Tomcat.Davehttp://www.blogger.com/profile/08701649145513988342noreply@blogger.com2tag:blogger.com,1999:blog-8955755.post-1155575845261459232006-08-14T13:16:00.000-04:002010-11-23T15:52:49.154-05:00SQL Server Default Values (or "Why Open Source Is (Still) Better")In getting our Java app to run on Windows, I'm forced to use SQL Server as a database. (Against my will, I might add.) I have an external application that will be adding rows to a table via ODBC, and I'm thinking it'd be nice to have SQL Server automatically generate a date value for when the row was written. In PostgreSQL, it'd be a default value in the DDL (I think; I've never needed it yet), but I wasn't sure what it'd be in SQL Server, so I tried timestamp.<br /><br />That didn't look right to me, as the value in Enterprise Mangler displayed as '<binary>', rather than the actual date. Okay, let's try datetime with a default value. Well, that complained about something odd. I googled and found that timestamp *is* what I want, display problems notwithstanding.<br /><br />Which leads me to today's punchline: when I switched from datetime w/default to timestamp, and tried to save my changes, EM complained about a default value not being appropriate for that datatype. Why, on earth, did EM not clear the default value when I switched datatypes?!<br /><br />Okay, maybe I'm reading too much into this, but this is a problem you just don't see in open source programs. In the O/S world, the first decent coder to hit that problem would have pulled down the source, fixed the problem, and submitted a patch. The next version of the program would be fixed, perhaps in less than a month, depending on the release cycle. Heck, I was itching to do it, myself, except, whaddya know, I can't get at the code.<br /><br />But I'll wager that this problem will never get fixed. It's not "important enough" (i.e. to the marketing team) to make it into a bug list, unless it annoys a SQL Server developer enough to make it happen "while he's doing other things" (i.e. without permission).<br /><br />Harumph. When will I be free of this nonsense?Davehttp://www.blogger.com/profile/08701649145513988342noreply@blogger.com2tag:blogger.com,1999:blog-8955755.post-1155326297150024842006-08-11T15:56:00.000-04:002006-08-11T15:58:17.160-04:00Windows Services and Network DrivesRather than turn this into a Windows rant (which it easily could become), I'll just skip to the punchline. After a few hours of trying to figure out why my File.exists() and File.isDirectory() calls don't work, now that I've moved the code into Tomcat, running as a service on Windows 2003 Server, I discovered that network drives are not available to services.<br /><br />More specifically, I got the impression that network drives are mapped by a user for that user, and as such, a service, which doesn't have a user (?), doesn't get the drives that any (other) user specifies. More generally, it's another way that Windows is borken. (Oops, I wasn't going to rant.)<br /><br />So I got to go back to my client and get him to move the app (whose data I was getting over their net) to the local machine, or figure out how to at least push the files to the local machine. Feh. (rant, rant, rant...)Davehttp://www.blogger.com/profile/08701649145513988342noreply@blogger.com0