问题
When I deploy my war file in wildfly9.0 I get following error; Any clue?
Hibernate version=5.0.1.Final
Hibernate validator version =5.2.1.Final
09:57:34,368 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 64) MSC000001: Failed to start service jboss.persistenceunit."test2dbwar.war#test2dbwar-persistence-unit": org.jboss.msc.service.StartException in service jboss.persistenceunit."test2dbwar.war#test2dbwar-persistence-unit": java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast to java.lang.Class
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:172)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:117)
at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:665)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:182)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
at org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast to java.lang.Class
at org.hibernate.cfg.AttributeConverterDefinition.<init>(AttributeConverterDefinition.java:67)
at org.hibernate.cfg.Configuration.addAttributeConverter(Configuration.java:2729)
at org.hibernate.cfg.Configuration.addAttributeConverter(Configuration.java:2673)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.buildHibernateConfiguration(EntityManagerFactoryBuilderImpl.java:1153)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:853)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:850)
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:425)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:849)
at org.jboss.as.jpa.hibernate4.TwoPhaseBootstrapImpl.build(TwoPhaseBootstrapImpl.java:44)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:154)
... 7 more
09:57:34,381 ERROR [org.jboss.as.controller.management-operation] (XNIO-1 task-9) WFLYCTL0013: Operation ("add") failed - address: ([("deployment" => "test2dbwar.war")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.persistenceunit.\"test2dbwar.war#test2dbwar-persistence-unit\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"test2dbwar.war#test2dbwar-persistence-unit\": java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast to java.lang.Class
C
回答1:
Wildfly 9's included hibernate version is not 5. See What versions of libraries are shipped with WildFly 9.0.1.Final Probably you have to use the correct version or exclude the servers' libraries using jboss-deployment-structure.xml. Or try Wildfly 10, which includes hibernate 5.
来源:https://stackoverflow.com/questions/37516192/java-lang-classcastexception-sun-reflect-generics-reflectiveobjects-parameteriz