hibernate3.5生成不了SessionFactory.错误如下:java.lang.ClassCastException: org.hibernate.annotations.common.reflection.java.JavaReflectionManager cannot be cast to org.hibernate.annotations.common.reflection.MetadataProviderInjector
at org.hibernate.cfg.AnnotationConfiguration.reset(AnnotationConfiguration.java:312)
at org.hibernate.cfg.Configuration.<init>(Configuration.java:216)
at org.hibernate.cfg.Configuration.<init>(Configuration.java:220)
at org.hibernate.cfg.AnnotationConfiguration.<init>(AnnotationConfiguration.java:168)
at com.dao.impl.EmployeeDaoImplTest.testA(EmployeeDaoImplTest.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
我在网上查了下,说是hibernate3.5的hibernate3.jar已经包含了注解包,不需要hibernate-annotations.jar包了,于是我把
 hibernate-annotations.jar删了,可是还是不行求大侠指教!!
或者告诉我hibernate3.5需要哪些包?

解决方案 »

  1.   

    我使用xml获得时没有问题:SessionFactory sdf = new Configuration().configure()
    .buildSessionFactory();使用注解时就有问题了: SessionFactory sdf = new AnnotationConfiguration().configure()
    .buildSessionFactory();这是为什么呀,求求大侠 了
      

  2.   

    应该是 缺jar包的 问题吧  你添加 hibernate-annotations.jar 试试
      

  3.   

    添加了hibernate-annotations.jar,不行我记得hibernate3.jar已经包含了hibernate-annotations.jar 了 不用添加继续求教。
      

  4.   

    你选择的jar有问题,多了ejb3-persistence.jar,hibernate-annotations.jar,hibernate-commons-annotations.jar这三个包,3.5已经将它们合并到了hibernate3.jar中,同时被合并的jar中还有hibernate-entityManager.jar,另外少了一个很重要的包是cglib-2.2.jar。不过3.5版本中存在bug,在使用QL的时候Query接口的实现有问题
    这是 我在网上 找到的 错误跟你的 一样 不知道 用没用
      

  5.   

    大侠,我问下,用hibeernate,你们使用的哪些包,我的是:
    antlr-2.7.6.jar
    commons-collections-3.1.jar
    commons-logging-1.0.4.jar
    dom4j-1.6.1.jar
    hibernate3.jar
    hibernate-jpa-2.0-api-1.0.0.Final.jar
    javassist-3.9.0.GA.jar
    jta-1.1.jar
    junit-4.8.2.jar
    log4j-1.2.16.jar
    slf4j-api-1.5.8.jar
    slf4j-log4j12-1.5.8.jar大家帮忙看看我写的包有问题吗?你们怎么用哪些hibernate3.5的包?
      

  6.   

    用MyEclipse8.5吧,集成的,方便好用!至于点击添加hibernate就行了!
      

  7.   

    我知道答案,因为我刚才也遇到同样的问题!不过我是到国外的网站上去找到答案的解决方法:
    删除两个jar包
    1、 hibernate-annotations.jar
    2、 hibernate-commons-annotations.jar至少我的问题和你一样,解决了,不知道你的能不能解决了