0 Replies Latest reply on Jan 12, 2012 10:20 AM by Sascha Möllering

    Class cast exception

    Sascha Möllering Newbie



      my current setup looks like this:


      1) JBoss 7.1.0 CR1

      2) One DAO (Stateless-Session-Bean) extending an abstract class for generic hibernate-access:


      public abstract class AbstractHibernateDao<T, PK extends Serializable>

          implements GenericDaoIntf<T, PK> {



           * The persistent class.


          protected Class<T> persistentClass;



           * The Hibernate session.


          protected Session session;




          protected AbstractHibernateDao() {


              setPersistentClass((Class<T>) ((ParameterizedType) getClass()







      public class ApplicationHibernateDao extends AbstractHibernateDao<Application, String> {


          private static final int MAX_RESULTS = 1000;



          public Application findByPrimaryKey(String id) {

              return (Application) session.get(Application.class, id);







      The problem is: setPersistentClass throws:


      Caused by: java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.reflect.ParameterizedType


      Any hints?