Apache CXF Linux Deployment

April 11th, 2011

A short reminder of small issues I had with deploying Apache CXF web service I built on linux server (CentOS in my case):

yum install tomcat5 went really well :) and then I had to add webapps and manager packages with separate commands.

tomcat5 package depends on jdk-1.4 so in case you haven’t already installed a more recent version of java you’ll get this one.

I used the tutorial from http://www.jroller.com/gmazza/entry/web_service_tutorial to set up the options for deploying to tomcat using maven and that went well, but jdk-1.4 was causing spring context loader to throw:

SEVERE: Exception sending context initialized event to listener instance of
class org.springframework.web.context.ContextLoaderListener
java.lang.NoClassDefFoundError: org.springframework.core.CollectionFactory
at java.lang.Class.initializeClass(libgcj.so.7rh)

and the actual error displayed when I tried to access the service from the browser was:

threw exception javax.xml.transform.TransformerFactoryConfigurationError:
Provider org.apache.xalan.processor.TransformerFactoryImpl not found  at
javax.xml.transform.TransformerFactory.newInstance(Unknown Source)  at

This was solved by installing open-jdk 1.6 devel package with yum, but then another, trickier error appeared:

java.lang.NoClassDefFoundError: org/apache/xml/serializer/OutputPropertiesFactory
at org.apache.xalan.templates.OutputProperties.(OutputProperties.java:82)
at org.apache.xalan.transformer.TransformerIdentityImpl.(TransformerIdentityImpl.java:86)

At several links (here and there) I figured it out that it has something to do with xalan.jar which was unavailable to my service deployed on tomcat. A command:

yum list xerces* xalan* | grep installed

showed that I already had xalan-2.7.1 in my /usr/share/java so I tried with copying it to CATALINA_HOME/common/endorsed but that didn’t fix the problem. I also tried symlinking xalan.jar to that file but that didn’t work either.

In the end, at the link which appeared to be some forum’s archive I found that someone had problems similar to this and was advised revert to xalan-2.6 version. I’ve tried with jar in http://archive.apache.org/dist/xml/xalan-j/binaries/xalan-j_2_6_0-bin.zip and it worked.

Yeee “me happy” :)


Java, Links, linux , , ,

Battle for Brilliant Developers (not Managers)

February 23rd, 2011

Recently, I’ve read about many companies offering rewards for referring great developers to them. Examples are Hubspot offering $10k, SeoMoz oferring $12k, and EnergySavy oferring $10k.

It appears that demand for developers exceeds supply so it’s good to be developer these days so I am using this opportunity to remind young computer science graduates that they are sometimes badly taught that being a developer is like being a plain old dirty worker and that they should strive to become project managers or team leaders. Graduates should ask themselves if they have ever seen a job ad asking for managers and offering reward before making a decision to become “great managers the world will know of” :)

After all, the most important thing is to be happy in what you are doing. And in my opinion being developer makes you happy and forever young (at least in spirit).

(The illustrations below show Happy developer and Miserable manager)


General, fun , , ,

Griffon eclipse support plugin

December 3rd, 2010

Recently I was playing  with griffon which I used together with jung library to visualize binary decision diagrams. In this regard, I had to make several small projects. Since I do that in my spare time, at the moment I start a new project I forgot how I managed to integrate previous griffon project with eclipse IDE (actually I am using Spring Tool Suite with Groovy and Grails support but I guess it’s the same as with eclipse) so that IDE doesn’t pop up nasty message similar to:

The project was not built since its build path is incomplete.
Cannot find the class file for groovy.lang.GroovyObject.
Fix the build path then try building this project.
The type groovy.lang.GroovyObject cannot be resolved.
It is indirectly referenced from required .class files 
Config.groovy    /myprojectname/griffon-app/conf    line 1

I used: griffon integrate-with -eclipse command which actually allowed me to import griffon project to eclipse but that wasn’t enough.

The solution was eclipse support plugin.

Having that written down I hope I won’t forget it again. :)


Java, groovy , , ,

Scruffy is outputting partial or blank images

October 1st, 2009

Scruffy gem that uses rmagick has a bug that caused me a lot of troubles since I am new to Ruby programming language. I am using windows environment.
Anyway, I was trying an example from Ruby in Practice by Jeremy McAnally and Assaf Arkin when I encountered a strange bug with Scruffy (now I know that it is its bug but it took me a while :).
This bug causes that any graph you try to render, renders only partially, similarly to the picture below:

The problem (with solution) is described here: http://rubyforge.org/tracker/index.php?func=detail&aid=27102&group_id=2030&atid=7929.

The cause of this problem is incorrect generation of viewbox by the base renderer. When you incorporate changes mentioned in the link above to RUBY_INSTALL\lib\ruby\gems\1.8\gems\scruffy-0.2.6\lib\scruffy\renderers\base.rb you should be able to render correct graphs.


ruby , ,

Debugging GUI events

September 22nd, 2009

Debugging gui events is usually not possible with regular line per line debugging and is done mostly by tracing.
For debugging code that relies on Java swing events like drag and drop, mouse moving, etc., having something similar to code below is very useful:

public boolean isMouseAboveHeaderPanel() {
System.out.println("HeaderPanel.isMouseAboveHeaderPanel() called from: "
+ Thread.currentThread().getStackTrace()[2].getClassName() + "."
+ Thread.currentThread().getStackTrace()[2].getMethodName());
// ...

In this way you trace not only current function but also you got information from where you entered that function. Of course to make things easier you should make some kind of a shortcut for entering this trace line. In Eclipse you can do that with code template:

System.out.println("${enclosing_type}.${enclosing_method}() called from: "
+ Thread.currentThread().getStackTrace()[2].getClassName() + "." 
+ Thread.currentThread().getStackTrace()[2].getMethodName());

This helped me in lot of situations, I hope that it will help you as well.


General, Java , ,

Groovy blob and mysql

September 20th, 2009

In certain occasions e.g. when you want to save scrapped html page or just a specific part of it (e.g. div with its contents) the recommendation I found is to use the blob type and save xml document as binary stream.

In groovy, this is achieved in a rather simple way:

class Document {
  int id
  String title
  String xmlContent
Sql sql = Sql.newInstance(
          "user", "pass", "com.mysql.jdbc.Driver")
// We assume db table similar to:
      `id` bigint(32) NOT NULL AUTO_INCREMENT,
      `title` varchar(500) NOT NULL,
      `xmlContent` blob,
      PRIMARY KEY (`id`)
def saveDocuments(def docs) {
  println "Saving documents to database..."
  def documents = sql.dataSet("document")
  docs.each {Document doc ->
    documents.add(title: doc.title, xmlContent: doc.xmlContent)

When you want to retrieve data, with Groovy this is not much complicated either:

def loadDocuments() {
  def list = []
  sql.eachRow("SELECT * FROM document") {
    Document doc = new Document(it.toRowResult())
    if (it['xmlContent'] != null) {
      doc.xmlContent = new String(it['xmlContent'])
  println "Loaded ${list.size()} documents from database"

I tried the code with mysql database but I assume that you can achieve the same with any other database.

One hint for mysql blobs and utf-8: although utf-8 charset behaves very well with other database table fields (if you add useUnicode=true and characterEncoding=UTF-8 parameters to your connection string), in order to work with utf-8  blob fields you should adjust one more parameter: useBlobToStoreUTF8OutsideBMP=true. With this parameter set, your utf8 encoded xml documents will behave well with mysql database.


Java, groovy , , ,

Groovy meliorates and dries

June 12th, 2009

Dynamic languages are very popular at this time and you probably had insight into at least one of them (Ruby, Python, Groovy).

If you are bound to Java platform the best way to “be dynamic” IMHO is to work with Groovy.

Apart from the http://groovy.codehaus.org/ where you can find documentation, getting started examples etc. there are many blogs around that blog about groovy.

My favorite (although very slow) is Andres Almiray’s blog. He mostly blogs about griffon and groovy and has nice tutorials and examples. There I found info about many open source libraries I never heard of but which are quite useful, for example: FEST, Glazed list, Swing clarity, etc.

Try Groovy cause it’s groovy :)

I felt like when I run my first program at elementary school and it wrote “Ninja” on the screen :)


Java, groovy ,

Why would you spend time on warez sites?

March 3rd, 2009

Even if not being a “regular” warez user it would be good if you stay informed about what is happening inside warez community.
One reason would be finding really popular and valuable programs by browsing warez sites. This is better than searching through regular download sites because programs found on these kind of sites are often more relevant to the field in which they belong. One reason could be this - If somebody put an effort to crack a piece of software then that software has some value for sure :).

I use: http://www.area51warez.info/ and http://softarchive.net/.


General, Links , , ,

HtmlUnit as Java Screen Scraping Library

January 23rd, 2009

If you are needing behavior ‘as though a real browser was scraping and using the page’ HtmlUnit is definitely the best option available. It was designed for testing websites but works great for screen scraping and navigating through multiple pages. It takes care of cookies and other session-related stuff and can execute (if you want it to) the Javascript in the page.

I’ve personally tried several other tools from this list (Jericho, Web Harvest) but neither of them is as good as this library. For example, writing a screen scraper with Web Harvest is an easy task, but badly formatted pages cause xml parser to break and this happened to me a lot of times. Jericho is ok but it took me much more coding to achieve the same as with HtmlUnit.

Take a look at HtmlUnit getting started and start scraping in no time.


Java , , , ,

‘Awesome’ administrator

January 20th, 2009

I am not sure if this clip is fake or not but it’s hilarious for sure. This guy is the administrator you don’t want to employ at your company (maybe you can recommend him to your competitors :).

Watch it from here:


fun , ,