Depends. You can use Habanero in a webapp or ear in AS 4.2.0, as long as the jbc libs are a part of your application.
You cannot replace the JBoss Cache 1.x jars shipped with AS 4.2 with JBoss Cache 2.x jars.
More specifically you cannot replace the JBoss Cache 1.x jars in JBoss 4.x if you are using any of the following AS services which depend on the API-incompatible JBC 1.x:
1) HttpSession replication.
2) EJB3 SFSB replication
3) JBC as a Hibernate 2nd Level Cache (which includes EJB3 entities).
If you remove those services, you should be able to replace the jars in server/all/lib. But it's probably easier to package JBC in a war.
Thanks, I'll try and package it in an ear.