I encountered a similar problem, though for a different reason. I'm not 100% sure, but the issue seems to be caused by the fact that explicitly putting Hibernate on the classpath using Maven conflicts with JBoss 7 when it
automatically adds Hibernate as a dependency, due to the strict classloading system AS7 employs. I think the problem is that two ANTLR JARs end up on the classpath, and even though they're the same JAR, they're loaded separately which in turn means their classes are defined separately. So if you try to pass an object created by one JAR to something using the other JAR, you get a ClassCastException because they're technically not the same class and don't share the same inheritance hierarchy.
Fortunately, there's an easy workaround. For starters, unless you have explicit compile-time dependencies on Hibernate (versus just JPA), don't declare Hibernate as a dependency in your POM. Use this instead:
Code:
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-6.0</artifactId>
<version>3.0.0.Beta1</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
This will make all the EE stuff available at compile time, but will not add it to the classpath at runtime due to the provided scope, where JBoss will provide it instead.
If, for some reason, you do have an explicit compile-time dependency on Hibernate, do this:
Code:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.0.1.Final</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
</exclusion>
</exclusions>
</dependency>
Adding the exclusion fixes the problem for me.