December 28, 2012

Chrome extension to test RESTFul services

Hi all

Just found a great tool to quickly build HTTP requests to test REST Services : Postman is its name.

Web interface is neat and simple, you can store your requests under Collections, control headers, follow "rel" style links, and so on.

The tool supports authentication as well, I tested quickly simple auth and it works great.

On top of that, you can dynamize your requests with some attributes, i.e. test the same request against several environments using a http://{{serverName}}/rest/... syntax.

December 18, 2012

Jax-RS Jersey on WAS 6.1 : ASM ClassReader noSuchMethodException

Today I had to POC a Jersey REST application deployed on a Websphere Application Server 6.1.

At first I had the now classic Hibernate / Jersey exception related to asm dependency :


[13/12/12 14:36:32:296 CET] 00000033 ServletWrappe E   SRVE0100E: Exception init() non intercept?e par le servlet ServletContainer : java.lang.NoSuchMethodError: org/objectweb/asm/ClassReader.accept(Lorg/objectweb/asm/ClassVisitor;I)V
 at com.sun.jersey.server.impl.container.config.AnnotatedClassScanner.analyzeClassFile(AnnotatedClassScanner.java:322)
 at com.sun.jersey.server.impl.container.config.AnnotatedClassScanner.indexDir(AnnotatedClassScanner.java:271)
....
...

The thing is :

  • Hibernate is loading cglib, which in turns loads asm with an old version
  • Jersey needs asm with a newer version, and both version aren't compatibles because of changes in packages.
Solution (that's not from me, it's well documented on the network) :
  • Exclude cglib, asm and asm-attr when declaring hibernate maven dependency (if you're using maven of course)
  • Explicitely declare a dependecy to cglib-nodep. This cglib repackaged artefact includes cglib AND asm, with altered package definition not to conflict with jersey asm version.
So your poms should by now look like this :



   cglib
   cglib-nodep
   2.1_3




   org.hibernate
   hibernate
   
   
   
    
     asm
     asm
    
    
     asm
     asm-attrs
    
    
     cglib
     cglib
    
   





   com.sun.jersey
   jersey-server
   1.1.4.1






So now hibernate is using is own version of asm, and Jersey the 3.11 required version.
So why do I keep getting this error ?

After a few hours struggling with my favorite deployment manager, which I thought was the cause of the issue, I realized that the loaded ClassVisitor class was coming from WAS internal plugins.
After setting a breakpoint and inspecting the classloader, I saw that the class was loaded from this jar : 
C:/Program Files/IBM/SDP70/runtimes/base_v61/plugins/com.ibm.wsfp.main_6.1.0.jar

So what's left to us ?
  • Solution #1 : Delete this jar :-) - Works, but not optimal !
  • Solution #2 : There must be a Websphere setting related to the classloader (PARENT_FIRST vs PARENT_LAST ?), but I can't get it to work (I get exceptions in the was console whenever I try to change those settings).

Anyhow, if anybody knows how to tell Websphere to pick up my jar instead of its jar, please let me know ! Any help would be greatly appreciated.

December 14, 2012

Multiple SSL Virtual Host with Apache : the SNI isssue

A short note of what I understood.

For french speaking persons, have a look here : Mimiz explained that much better than I do !

Before Apache 2.2.12, if you set up multiple Virtual Host with SSL configuration, you owuld end up with a warning like this :


[warn] vhost2 VirtualHost overlap on port 443, the first (vhost1) has precedence

You could set up as many SSL VHost configuration you want, on ly the first one would be used, sometime resulting in client warnings because wrong certificate was served.

From 2.2.12 and on, OpenSSL (shipped with Apache) uses the SSL extension named SNI (which stands for Server Name Identification). This extension allows Apache to send the right certificate, according to the domain requested.

But client AND server have to use this SNI thing, and of course some clients do not follow the rule...follow my gaze.

According to the wiki page :

No support

The following combinations do not support SNI:

In short, If you have to support IE on XP, you'll have to have as many IP addresses as desired domains.

December 10, 2012

Liferay Service builder : finder methods not created in *ServiceUtil class

I had to generate finder methods via liferay service builder, and was surprised not to find corresponding static utility methods in *ServiceUtil class.

I had to "manually" write the implemenation of those methods in my *LocalServiceImpl.java class. Tod do so, simply call the corresponding *util.findByxxxx method in your implementation method :


// xxxLocalServiceImpl.java :
public List<XXX> findByGroupId(long groupId) throws SystemException {
return xXXPersistence.findByGroupId(groupId);
}
And then re-run service builder build-services task to create the corresponding static utility method in XXXLocalServiceUtil class.


Hope this help.