Google search bar

December 18, 2009

Enable Classic Eclipse Update Capability

In eclipse galileo, go to window-->preferences.
In the preferences dialog, search for Capabilities.
In /General/Capabilities, check 'Classic Update'.
Restart and the classic update and plug-in management is available.

December 01, 2009

Hibernate's "User SQL Comments" feature causes a problem with DB2

I've been having a problem where a query sent through hibernate fails with the message: executeQuery method cannot be used for update

Here is an example of the log output. The hibernate actual hql and sql queries have been replaced with [...] in order not to expose my employer's database schema information.

Hibernate: /* select [...] */ select [...]JDBCExceptionReporter:100 - SQL Error: -99999, SQLState: nullJDBCExceptionReporter:101 - executeQuery method cannot be used for update.

I googled: db2 "executeQuery method cannot be used for update"

and the second result lead me to this.

It turns out that the problem was that I had the hibernate property "hibernate.use_sql_comments" set to "true". This caused the error because the hql was prepended to the sql query. Once I commented out the setting of that property the problem went away. I suppose that the default is false for this property.


I copy and paste the material here just in case it disappears from the referenced page.

Hibernate problems and solutions

  1. Hibernate not retrieving entity and throwing (what seems) a jdbc driver exception.

I have a simple entity mapping and attempt to save and then retrieve the object by the generated id. Hibernate throws the following exception:

org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not load an entity:
[nz.co.client.blitztecapp.model.MessageArchiveImpl#41]; uncategorized SQLException for SQL [/* load nz.co.client.blitztecapp.model.MessageArchiveImpl */ select messagearc0_.MESSAGE_ARCHIVE_ID as MESSAGE1_0_0_, messagearc0_.MESSAGE_TYPE as MESSAGE2_0_0_, messagearc0_.CONTENTS as CONTENTS0_0_, messagearc0_.MESSAGE_ID as MESSAGE4_0_0_, messagearc0_.PACKAGE_ID as PACKAGE5_0_0_, messagearc0_.CREATED_BY as CREATED6_0_0_, messagearc0_.CREATED_DATE as CREATED7_0_0_ from MESSAGE_ARCHIVE messagearc0_ where messagearc0_.MESSAGE_ARCHIVE_ID=?]; SQL state [null]; error code [-99999]; executeQuery method cannot be used for update.; nested exception is com.ibm.db2.jcc.a.SqlException: executeQuery method cannot be used for update.
Caused by: com.ibm.db2.jcc.a.SqlException: executeQuery method cannot be used for update.
at com.ibm.db2.jcc.a.co.a(co.java:2079)
at com.ibm.db2.jcc.a.cp.d(cp.java:1528)
at com.ibm.db2.jcc.a.cp.K(cp.java:316)
at com.ibm.db2.jcc.a.cp.executeQuery(cp.java:299)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
at org.hibernate.loader.Loader.doQuery(Loader.java:674)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1860)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:42)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3042)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:395)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:375)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:139)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:195)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:103)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:815)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:808)
at org.springframework.orm.hibernate3.HibernateTemplate$1.doInHibernate(HibernateTemplate.java:467)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:369)
at org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.java:461)
at org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.java:455)
.
.

Problem:
The problem is a hibernate property that I had set : hibernate.use_sql_comments=true causes the failure. This seems to be a bug in hibernate - Unset the property and things should work fine.

November 25, 2009

DB2 9.7 JDBC Driver causes a problem for hibernate native id strategy

I've been struggling with a problem where an application I'm upgrading had problems inserting new records into a database using hibernate.

App Server: IBM Websphere Application Server 6.1
DB: IBM DB2 8.?
JDBC Driver: Those packaged with IBM DB2Express v9.7

I would get a message stating:
org.hibernate.HibernateException: The database returned no natively generated identity value

When I changed my Websphere server configuration to point to an older db2 jdbc driver, the insert succeeded.

Information and workaround options are available here.

October 08, 2009

In Ubuntu, sh is dash, not bash

I've been trying to install IBM Websphere Application Server 6.1 on Ubuntu 9.04 AMD64. The installer kept failing. I found this post that clued me in that in Ubuntu /bin/sh is a symbolic link to /bin/dash (a faster, smaller shell apparently). The association of sh can be changed from dash to bash as follows:
unlink /bin/sh
ln -s /bin/sh bash
after doing this the installer worked just fine.

Should you desire, you can switch back to dash. Just run the above commands substituting 'dash' for 'bash' in the second one.

Here is more information on the sh-as-dash 'feature' of Ubuntu.

September 24, 2009

Aptitude (Command-line package manager)

Here are some commands to use (usually with sudo):
aptitude update -- update the package repo
aptitude safe-upgrade
aptitude full-upgrade
aptitude search 'part of package name'
aptitude show package-name
aptitude install package-name

Switching Linux Consoles

Turns out linux has several consoles going at once. From within my Gnome session I can press Ctrl-Alt-F1 and bring up console one. Gnome is running on console 7 so Ctrl-Alt-F7 brings me back into Gnome. Ctrl-Alt-F1 through Crtl-Alt-F7 work. Notice that Crtl-Alt-F1 takes you to TTY1 and Ctrl-Alt-F6 to TTY6. Having a full terminal to run from is handy when the session on TTY7 (Gnome) gets messed up some how.

Ctrl-Alt-F8 brings up some text, maybe system messages or something but it doesn't look like a command line I can do something with.

A little research suggest nothing runs on Terminals 8-12 initially.

Adding key to apt so ppa packages can be authenticated

I use a program called KeePass on Windows to manage passwords. There is a project called KeePassX for Linux that will use the same password database file I use on windows. To install it on Ubuntu 9.04 AMD-64, I did the following:
Add the source to Ubuntu (System > Administration > Software Sources)
deb http://ppa.launchpad.net/keepassx/ppa/ubuntu jaunty main
deb-src http://ppa.launchpad.net/keepassx/ppa/ubuntu jaunty main
Add the project signing key to apt:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 095F1873
The signing key from launchpad was 1024R/095F1873 (note the part after the slash is used in the apt-key command.
The ppa page from which I got this information:
https://launchpad.net/~keepassx/+archive/ppa?field.series_filter=jaunty

Adding key to apt so ppa packages can be authenticated

When you add Third-Party Software Sources to Ubuntu, you will likely want to add those sources' shared keys to the apt so that when you update your packages a warning stating that some packages cannot be authenticated can be avoided. I get tired of it coming up. So, In my case I added
deb http://ppa.launchpad.net/keepassx/ppa/ubuntu jaunty main
deb-src http://ppa.launchpad.net/keepassx/ppa/ubuntu jaunty main
as sources.

Then I added the corresponding key to apt with this command:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 095F1873
095F1873 is part of the PPA's PGP signing key (1024R/095F1873)

September 04, 2009

Trapped in Terminal Server Client Full Screen

The Terminal Server Client (tsClient) that I use with Ubuntu (9.04) works quite well. But if you don't know how to escape full screen mode, it can be frustrating.

The key sequence Ctrl-Alt-Enter toggles full screen.

September 02, 2009

Killing processes in linux

I have a laptop running Ubuntu 9.04. Recently Lotus Notes was installed on it. Notes seems to become unstable some times. The instability is so bad that I can't close the program in the normal way (mouse-click the 'x' button in the upper right corner. I would have to run

ps ax | grep notes

to get the process id and then run

sudo kill -9 *procId*

to kill it.

Tyler, a coworker, pointed out to me that I could add 'Force Quit' to the panel at the top. When you press that you can just click on a misbehaving window to kill it.

August 25, 2009

Java HashSet can "lose" objects

If the hash of an Object changes, the Object is 'lost' in a HashSet.

I have some code that invoked HashSet.remove(Object) and the object was NOT removed. Turned out that after the object was added to the set, a field that is involved in computing the HashSet was changed. Then, because the hash of the object changed, the remove method didn't remove the object. I tested in Sun Java 1.6.0_13 and in on IBM jdk 1.5. I found this blog post about the subject that contains a good explanation.

I don't think this limitation is sufficiently documented Java's HashSet.

Thanks to Boris Kirzner

http://boriskirzner.wordpress.com/2006/10/01/hashsetcontains-does-your-busket-contain-something/

May 21, 2009

Internet Explorer Collection (Multiple Versions of Internet Explorer Installed on MS Windows)

I have just come across this package that can install many/all compatible Internet Explorer versions in your windows environment. Take a look.

April 24, 2009

Derby

Thanks to Bruce Phillips for this post on using the derby server that comes with MyEclipse.

Especially the part about adding an attrib to the connect string to create a new schema. (jdbc:derby://localhost:1527/phillipsDB;create=true)

http://www.brucephillips.name/blog/index.cfm/2009/2/28/Using-the-MyEclipse-Derby-Database-Server

April 10, 2009

MercurialEclipse

Installing MercurialEclipse plugin I've run into the problem that the plugin would say something like 'error when verifying mercurial install...'

Well. I installed the mercurial 1.2.1 windows binary package from here: , set HG environment variable to the path to the hg executable. the hg install directory was added to the PATH. Now the pluggin seems to work well.

March 12, 2009

Atheros Wireless in Ubuntu 8.10 Intrepid Ibex

Thanks for this blog entry
http://unsharptech.com/2008/10/31/atheros-wireless-in-ubuntu-810-intrepid-ibex/

With my Toshiba L355D-S7825 laptop I have to install a backports package

The package is linux-backports-modules-intrepid-generic

sudo apt-get install linux-backports-modules-intrepid-generic

February 26, 2009

Could not install cygwin on MS Windows Vista 32-bit

I just did a fresh install of windows on a fairly new laptop. The factory install was corrupt in some way. Windows explorer would crash all the time. It was annoying. So I wiped the harddrive and restored with Toshiba's handy-dandy windows-recovery-and-bloatware-restoration cd.

Any windows machine I use regularly has cygwin installed. I need my linux/unux-like tools. Cause I'd loose my geek card if I didn't unzip files using command line tools.

Something happened during the installation. It froze and never progressed. I've installed cygwin a bunch of times, so I'm confident this was not a case of impatience. I killed the install. Later I started another install. This would fail with a message to the effect that cygwin install failed to start because cygintl-3.dll couldn't be found. This caused bash.exe to hang. Tried a couple more times. Same result.

I decided that there might be something wrong in the cygwin-packages directory. When you run the installer it asks for a package dir and an install dir. So, I deleted the package dir.

The next run of the installer was completely successful.

January 31, 2009

I messed up my install of Juice podcatcher

Long explanation (If you want the skinny, just look at the summary below)

Update, 2/1: the fix was not completely successful. See the update at the end.

This isn't really a software engineering topic. But, hey! It's my blog. Someone might really need this information!

So I wanted to try the Juice open source podcast receiver (some people call them podcatchers). As of my writing this article, the current version is 2.2. I installed it, started it, opened up the preferences and saved them with a wrong path to the directory where my podcasts should be saved. I think the problem is that by default the path was wrong for Vista. It was "C:\Users\\My Documents\My Received Podcasts"

But it should have been "C:\Users\\Documents\My Received Podcasts".

After I saved the preferences with the invalid path, Juice would crash every time I tried to start it. The following is from the log and shows the error that was crashing Juice.
Traceback (most recent call last):
File "gui.py", line 4, in ?
File "iPodderGui.pyc", line 3573, in main
File "ipodder\configuration.pyc", line 468, in __init__
File "os.pyc", line 154, in makedirs
OSError: [Errno 17] File exists: 'C:\\Users\\Ari Zelanko\\My Documents\\My Received Podcasts'
I tried to find a solution by googling the error. It didn't yield anything. Several people had posted questions on many sites about similar problems. No solutions were published.

I tried to reinstall the application. I uninstalled and reinstalled. No improvement. Juice still crashed on startup. I opened up the readme file in the Juice install directory. It has a section about updated from an older version of Juice (formerly iPodder). This is a quote from the Juice 2.2 readme file:
In iPodder 1.0 the settings were stored in the iPodder installation directory, probably C:\Program Files\iPodder. Starting with version 1.1 the configuration are placed outside the installation directory, in a user-specific directory, if possible. The default location is the NT-style Application directory, usually C:\Documents and Settings\yourname\Application Data\iPodder. If your settings were lost, try locating these three files in the previous installation directory and copying them to the new configuration directory: favorites.txt, history.txt, schedule.txt.
So, I started to look around my user directory for the settings. I found them. On Vista the path to the configuration was "C:\Users\\AppData\Roaming\iPodder".

"I'll just remove the settings folder and Juice will start up normally, right?" I thought. So I deleted the iPodder directory under my user profile. I started up Juice and voila! There was no change. Juice still crashed with the same message! How infuriating! (I should stop the gratuitous use of exclamation points!)

Just when I was about to give up, I thought, "Maybe if I reinstall right now, the problem will go away." ... And that worked.

Summary

The problem:
Because I set an invalid path-to-save-my-podcasts-to in the Juice preferences, the application wouldn't start. Rather it would crash on startup.

The error log:
Traceback (most recent call last):
File "gui.py", line 4, in ?
File "iPodderGui.pyc", line 3573, in main
File "ipodder\configuration.pyc", line 468, in __init__
File "os.pyc", line 154, in makedirs
OSError: [Errno 17] File exists: 'C:\\Users\\Ari Zelanko\\My Documents\\My Received Podcasts'
The Solution:
I removed the iPodder config directory under my user profile ("C:\Users\\AppData\Roaming\iPodder"). I then ran the Juice 2.2 installer again. I started the app and this time set the right directory for saving podcasts!

Update: The fix wasn't successful (2/1/2009)
After a restart, the problem in this post returned. For now I've carefully reproduced the issue, entered a bug with the project and included logs, config files and such. I've uninstalled Juice for now. I think I will look for another free podcatcher program.

January 27, 2009

Java Resources

Thanks to theServerSide for this great article by Ted Neward.

It contains a lot of resources for an up-and-coming java dev.

January 16, 2009

Install Ruby from binaries on Windows

Suppose you want to install ruby on Microsoft Windows and you don't want to use the One-click installer. Maybe it's because the installer is for ruby 1.8.6 and the newest stable binaries are for 1.8.7. You just have to get the most up-to-date binaries, because obviously 1.8.6 is just way too old.

I looked around for instuctions and found the answer posted by Lolindrath at stackoverflow.com.

  1. Download the windows binaries for Ruby 1.8.7 here: http://www.ruby-lang.org/en/downloads/ extract that to wherever you would like, I use c:\ruby. Then put c:\ruby\bin in your PATH environment variable.
  2. Download the zlib package: http://www.zlib.net/zlib123-dll.zip and extract the zlib1.dll, rename it to zlib.dll and move it into your Windows\System32.
  3. Download the iconv package: http://sourceforge.net/project/showfiles.php?group_id=25167&package_id=51458. Find and extract the iconv.dll into your Windows\System32.
  4. Download the rubygems package and follow the instructions, basically extracting the package and running ruby setup.rb
  5. Verify that everything works properly by trying a gem install rails, once that installs then do: rails test_project
These are the steps just as they were posted. I didn't just download the libraries from the links above. I checked for newer versions, but as of this post, there were none. I have not done step five. But I've installed a few gems and a couple of scripts I've written run fine.

January 14, 2009

That file isn't open!

I sometimes need to do something like delete a file and I can't because, according to windows, a program has the file open. Sometimes this happens because a process doesn't exit when you think it has.

Do you want to find out what program has a file open?

You can do it with a free program called ProcessExplorer.
In the program's Find menu choose 'Find Handle or DLL...' (Or press ctrl-F)
Enter a part of the file's name. Press enter. Voila! You now have a listing that includes the process id that has that file open. If you kill the process, you should have no trouble deleting that pesky file.

If you are not sure what killing a process is or if you should, then just restart the computer and that should fix the problem.