请教一个hibernate小问题

07-06-26 ljw714
我用hibernate-extensions-2.1.3生成pojo类,但在我想使用hibernate3的包进行开发。在测试时出现错误:java.lang.NoSuchMethodError: net.sf.cglib.proxy.Enhancer.setInterceptDuringConstruction(Z)V

at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:126)

at org.hibernate.proxy.pojo.cglib.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:43)

at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:162)

at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:135)

at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:55)

at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(EntityEntityModeToTuplizerMapping.java:56)

at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:295)

at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:434)

at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:109)

at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)

at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)

at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)

at com.hw.system.common.CreateSession.OpenSession(CreateSession.java:12)

at HibernateTest.test(HibernateTest.java:17)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at junit.framework.TestCase.runTest(TestCase.java:154)

at junit.framework.TestCase.runBare(TestCase.java:127)

at junit.framework.TestResult$1.protect(TestResult.java:106)

at junit.framework.TestResult.runProtected(TestResult.java:124)

at junit.framework.TestResult.run(TestResult.java:109)

at junit.framework.TestCase.run(TestCase.java:118)

at junit.framework.TestSuite.runTest(TestSuite.java:208)

at junit.framework.TestSuite.run(TestSuite.java:203)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

应该是某个地方去读取hibernate2的包,但我不知道是再哪里。忘各位高手指教。

banq
2007-06-26 16:47
就是在java的classpath了

有两种IDE classpath 和运行环境classpath。

你上述结果是在开发工具IDE发生的,就从IDE classpath寻找,反之后者。

ljw714
2007-06-26 20:50
我觉得应该是某个配置文件配置的时候写的是调用hibernate2的net.sf.cglib这个包。如果没有配置文件调用,我的classpath设置了hibernate2和hibernate3的jar包都没关系吧。不知道我的理解是否正确

猜你喜欢