Thursday, March 29, 2007

db4o Java Bean Database

The db4o project makes a very simple, light-weight object database. It's free, too. Maybe too free, as they use GPL. But see comment below. Obviously this sort of thing is great if you do a lot of POJO development (say, with JSF) and need some persistent storage.

The downloadable documentation is pretty good, as is this article:

Two issues with the docs. First, their examples always assume that your bean has a complete constructor that sets all fields. You may not wish to do this, so instead you can just use the appropriate set method instead.

Assume you have a MyBean class with the fields beanName, beanCreationDate, beanCreator, and so on. Then:

MyBean myBean=new MyBean();
ObjectSet results=db.get(myBean);

The returned results set will have all the MyBean instances that you have stored with the name "Junk".

Second, you can only delete specific bean instances. That is, the corresponding db.delete(myBean) method for the above code will not delete all the matching beans.

//Won't work if your bean has multiple fields.
MyBean myBean=new MyBean();
//Won't work

To do this, you have to get the specific beans that you matched in the get() and the delete them one by one. For example,

MyBean myBean=new MyBean();
ObjectSet results=db.get(myBean);
//Reassign the myBean.

Denying Anonymous Reading in Media Wiki

See Don't forget to add the white-list pages to specify exceptions. Otherwise, no one will be able to read the login page. The following blog had a full example:

In summary, you need to edit LocalSettings.php with settings like those below.

$wgGroupPermissions['user' ]['read'] = true;

$wgGroupPermissions['*' ]['createaccount'] = false;
$wgGroupPermissions['*' ]['read'] = false;
$wgGroupPermissions['*' ]['edit'] = false;

One other note on creating accounts: to create accounts for other users, log in with sysop privileges (that is, login using the account that you created when you set up the wiki) and then point your browser to index.php/Special:Userlogin. This should give you the forms for new account creation.

Monday, March 19, 2007

Resizing Linux File Systems

I hadn't done this in a while and got some new linux servers, so I'm pleased to learn that it has gotten much easier to change disk partitions with LVM. I'm doing the following on RHEL ES 4.

I'll assume logical groups and volumes have already been created, say by Dell. They'll probably do this because of the immutable physical law that it is easier to get bigger than to get smaller. If you are happy with these predefined logical volumes, you'll just need to increase the space on the existing file systems.

All of the following commands should be done as root. I'll assume your PATH is reasonable, but if not you can probably find them in /sbin/ or /usr/sbin.

  1. fdisk -l: This will show you the available devices and partitions. Use this to decide how much to increase any of the existing files.
  2. df -k: shows existing file systems. This will also show you the names of any logical volumes.
  3. vgdisplay: this will display info on your volume groups (i.e. see how much size is available).
  4. pvcreate /dev/sba: use this to initialize a new partition. You will need to do this if you have added new disks to your RAID. Get the actual device name (/dev/xyz) from the df command.
  5. lvextend -L100G /dev/VolGroup00/LogVol00: this will set the logical volume 100 GB in size. You can also use -L+10G to increase the size further. This will take a few moments to run.
  6. Use lvreduce to reduce logical volume sizes. Use this if you accidentally extend the wrong volume in the previous step (doh!).
  7. ext2online /dev/VolGroup00/LogVol00: increases the actual file system size (but see below).
The last step can depend on your file system type (mine was ext3). Look in /etc/fstab to see. This step caused some uncertainty at first, since many pages that I googled used resize2fs, but this was not in my path and so made me suspect this info may be obsolete or not appropriate for RHEL. was helpful.

[Looks like resize2fs is back in RHEL5 and Fedora Core 7, and ext2online's functionality has been incorporated in it. You just need to replace "ext2online" with "resize2fs".]

That's it. You probably will want to verify that everything worked, so do the following:
  1. umount /dev/VolGroup00/LogVol01: unmounts the volume.
  2. e2fsck /dev/VolGroup00/LogVol01: verifies the file system.
  3. mount /dev/VolGroup00/LogVol01: brings the volume and associated file system back up.
  4. df: verify the file system is mounted as expected.

Thursday, March 15, 2007

Java Libraries for Creating Atom Feeds

We're using Atomsphere to generate atom feeds from databases as a simpler version of Web services. So far, so good. I will post some examples later. See also Carol's notes here.

The above link is for their SourceForge downloads. The project page is here, although it looks like they are having bad gateway problems this morning.

Tuesday, March 13, 2007

Preventing new lines in JSP's generated servlets

Good tip from Dr. Chuck: don't use the following for your JSPs:

<%@ page import="cgl.gis.wfs.webservice.*"%>
String beginDate=request.getParameter("beginDate");

The generated servlet will include


which will put a blank line at the top of your output. This can cause problems if you are using JSP to generate (for example) XML feeds, since the XML header line must be the first line.

To fix, use instead

<%@ page import="cgl.gis.wfs.webservice.*"%><%
String beginDate=request.getParameter("beginDate");

Sakai JSR 168 Tests

* svn co sakai

* Must create a build file in your $HOME:

[gateway@gridfarm008 WebFeatureService_Deploy]$ more ~/
maven.repo.remote =,,http://www.ibi,,

maven.tomcat.home = /home/gateway/SakaiJsr168/apache-tomcat-5.5.20/


maven.compile.source= 1.5 1.5


* For a fast build, use "~/maven-1.0.2/bin/maven bld dpl" the first time to avoid downloading unnecessary jars.

* To run sakai's maven targets in any subdirectory, use

~/maven-1.0.2/bin/maven plugin:download -DgroupId=sakaiproject -DartifactId=sakai -Dversion=2.2

* To completely clean everything out,

~/maven-1.0.2/bin/maven cln

Note the usual "maven clean" will not use the the reactor. Noticed this because we had some problems with
incompatible java versions (1.6 versusu 1.5, trying to use 1.6 classes with 1.5 compiler).

* Or just use "find . -name target|xargs rm -r" (this is faster, since you won't have to check remote repositories
for jars that don't exist).

* Don't use Java 1.4. Use Java 1.5. Java 1.6 may work or not, but be sure to be consistent--Java 1.5 compilers
will not understand java 1.6 classes.

* After installing,
[gateway@gridfarm008 SakaiJsr168]$ mkdir apache-tomcat-5.5.20/sakai/
[gateway@gridfarm008 SakaiJsr168]$ cp sakai/reference/demo/ apache-tomcat-5.5.20/sakai/

* Be sure to use extra memory:
export CATALINA_OPTS="-server -Xms512m -Xmx512m -XX:NewSize=128m -XX:PermSize=16m -XX:MaxPermSize=128m -XX:+UseConcMarkSweepGC -XX

* Point browser to http://.../portal after it starts (tail -f your catalina.out file to track--could take a few

* Make your web.xml for your portlet:
<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"

<display-name>IFrame Portlet</display-name>
This application is a portlet. It can not be used outside a portal.

<!-- This param value should match the value of the <portlet-name> in

<!-- Note the servlet-name must match the servlet-name param above -->



* To add portlet,
1. Click "Worksite setup" and create a new workspace
2. In the workspace you just created, add the portlet using "Site Info"

* Tested: Velocity-based Iframe portlet (worked) and JSF-bridges based Google Map portlet (also worked). Tested
OGCE myproxy portlet and found a bug in the Sakai bridge (accidentally called portlet twice, which caused
problems since the portlet's state had been flushed.) Turned out to be an easy fix.

Tuesday, March 06, 2007

Web Desktop Master List

From Wikipedia, linked here so that I can remember it: