Tuesday, 29 April 2008

Using the ruby oracle_adapter on Windows XP

I have been having some problems getting my windows install of ruby to connect to oracle. It is so much easier on ubuntu. Looking at the blog of a friend Andrew Beacock other people have had the same problem, admittedly a while ago.

I tried the gem install command:
gem install activerecord-oracle-adapter
with no luck.

I tried
gem install activerecord-oracle-adapter --source http://gems.rubyforge.org
also with no luck.

Then I tried this. I am sure it is not the purist solution but it works !!!
Download the oracle_adapter.rb

Then copy this into the relevant directory under where you have ruby installed.
C:\ruby\lib\ruby\gems\1.8\gems\activerecord-2.0.2\lib\active_record\connection_adapters

And bobs your father's brother ...

My database.yml file looks like this:
development:
adapter: oracle
database: my_sid
username: my_user
password: my_password

Saturday, 5 April 2008

hibernate3 - hibernateQueryException - Class is not mapped

I have been having a problem for a while trying to get a basic hibernate3 and Spring 2.5 example working. Using old style hibernate CLASS_NAME.hbm.xml files worked fine. When I changed the context.xml file to try & use annotations instead I got the following error:

Exception in thread "main" org.springframework.orm.hibernate3.HibernateQueryException:
Test is not mapped [from Test t where t.name = ?];
nested exception is org.hibernate.hql.ast.QuerySyntaxException:
Test is not mapped [from Test t where t.name = ?] at
org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:640)


Check the imports of your '@Entity' annotations in your beans

If it is:
    org.hibernate.annotations.Entity;
Then change it to:
    import javax.persistence.Entity;
and life will be sweet.

Thursday, 13 March 2008

Getting mysql gui tools working on ubuntu 7.10

I had three hurdles to get over to get mysql gui tools to work.

1. My first problem was that I got the error

/bin/sh: bad interpreter: Permission denied

when I tried running mysql-administrator

This was because my mounted directory did not have exec permissions. Adding 'exec to the row in /etc/fstab, then umount & mount solved this.

/dev/hdb1 /media/d_drive auto rw,user,exec 0 0

2. My next problem was the following error:

./mysql-administrator

(mysql-administrator-bin:7476): Gtk-WARNING **: Unable to locate theme engine in module_path: "ubuntulooks",
Fontconfig warning: line 32: unknown element "cachedir"
Fontconfig warning: line 33: unknown element "cachedir"
Fontconfig warning: "/etc/fonts/conf.d/80-delicious.conf", line 18: invalid match target "scan"
./mysql-administrator-bin: symbol lookup error: /usr/lib/libbonoboui-2.so.0: undefined symbol: g_once_init_enter_impl

I eventually found this. The fix is right at the end.
To cut a long story short.

cd to where you have unpacked the gui tools
mv lib lib_
& if
/etc/mysql/conf.d does not exist
mkdir /etc/mysql/conf.d

3. My third and hopefully last problem was that I could not connect to localhost:3306
However I could connect to 127.0.0.1:3306
My /etc/hosts looked like this.

127.0.0.1 localhost
127.0.1.1 billspc

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
I am not sure if this is a good fix but the cure was to comment out the line

#::1 ip6-localhost ip6-loopback

Wednesday, 5 March 2008

IntelliJ Live Templates for Eclipse

D you miss all those IntelliJ Templates when in Eclipse.

If so, then go thekua.com for all the instructions you need.

UnitTest and spring-mock or spring-test

I have just installed spring 2.5.1

I wanted to create some unit tests and all the sites I found referred to spring-mock.jar.

It is now spring-test.jar.

You will find it in the directory spring-framework-2.5.1/dist/modules after you have extracted the zip. I downloaded spring-framework-2.5.1-with-dependencies.zip although I see they have gone to 2.5.2 already.

Tuesday, 26 February 2008

Eclipse on ubuntu throws ClassNotFoundException



I have just performed a fresh install on my pc with the latest ubuntu 7.10 (Gutsy Gibbon). After installing Eclipse I got the following Exception java.lang.ClassNotFoundException: org.eclipse.core.runtime.Plugin

The problem is that the default java that is installed is not compatible.

ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22 2008-02-26 14:52 /usr/bin/java -> /etc/alternatives/java

The solution is to install the latest version of java from www.sun.com
and change the java link in /usr/bin. I installed this in /tools/java6 and then created a link called java

cd /tools
sudo ln -fs /tools/java6 java
cd /usr/bin
sudo mv java java_alternatives
sudo ln -fs /tools/java/jdk/bin/java

Welcome

After several years of taking the michael out of a long lasting friend & colleague Andrew Beacock I have come to realise the benefits of blogging to all. Andrews blog has come to be an invaluable resource for our team. So here goes with my little contribution.