xuexijava 2010年05月06日
Hibernate3.1报错。。。异常信息比较多看的有点晕高手帮看下是什么问题
做个小项目
用的环境是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
...全文
170 点赞 收藏 23
写回复
23 条回复

还没有回复,快来抢沙发~

发动态
发帖子
Web 开发
创建于2007-09-28

5.2w+

社区成员

34.1w+

社区内容

Java Web 开发
社区公告
暂无公告