Hibernate3.1报错。。。异常信息比较多看的有点晕高手帮看下是什么问题

xuexijava 2010-05-06 04:01:20
做个小项目
用的环境是Hibernate3.1+Struts1.3中间只用的Spring2.0的一些工具类
做了一个多对一的映射具体文件如下
(这个是一这端的映射文件)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.domain">
<class name="ProductTypes">
<id name="id">
<generator class="uuid.hex" />
</id>
<property name="typeName" length="100"/>
<property name="createDate" length="100"/>
<property name="isShows" length="100"/>
<set name="product" cascade="delete" inverse='true' >
<key column="productType_id" />
<one-to-many class="Products"/>
</set>
</class>
</hibernate-mapping>
(这个是多这端的映射文件)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.domain">
<class name="Products">
<id name="id">
<generator class="uuid.hex" />
</id>
<property name="pName" length="100"/>
<property name="rl" length="100"/>
<property name="gg" length="100" />
<property name="sourceImgsPath" length="100" />
<property name="minImgPath" length="100" />
<property name="createDate" length="100" />
<many-to-one name="pt" class="ProductTypes" cascade="save-update">
<column name="productType_id"/>
</many-to-one>
</class>
</hibernate-mapping>
然后在Test类中写了个很普通的
           Query q=session.createQuery("from Products");
List list=null;
list=q.list();
for(int i=0;i<list.size();i++){
p=(Products)list.get(i);
System.out.println("产品名称:"+p.getpName());



报如下错误
Hibernate: select products0_.id as id6_, products0_.pName as pName6_, products0_.rl as rl6_, products0_.gg as gg6_, products0_.sourceImgsPath as sourceIm5_6_, products0_.minImgPath as minImgPath6_, products0_.createDate as createDate6_, products0_.productType_id as productT8_6_ from Products products0_
Exception in thread "main" java.lang.ExceptionInInitializerError
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at org.hibernate.proxy.CGLIBLazyInitializer.getProxy(CGLIBLazyInitializer.java:99)
at org.hibernate.proxy.CGLIBProxyFactory.getProxy(CGLIBProxyFactory.java:47)
at org.hibernate.tuple.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:372)
at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:3121)
at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:232)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:173)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:862)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:830)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:266)
at org.hibernate.type.EntityType.resolve(EntityType.java:303)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:116)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842)
at org.hibernate.loader.Loader.doQuery(Loader.java:717)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2145)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1106)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at com.test.Test.main(Test.java:35)
Caused by: net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:237)
at net.sf.cglib.reflect.FastClass$Generator.create(FastClass.java:64)
at net.sf.cglib.proxy.MethodProxy.helper(MethodProxy.java:81)
at net.sf.cglib.proxy.MethodProxy.create(MethodProxy.java:46)
at com.domain.ProductTypes$$EnhancerByCGLIB$$e011af00.CGLIB$STATICHOOK4(<generated>)
at com.domain.ProductTypes$$EnhancerByCGLIB$$e011af00.<clinit>(<generated>)
... 30 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at net.sf.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:384)
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:219)
... 35 more
Caused by: java.lang.LinkageError: loader (instance of sun/misc/Launcher$AppClassLoader): attempted duplicate class definition for name: "$java/lang/Object$$FastClassByCGLIB$$3f697993"
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
... 40 more
...全文
241 23 打赏 收藏 转发到动态 举报
写回复
用AI写文章
23 条回复
切换为时间正序
请发表友善的回复…
发表回复
xuexijava 2010-05-06
  • 打赏
  • 举报
回复
[Quote=引用 22 楼 justlearn 的回复:]

从官方文档看,是建议你设置ProxoolFacade.disableShutdownHook
然后在程序里显式地关闭连接池。
[/Quote]
So 3Q
justlearn 2010-05-06
  • 打赏
  • 举报
回复
从官方文档看,是建议你设置ProxoolFacade.disableShutdownHook
然后在程序里显式地关闭连接池。
xuexijava 2010-05-06
  • 打赏
  • 举报
回复
[Quote=引用 20 楼 justlearn 的回复:]

是的,换掉试试,你原来2.1.3不是nodep的吗?
cglib-nodep-2.1_3.jar
[/Quote]
太3Q了,整了快一下午终于搞定
把cglib-2.1.3.jar换成cglib-node-2.2.jar
问题解决。。。。。
justlearn 2010-05-06
  • 打赏
  • 举报
回复
是的,换掉试试,你原来2.1.3不是nodep的吗?
cglib-nodep-2.1_3.jar
xuexijava 2010-05-06
  • 打赏
  • 举报
回复
[Quote=引用 17 楼 justlearn 的回复:]

原来asm和cglib的包删除
[/Quote]
把cglib-2.1.3.jar换成cglib-nodep-2.2.jar?
还是怎么操作?
能说的具体点吗?
xuexijava 2010-05-06
  • 打赏
  • 举报
回复
[Quote=引用 14 楼 justlearn 的回复:]

官方文档,0.9.0RC3修正了和cglib的冲突,cglib要求2.1.3版本
0.9.0RC3
- New naming policy for Cglib stops conflicts with other Cglib instances that are running (even ones in different packages). Without using our own……
[/Quote]
我当个试试先
justlearn 2010-05-06
  • 打赏
  • 举报
回复
原来asm和cglib的包删除
justlearn 2010-05-06
  • 打赏
  • 举报
回复
0.9.1是最新的了,那么就试试换cglib
cglib-nodep-2.2.jar
xuexijava 2010-05-06
  • 打赏
  • 举报
回复
[Quote=引用 12 楼 xyylove520 的回复:]

jar包冲突
[/Quote]
哪个Jar包冲突呢?
justlearn 2010-05-06
  • 打赏
  • 举报
回复
官方文档,0.9.0RC3修正了和cglib的冲突,cglib要求2.1.3版本
0.9.0RC3
- New naming policy for Cglib stops conflicts with other Cglib instances that are running (even ones in different packages). Without using our own naming policy we end up with exceptions like:
java.lang.LinkageError: duplicate class definition:
$java/lang/Object$$FastClassByCGLIB$$3f697993
- Added ProxoolFacade.disableShutdownHook so that you can choose to explicitly shutdown Proxool programatically. This is useful because the order that the JVM calls shutdown hooks isn't easily controlled and you might want to shutdown Proxool *after* you've done some cleaning up yourself. Suggested by Alex Lemaire.
- Fixed bug in ProxoolDataSource to add in maximum-active-time. Credit to Paolo Di Tommaso.
- Fixed bug in AdminServlet where select HTML tag was not closed properly. Credit to Paolo Di Tommaso.
xuexijava 2010-05-06
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 justlearn 的回复:]

Proxool 换个新点的版本看看
[/Quote]
我用的是proxool-0.9.1
换哪个版本会好点?
2010-05-06
  • 打赏
  • 举报
回复
jar包冲突
luonanqin 2010-05-06
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 xuexijava 的回复:]
引用 8 楼 luonanqin 的回复:

at com.test.Test.main(Test.java:35)

楼主 这一行的代码是什么啊?

Products p=null;
Query q=session.createQuery("from Products");
System.out.println("te"+q);
ArrayList list=new Array……
[/Quote]

还真没看出来有啥错误,等高人指点
justlearn 2010-05-06
  • 打赏
  • 举报
回复
Proxool 换个新点的版本看看
xuexijava 2010-05-06
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 luonanqin 的回复:]

at com.test.Test.main(Test.java:35)

楼主 这一行的代码是什么啊?
[/Quote]
Products p=null;
Query q=session.createQuery("from Products");
System.out.println("te"+q);
ArrayList list=new ArrayList();


list=(ArrayList)q.list();
System.out.println("listSize:"+list.size());
for(int i=0;i<list.size();i++){
p=(Products)list.get(i);
System.out.println("产品名称:"+p.getpName());
}
35行是list=(ArrayList)q.list();
luonanqin 2010-05-06
  • 打赏
  • 举报
回复
at com.test.Test.main(Test.java:35)

楼主 这一行的代码是什么啊?
bunrise 2010-05-06
  • 打赏
  • 举报
回复
在class标签中加上layz="false"看看
xuexijava 2010-05-06
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 fairy_dy 的回复:]

由于Spring中的“asm-2.2.3.jar”和Hibernate中的“asm.jar”包冲突。解决办法是移除“asm-2.2.3.jar”即可,你试一下
[/Quote]
我Lib目录下没有asm-2.2.3.jar
nangonghaopeng 2010-05-06
  • 打赏
  • 举报
回复
这个是我 楼主已经添加好友
xuexijava 2010-05-06
  • 打赏
  • 举报
回复
Spring2.0只用了它的spring-beans.jar
加载更多回复(3)

81,090

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧