I'm trying to configure jboss 7.1.1.Final in a way, that modules would refer each other.
What we could implement would be that all dependencies depend in each other. So, in your example:
The log4j module would only have the javax.api and javax.transaction.api dependencies
The com.h2database.h2 module would have these two + log4j
The p6spy module would have these two + log4j + com.h2database.h2