Friday, November 16, 2007

How to use TopLink along with JBoss

JBoss is bundled with Hibernate as the default JPA/EJB3 persistence implementation, like GlassFish which is bundled with TopLink essentials. Developers who are trying to use TopLink in an application which is to be deployed on JBoss may face with some difficulties.

Persistence implementation class is referenced in persistence.xml. Since Hibernate JPA implementation is referenced somewhere in persistence.xml in a META-INF folder visible in JBoss classpath, javax.persistence.Persistence finds at least two implementations: TopLink (which is deployed with the application, and you put persistence.xml in your classes/META-INF) and Hibernate. A call to EntityManagerFactory implementation constructor is done through reflection. If it returns null, Persistence tries with the next implementation found. The problem here is that a call to Hibernate's EntityManagerFactory cannot be done, since Hibernate classes (org.hibernate.*) are not visible in the current classloader's classpath, so your application fails to deploy with a ClassCastException for Hibernate's EntityManagerFactory implementation. To overcome this problem you need to do a small trick. Just copy hibernate-entitymanager.jar inside WEB-INF/lib folder, so that org.hibernate.ejb.HibernateEntityManagerFactory is visible in class path. Since all hibernate libraries are not available and also you specified another implementation (TopLink) in your META-INF/persistence.xml, Hibernate is bypassed and TopLink is used instead.

Thursday, November 8, 2007

Typos in Digital Copies of Yusuf Ali Translation

There are a number of copies of widely-known Quran translation of Abdullah Yusuf Ali on the web. Since most of the digital copies are using the text provided by USC-MSA (which is actually extracted by means of OCR), they all have the same typo for 23:22.

Today, I noticed a bug report for Zekr's Yusuf Ali translation, which mentioned the typo. I then checked the printed copy of the book on Google books and found the original text, which was different in 4 places.

The original Arabic text for Sura Al-Muminun, aya 22 is:
وَعَلَيْهَا وَعَلَى الْفُلْكِ تُحْمَلُونَ

the right English translation of Yusuf Ali is:
And on them, as well as in ships, ye ride.

while many websites have the meaningless translation:
An on them, as well as in slips, ye side.

I just tried a Google search and found that the buggy one is more commonly used than the right one. My first query resulted in 6 items, while the second one (buggy) resulted in 27. The copy on on Wikisource also had that problem, which is now fixed.

Special thanks to Benjamin Geer for pointing out these typos.