Running tests through JUnit SwingUI Test Runner and JDeveloper 10g

Submitted by Jochus on Wed, 20/02/2013 - 21:13 | Posted in: Java
Posted in


The following error occurred when running a JUni test

org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [com/psws/psbilling/test/spring/dataSourceContext.xml]; nested exception is java.lang.IllegalArgumentException: Class [org.springframework.beans.factory.xml.SimplePropertyNamespaceHandler] does not implement the NamespaceHandler interface
Caused by: java.lang.IllegalArgumentException: Class [org.springframework.beans.factory.xml.SimplePropertyNamespaceHandler] does not implement the NamespaceHandler interface
	at org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver.initHandlerMappings(
	at org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver.<init>(
	at org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver.<init>(
	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.createDefaultNamespaceHandlerResolver(
	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.createReaderContext(
	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(
	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(
	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(
	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(
	at org.springframework.test.AbstractSingleSpringContextTests.loadContextLocations(
	at org.springframework.test.AbstractSingleSpringContextTests.loadContext(
	at org.springframework.test.AbstractSpringContextTests.getContext(
	at org.springframework.test.AbstractSingleSpringContextTests.setUp(
	at org.springframework.test.ConditionalTestCase.runBare(


After Googling a while, I noticed some classes are cached inside the Spring context. Theses classes cannot be accessed from the classloader which is used to startup the JUnit Testrunner. So the dependency injection fails.

The following step solved this issue:

  • Add in your home folder (e.g.: /Users/jochen/) the file:
  • Provide the following file contents:

MySQL table names always converted to lowercase

Submitted by Jochus on Thu, 14/02/2013 - 16:58 | Posted in: Mac
Posted in


When I execute DDL statements to my MySQL database on my Mac installation, every table is converted to lowercase letters - even if the name is in uppercase letters in my script. This leads to errors in ALTER TABLE operations to add foreign keys (because of case sensitive).


According to this page:

How table and database names are stored on disk and used in MySQL is affected by the lower_case_table_names system variable, which you can set when starting mysqld. lower_case_table_names can take the values shown in the following table. This variable does not affect case sensitivity of trigger identifiers. On Unix, the default value of lower_case_table_names is 0. On Windows the default value is 1. On Mac OS X, the default value is 2.

I updated my my.cnf file:

$ sudo nano /private/etc/my.cnf

... by adding the following line:


Installing Windows fonts on a fresh Ubuntu installation

Submitted by Jochus on Tue, 12/02/2013 - 15:00 | Posted in: Linux
Posted in


Fonts like Tahoma, Verdana, ... are missing on a standard Ubuntu installation. I was looking to install the Microsoft TrueCrypt fonts so I could open Word documents (created in Microsoft Office) correctly in OpenOffice. Also, I had the issue some of my webpages were not looking ok in Firefox (Linux) - fonts were missing, so pages could look totally different.


  • Install package msttcorefonts
  • $ sudo aptitude install msttcorefonts

  • To be able to reload the fonts, without rebooting the machine, execute the command:
  • $ sudo fc-cache -fv

How to disallow content copying and printing of a PDF (aka securing a PDF)

Submitted by Jochus on Mon, 11/02/2013 - 21:18 | Posted in: Java
Posted in

I came across some issues with processing secured PDF's. These PDF files were encrypted. After reading the following documentation:…, I tried securing one of my own PDF's.


Encrypting the PDF so text cannot be copy/pasted and the PDF could not be printed


  • iText
  • BouncyCastle jars

Libraries used

  • iText: 5.3.5
  • BouncyCastle: bcprov-jdk14-1.47.jar and bcprov-ext-jdk14-1.47.jar


import com.itextpdf.text.pdf.PdfReader;
import com.itextpdf.text.pdf.PdfStamper;
import com.itextpdf.text.pdf.PdfWriter;
public class EncryptPDF {
	private static final String INPUT_FILENAME = "/tmp/test.pdf";
	private static final String OUTPUT_FILENAME = "/tmp/test_encrypted.pdf";
	private static final String USER_PASSWORD = "";
	private static final String OWNER_PASSWORD = "foobar";
	public static void main(String[] args) {
		PdfReader reader = null;
		FileOutputStream out = null;
		PdfStamper stamper = null;
		try {
			// Define input
			reader = new PdfReader(INPUT_FILENAME);
			// Define output
			out = new FileOutputStream(OUTPUT_FILENAME);
			// Encrypt document
			stamper = new PdfStamper(reader, out);
			stamper.setEncryption(USER_PASSWORD.getBytes(), OWNER_PASSWORD.getBytes(), 0, PdfWriter.STANDARD_ENCRYPTION_128);
		} catch (Exception ex) {
		} finally {
			if (stamper != null) {
				try {
				} catch (Exception ex) {
			if (reader != null) {
				try {
				} catch (Exception ex) {
			if (out != null) {
				try {
				} catch (Exception ex) {


You can also play with the permissions by providing PdfWriter perms instead of the value "0".

stamper.setEncryption(USER_PASSWORD.getBytes(), OWNER_PASSWORD.getBytes(), PdfWriter.ALLOW_ASSEMBLY | PdfWriter.ALLOW_COPY, PdfWriter.STANDARD_ENCRYPTION_128);

Check if PDF is secured

  • When opening the PDF with Acrobat Reader, the title should end with: (SECURED)
  • Open the properties of the PDF in Acrobat Reader ( + D on a Mac ) and look at Document Restrictions Summary

Changing the startup scripts of an Ubuntu installation

Submitted by Jochus on Sun, 10/02/2013 - 19:23 | Posted in: Linux
Posted in


When you boot your Ubuntu installation, a lot of scripts are started. A lot of scripts are superfluous. But how to disable the ones you don't need?


  • Install rcconf
  • $ sudo aptitude install rcconf

  • Disable the service by toggling the service using the "space bar".
  • $ sudo rcconf

Eclipse code assist in .xhtml pages (JSF tags, Richfaces tags, ...)

Submitted by Jochus on Sat, 09/02/2013 - 17:53 | Posted in: Java
Posted in

If you are missing code assist in XHTML pages, try to the change the following project settings:

  • Right click on project > Properties
  • Choose: Project Facets
  • Check and choose the correct version for Dynamic webmodule
  • Check and choose the correct version for JavaServer Faces

Formatting XML documents using Vi and Xmllint

Submitted by Jochus on Thu, 07/02/2013 - 14:48 | Posted in: Mac
Posted in

If you want to format the following XML document:

<?xml version="1.0" encoding="UTF-8"?><ROOT><FOO><BAR>Hello World</BAR></FOO><BAR><FOO>World Hello</FOO></BAR></ROOT>

... you can use Vi in combination with Xmllint to do the formatting

$ vi example.xml
:%!xmllint --format -

... the result will be:

<?xml version="1.0" encoding="UTF-8"?>
    <BAR>Hello World</BAR>
    <FOO>World Hello</FOO>

Building Richfaces 3.3.x from source code

Submitted by Jochus on Thu, 07/02/2013 - 14:43 | Posted in: Java
Posted in

When building Richfaces 3.3.x from source, you might run into the following error:

richfaces\framework\test\src\main\java\org\ajax4jsf\tests\[32,7] org.ajax4jsf.tests.EnumSupportExpressionFactoryWrapper is not abstract and does not override abstract method coerceToType(java.lang.Object,java.lang.Class) in javax.el.ExpressionFactory

The solution to solve this error:

The problem is that there are different versions of the "el-api-1.0.jar" on the Internet.

The official JAR, with 24432 bytes and SHA1 checksum df8c6ce0406676e70c5d018e5fb988be1bcf1024, is available at the usual locations:

RichFaces 3.3.X does not compile when this JAR is used. It needs the "el-api-1.0.jar" from the old Maven 1 repo at (29309 bytes, SHA1 1e72d5b13b698f99058d35751a29f87ef3066e87).

You don't have to clear the whole local repository or circumvent your Maven proxy. It is just enough to delete all files in %HOME_DIR%\.m2\repository\javax\el\el-api\1.0\ and download into that folder.