This blog is mainly about Java...

Tuesday, February 9, 2010

Advanced Seam series

In the upcoming weeks I will be posting some nice articles about some of the advanced features of Seam I know people have trouble understanding and incorporating. 

The articles will be a "three" (may be more) part series where I will cover the topics Interceptors, Filters and Asynchronous events.

I will show working real life examples of all three. You will learned:
  • What Interceptors are, and how you can use them and incorporate security techniques using interceptors.
  • Filters - Why they are useful to use. 
    • I will show how you can implement a filter that enables downloading of files without consumption of unnecessary memory.
  • Asynchronous - I will show how you can send a mail asynchronously

If there are any advanced areas you wish to know more about, let me know by writing in the comment section and I will consider adding them to the series.

Monday, January 25, 2010

"Too many open files error" when running TestNG in Eclipse

I frequently get this exception when trying to run a test from TestNG in Eclipse.

Open a terminal and write ulimit -n and you will most probably get 1024.
(ulimit -a) for everything. (I am running Ubuntu 9.10)

This means you can have max 1024 open files.

To fix this check this page out and follow the instructions.
http://knol.google.com/k/fred-grott/open-file-limits-settings-on-ubuntu/166jfml0mowlh/3#

setProperty must be overridden by all subclasses of SOAPMessage

Have you gotten this error message? Then you probably either upgraded from Java 5 to Java 6 in JBoss application, or you just tried to run your webservice client for the first time.

The reason your Webservice client call suddenly fails is because of a bug in JBoss WS with JBoss 4.x

I haven't tested this on JBoss 5, so I cannot for sure exclude this bug in JBoss 5. However, the bug seem to be fixed in jbossws-2.0.

The solution to this problem is to
Copy the three jars from <JBOSS_HOME>\server\default\lib to <JBOSS_HOME>\lib\endorsed.

jboss-jaxrpc.jar
jboss-jaxws.jar
jboss-saaj.jar 

More information can be found here

Wednesday, November 25, 2009

s:convertDateTime

In the Seam documentation there is very little information about this tag.
In the documentation, there is only one example:
<h:outputText value="#{item.orderDate}">
   <s:convertDateTime type="both" dateStyle="full"/>
h:outputText>

This doesn't really say much. However, after some googling, I can explain some of the attributes, and what is actually useful to use.
If you want to show both date and time: dd-MM-yyyy hh:mm:ss you can use type="both" and dateStyle="full". If you want to show only date. Use type="date".

You choose from a range of different dateStyle.
default                   May 14, 2007 2:35:45 PM ( Default Value)
short                     5/14/07 12:55:42 PM
medium                 May 14, 2007 2:42:36 PM
long                      May 14, 2007 2:41:08 PM
full                        Monday, May 14, 2007 2:39:56 PM


However what I have found the most useful is just to use the pattern attribute together with the type.
So if you want the style 14.07.2009 you just write

<h:outputText value="#{item.orderDate}">
   <s:convertDateTime type="both" pattern="dd-MM-yyyy"/>
h:outputText>
And you are set to go! 

Monday, November 23, 2009

Axis 2 gotcha

Just wanted to give a quick GOTCHA I discovered with Axis 2. The other day I wanted to install and use lombok (which is AWESOME by the way).

However lombok needs Java 6 to run, and my WebService was compiled with Java 5, so I changed to Java 6, recompiled, but obviously forgot to recompile the WebService client stubs.
 I didn't get any exception that remotely told me that I had a class version issue. However, I got this exception:
com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog
After reverting back to Java 5, everything worked just fine. So just a heads up.

Labels