Saturday, 11 December 2010

cleaning frequency of /tmp and /var/tmp

/tmp normally gets cleared after every reboot on ubuntu which is a bit quick for me. For example I sometimes want to save a screenshot and maybe quickly edit it and e-mail it, but I don't want to loose it if my system reboots for whatever reason (including forgetting that I was busy with something).
It turns out that you can set how long to keep stuff in /tmp by setting TMPTIME in /etc/default/rcS to the number of days to keep stuff (I'm going for 7days now).
http://linuxers.org/article/differences-between-tmp-and-vartmp

Apparently you normally should put temp stuff you want to keep a bit longer in /var/tmp [1] but that does not seem to get cleared out regularly.
So I made a weekly cronjob to clean out stuff older than 60 days:/etc/cron.weekly/clean_var_tmp.sh
#!/bin/bash
days=60
tmpdir=/var/tmp/
find -P ${tmpdir} -type f -mtime +$days        -exec su amanica -c "notify-send 'weekly clean ${tmpdir}' 'rm {}'" \; -exec rm {} \;
find -P ${tmpdir} -type d -mtime +$days -empty -exec su amanica -c "notify-send 'weekly clean ${tmpdir}' 'rm {}'" \; -exec rm -r {} \;

http://ubuntu-virginia.ubuntuforums.org/showthread.php?t=1524077

[1] http://www.pathname.com/fhs/2.2/fhs-5.15.html

Wednesday, 27 October 2010

@Entity(name != table_name !!!

Normally if you get "org.hibernate.hql.ast.QuerySyntaxException: is not mapped" then you used the table name in stead of the class name. In my case I'm ashamed to admit, 
I though setting @Entity(name is setting the table name,
where in fact it is setting the JPQL alias! 
I thought it was weird that you can set that and the @Table(name . 


@Entity(name != table_name !!!
@Entity(name != table_name !!!
@Entity(name != table_name !!!
@Entity(name != table_name !!!
@Entity(name != table_name !!!
@Entity(name != table_name !!!
@Entity(name != table_name !!!
@Entity(name != table_name !!!
@Entity(name != table_name !!!
@Entity(name != table_name !!!


Thanks Matt Raible for showing me the light:

If you specify a name value for your @Entity annotation (for example
@Entity(name="person")), this will be the alias for HQL queries. If you
don't specify this value, the name will match the short name of your class (
Person). If you want to change the table name that's generated, use the
@Table
with a "name" value.

Tuesday, 19 October 2010

IncompatibleClassChangeError: Implementing class

In my case this was caused by incompatible versions of hibernate in the classpath...


2010-10-19 12:40:32,271:ERROR   Problem encountered during View.servePage       - com.icesoft.faces.context.View
java.lang.IncompatibleClassChangeError: Implementing class
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
        at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:983)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1501)
        at za.co.enerweb.nampower.report.hibernate.HibernateSessionFactory.(HibernateSessionFactory.java:60)