如何解决java.lang.NoSuchMethodError:org.hibernate.integrator.internal.IntegratorServiceImpl

时间:2014-10-08 20:11:40

标签: java hibernate nosuchmethoderror

我是hibernate的新手,我试图在持久层中使用Hibernate构建一个JSF应用程序。这就是我获得Session Factory的方式。

Configuration config = new Configuration().configure("hibernate.cfg.xml");
        StandardServiceRegistryBuilder ssrb = new StandardServiceRegistryBuilder().applySettings(config.getProperties());
        factory = config.buildSessionFactory(ssrb.build());

但是在运行应用程序时出现以下错误。

Error Message:
Caused by: java.lang.NoSuchMethodError: org.hibernate.integrator.internal.IntegratorServiceImpl.<init>(Ljava/util/LinkedHashSet;Lorg/hibernate/boot/registry/classloading/spi/ClassLoaderService;)V
    at org.hibernate.boot.registry.BootstrapServiceRegistryBuilder.build(BootstrapServiceRegistryBuilder.java:247)
    at org.hibernate.boot.registry.StandardServiceRegistryBuilder.<init>(StandardServiceRegistryBuilder.java:73)
    at com.sherwin.j29.jpa.factory.JPASessionFactory.createSessionFactory(JPASessionFactory.java:19)
    at com.sherwin.j29.jpa.factory.JPASessionFactory.getSessionFactory(JPASessionFactory.java:13)
    at com.sherwin.j29.dao.WorkItemDAO.<init>(WorkItemDAO.java:24)
    at com.sherwin.j29.dao.WorkItemDAO$Proxy$_$$_WeldClientProxy.<init>(WorkItemDAO$Proxy$_$$_WeldClientProxy.java)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at org.jboss.weld.util.reflection.SecureReflections$16.work(SecureReflections.java:344)
    at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52)
    at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInstantiation(SecureReflectionAccess.java:173)
    at org.jboss.weld.util.reflection.SecureReflections.newInstance(SecureReflections.java:341)
    at org.jboss.weld.bean.proxy.ProxyFactory.create(ProxyFactory.java:237)
    at org.jboss.weld.bean.proxy.ClientProxyFactory.create(ClientProxyFactory.java:105)
    at org.jboss.weld.bean.proxy.ClientProxyProvider.createClientProxy(ClientProxyProvider.java:87)
    at org.jboss.weld.bean.proxy.ClientProxyProvider.access$000(ClientProxyProvider.java:43)
    at org.jboss.weld.bean.proxy.ClientProxyProvider$1.load(ClientProxyProvider.java:53)
    at org.jboss.weld.bean.proxy.ClientProxyProvider$1.load(ClientProxyProvider.java:46)
    at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3589)
    at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2374)
    at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2337)
    at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2252)

我正在使用hibernate 4.3.6。

如果我错过了什么,请告诉我。

2 个答案:

答案 0 :(得分:1)

确保已从类路径中删除了所有以前版本的Hibernate。

在github上查看它,我不明白为什么会出现这种情况,除非您遇到版本冲突引起的类加载器问题,因为IntegratorServiceImpl存在于您正在/正在使用的两个版本中,这表明类加载器问题给我

答案 1 :(得分:0)

如果最近有任何软件包升级,请尝试清理并构建项目。