Friday, July 23, 2010

Removing unwanted kernels in Ubuntu and updating Grub2 configuration

The installation of a new kernel adds two new entries in the Grub menu. I have set the default selected entry to something different from the first item, so each time a new kernel is installed, the default entry points to the wrong menu item. Using update-grub will automatically update all Grub2 configuration files, and that's when the kernels present in the file system are automatically detected (Grub2).

I want to remove the old kernels, which I won't need anymore. There are several ways to do it. I'll show how to do it on the command line. First, let's list the installed kernels


dpkg -l | grep linux-im

ii linux-image-2.6.32-23-generic 2.6.32-23.37 Linux kernel image for version 2.6.32 on x86
ii linux-image-2.6.32-24-generic 2.6.32-24.38 Linux kernel image for version 2.6.32 on x86
ii linux-image-generic 2.6.32.24.25 Generic Linux kernel image


Here, we see package names and package version numbers. The syntax to completely remove packages is "apt-get purge packagename". Let's remove the unwanted kernel image, which is 2.6.32-23.37. The string used after "purge" is a regular expression. I don't bother to escape it.

sudo apt-get purge .*.2.6.32-23

All packages matching this regular expression will be completely removed. This operation must be done with caution. Fortunatly, before packages are removed, a confirmation will be displayed (in Japanese in my local environment):

以下のパッケージは「削除」されます:
linux-headers-2.6.32-23* linux-headers-2.6.32-23-generic*
linux-image-2.6.32-23-generic*
アップグレード: 0 個、新規インストール: 0 個、削除: 3 個、保留: 0 個。
この操作後に 184MB のディスク容量が解放されます。
続行しますか [Y/n]? Y

This shows that three packages will be removed. That's what I was expecting. After accepting the changes, the Grub configuration will be automatically updated ! No need to update it yourself.

Running postrm hook script /usr/sbin/update-grub.
Generating grub.cfg ...
...
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.32-24-generic
Found initrd image: /boot/initrd.img-2.6.32-24-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Microsoft Windows XP Home Edition on /dev/sda1
Found Windows NT/2000/XP on /dev/sda3
done

Voila ! The unwanted kernels should be gone from the file system and from the Grub menu.

Thursday, July 22, 2010

Griffon 0.9 released

Griffon 0.9 is out, with a bunch of bug fixes and new features. Once thing which caught my eyes was Spock. It's not a name easy to miss ! But it's the first time I hear about it. Yet another framework on my todo list.

Sadly, I've stopped studying Griffon recently. My lack of Groovy/Grails knowledge is wasting all the fun. I've decided to study Groovy and Grails first, as Griffon is not only based on Groovy, but it also gets a lot of its inspiration from Grails. I bought Grails In Action and started studying it. There's a whole chapter on Groovy basics. Developping Grails application helps to get used to it. I must say that this is a very cool framework ! Once I'm finished with it, I plan to go back to Griffon, and restart reading Griffon In Action's MEAP book.

I'm late to dive into the Groovy world. There's so much I have to do to get back on tracks. But the efforts are well worth it. Groovy is fun. Grails is fun. But I'm yet to know just how fun it can be.

Friday, July 9, 2010

Preventing services to startup at boot time in Ubuntu

After installing Tomcat6 via the Synaptic package manager, Tomcat is automatically started at boottime. This was fine, until I started playing with Grails. Without changing any configuration settings, Grails will start its own web server instance at the default http port, 8080, the same as Tomcat's default. This results in an error when trying to start a Grails application :

grails run-app

Server failed to start: java.net.BindException: Address already in use

There are different ways to avoid this error. Make Grails use Tomcat's instance, change either Grails or Tomcat's default http port, or don't start Tomcat at boot time. I decided to remove Tomcat's automatic startup. How do we do that in Ubuntu ?

Init scripts are in /etc/init.d, and symbolic links to these scripts are separated in runlevels, each residing in /etc/rcX.d/, where X is the runlevel. We could remove them by hand, but this can be done easily with one single command : update-rc.d

sudo update-rc.d tomcat6 disable

update-rc.d: warning: tomcat6 start runlevel arguments (none) do not match LSB Default-Start values (2 3 4 5)
update-rc.d: warning: tomcat6 stop runlevel arguments (none) do not match LSB Default-Stop values (0 1 6)
Disabling system startup links for /etc/init.d/tomcat6 ...
Removing any system startup links for /etc/init.d/tomcat6 ...
/etc/rc0.d/K20tomcat6
/etc/rc1.d/K20tomcat6
/etc/rc2.d/S20tomcat6
/etc/rc3.d/S20tomcat6
/etc/rc4.d/S20tomcat6
/etc/rc5.d/S20tomcat6
/etc/rc6.d/K20tomcat6
Adding system startup for /etc/init.d/tomcat6 ...
/etc/rc0.d/K20tomcat6 -> ../init.d/tomcat6
/etc/rc1.d/K20tomcat6 -> ../init.d/tomcat6
/etc/rc6.d/K20tomcat6 -> ../init.d/tomcat6
/etc/rc2.d/K80tomcat6 -> ../init.d/tomcat6
/etc/rc3.d/K80tomcat6 -> ../init.d/tomcat6
/etc/rc4.d/K80tomcat6 -> ../init.d/tomcat6
/etc/rc5.d/K80tomcat6 -> ../init.d/tomcat6

There are a couple of warning because I used the disable command without any parameters. These can be ignored. As the man page says : "If no start runlevel is specified after the disable or enable keywords, the script will attempt to modify links in all start run‐levels.". Enabling back the service at bootime is as simple (same warnings):

sudo update-rc.d tomcat6 enable

update-rc.d: warning: tomcat6 start runlevel arguments (none) do not match LSB Default-Start values (2 3 4 5)
update-rc.d: warning: tomcat6 stop runlevel arguments (none) do not match LSB Default-Stop values (0 1 6)
Enabling system startup links for /etc/init.d/tomcat6 ...
Removing any system startup links for /etc/init.d/tomcat6 ...
/etc/rc0.d/K20tomcat6
/etc/rc1.d/K20tomcat6
/etc/rc2.d/K80tomcat6
/etc/rc3.d/K80tomcat6
/etc/rc4.d/K80tomcat6
/etc/rc5.d/K80tomcat6
/etc/rc6.d/K20tomcat6
Adding system startup for /etc/init.d/tomcat6 ...
/etc/rc0.d/K20tomcat6 -> ../init.d/tomcat6
/etc/rc1.d/K20tomcat6 -> ../init.d/tomcat6
/etc/rc6.d/K20tomcat6 -> ../init.d/tomcat6
/etc/rc2.d/S20tomcat6 -> ../init.d/tomcat6
/etc/rc3.d/S20tomcat6 -> ../init.d/tomcat6
/etc/rc4.d/S20tomcat6 -> ../init.d/tomcat6
/etc/rc5.d/S20tomcat6 -> ../init.d/tomcat6

To disable the running service without having to reboot:

sudo /etc/init.d/tomcat6 stop

* Stopping Tomcat servlet engine tomcat6 [ OK ]

After that, Grails applications will be happy to run:

grails run-app

Welcome to Grails 1.1.1 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /usr/local/lib/grails-1.1.1

Base Directory: /home/kuriqoo/eclipse/workspace/hubbub
Running script /usr/local/lib/grails-1.1.1/scripts/RunApp.groovy
Environment set to development
Running Grails application..
Server running. Browse to http://localhost:8080/hubbub

Tomcat can be manually started using :

sudo /etc/init.d/tomcat6 start

* Starting Tomcat servlet engine tomcat6
Using CATALINA_BASE: /var/lib/tomcat6
Using CATALINA_HOME: /usr/share/tomcat6
Using CATALINA_TMPDIR: /tmp/tomcat6-tmp
Using JRE_HOME: /usr/lib/jvm/java-6-openjdk
Using CLASSPATH: /usr/share/tomcat6/bin/bootstrap.jar [ OK ]

Thursday, July 8, 2010

Oracle updating the Sun Java Certifications

Oracle is starting to change the Sun Certifications. There are already four exams in Beta stage :

* Sun Certified JPA Developer for the Java EE6 Platform
* Sun Certified Developer for the Java Web Services for the Java EE6 Platform
* Sun Certified JSP and Servlet Developer for the Java EE6 Platform
* Sun Certified EJB Developer for the Java EE6 Platform

SCBCD5.0 included JPA1.0 in it. Now JPA has its own exam, so if you want to be a Business Component Developer, you'll have to pay two exams. Beta exams were free in the past. Oracle has decided to get a few bucks out of them. You pay $50 to attend the Sun Certified JSP and Servlet Developer for the Java EE6 Platform beta exam, and spend 3 to 5 hours answering 215 questions ! Good luck. The exam objectives are still very evasive, contrary to the old ones which were very detailed. I mean, in the JPA certification, what is "Optimize database access" and "Use advanced JPA features" supposed to include ? If I decide to upgrade one day, I'll wait for the official one. No beta for me.

JavaRanch and the Big Moose Saloon

JavaRanch and its Big Moose Saloon is a great place to go for anybody interested in Java. If you have a Java problem, go there. If you want to pass a Sun (Oracle) certification like SCJP, SCWCD, SCBCD..., go there. There are also forums for Groovy, Scala, Javascript...

Some of the top reasons why you should be a member :

1. It's a very friendly place. No insults. No "you don't even know that ??" kind of mockery. When you sign there, the first thing you are told is to "Be Nice". It's the number one JavaRanch policy. It's a nice place.
2. The place is kept clean by a bunch of bartenders and sheriffs (ranchy names for moderators), whose first rule is also to "Be Nice". There's no exception to the rule. We are all here to help each other.
3. You'll find people answering your problems relatively quickly. I rarely see questions left unanswered.
4. Answers are usually checked by moderators, leading into constructive arguments or more elaborate answers.
5. You'll find great materials and advices to pass the Sun certifications. Advices given by other members who actually passed the exam.
6. You'll meet book authors, some of them being regual members.
7. One of the original goal of the forum was to help people. So insteading of giving away code snippets for coding problems, we tend to lead people toward the answer, to make them think by themselves. This may take some time, but it's really worth it.
8. The ranch listens to you, and you can help it change. If you have any request concerning the forums, people will listen to you, and debate whether or not your ideas could be applied.
9. You'll have a chance to win free books ! A book promotion is conducted almost every week, where book or software authors spend a week answering members' questions about their product. Don't miss it.

I love being there, helping others solving their problems. I learned a lot thanks to the ranch. Not only about Java, but also about dealing with problems. It's also a great motivation to be there, being surrounded by software experts. It's sometimes challenging to "Be Nice". I think things would easily get out of hands in other forums. But not at JavaRanch. You'll be in good hands.

So, what are you waiting for ? Join this great community.

Sunday, July 4, 2010

Book review : Beginning Oracle Database 11g Administration: From Novice to Professional

I have finished reading the book "Beginning Oracle Database 11g Administration: From Novice to Professional (APress)", by Iggy Fernandez. First of all, I am not a DBA. I'm using Oracle at work, but, most of the time, I'm only using basic SQL. I have nothing to do with database administration, but recently I wanted to know more about Oracle, and this book is just what I needed. The author doesn't go deeply into details, which that is not the purpose of the book. He introduces the most important topics (installation, monitoring, backups, recoveries, tuning...) in a very understandable manner. I don't think that this book will turn anyone into an Oracle Professional, as the title suggests, but it does cover enough material to make you more than a novice. I recommend it highly to anyone who wants to know the basic notions of the Oracle architecture and administration.

I plan to buy "Expert Oracle Database Architecture: Oracle Database Programming 9i, 10g, and 11g Techniques and Solutions" by Thomas Kyte, which is planned to be published this month. For the moment, I'll start reading the Oracle Concepts PDF file, which is available online.

Thursday, June 24, 2010

Eclipse Marketplace in Eclipse Helios

Eclipse Helios is out, it's time to check some of the new features. Helios comes with a new system to manage plugins even more easily than before : the Eclipse Marketplace. Gathering softwares, third-party tools, plugins, etc... and making them easily accessible is becoming a trend these recent years. Android Market, iPhone App Store, you name it.

Until Eclipse Galileo, the easiest way to install plugins was to :
1. Search for the plugin on Internet (by using the Eclipse Plugin Central for example)
2. Get the Update Site URL to be used in Eclipse's Update Manager
3. Go to Eclipse Update Manager, register the plugin host using the Update Site URL
4. Follow the instructions to install the plugin

Now, with the Eclipse Marketplace, no need to leave Eclipse :

1. Access the Eclipse Marketplace via the Help menu
2. Search for the plugin by entering some relevant keywords
3. Click the Install button of the plugin
4. Follow the instructions to install the plugin

I needed to use SubVersion on my freshly installed Helios. Let's see what the Eclipse Marketplace looks like and how easy it is to install plugins.

1. Access the Eclipse Marketplace via the Help menu.


2. Search for the plugin by entering some relevant keywords.


3. Click the Install button of the plugin (I chose Subversive).


4. Follow the instructions to install the plugin, and restart Eclipse. The Subversive plugin is now listed in the Installed tab of the Eclipse Marketplace.