高手指教啊。 郁闷好久了。错误描述
2006-1-20 10:34:24 net.sf.hibernate.cfg.Environment <clinit>
信息: Hibernate 2.1.7
2006-1-20 10:34:24 net.sf.hibernate.cfg.Environment <clinit>
信息: loaded properties from resource hibernate.properties: {hibernate.cglib.use_reflection_optimizer=true}
2006-1-20 10:34:24 net.sf.hibernate.cfg.Environment <clinit>
信息: using CGLIB reflection optimizer
2006-1-20 10:34:24 net.sf.hibernate.cfg.Environment <clinit>
信息: using JDK 1.4 java.sql.Timestamp handling
2006-1-20 10:34:24 net.sf.hibernate.cfg.Configuration addClass
信息: Mapping resource: com/aaok/blog/dao/Content.hbm.xml
2006-1-20 10:34:24 net.sf.hibernate.cfg.Binder bindRootClass
信息: Mapping class: com.aaok.blog.dto.Content -> content
Exception in thread "main" java.lang.NoClassDefFoundError: net/sf/cglib/beans/BulkBeanException
at net.sf.hibernate.util.ReflectHelper.getBulkBean(ReflectHelper.java:180)
at net.sf.hibernate.type.ComponentType.<init>(ComponentType.java:111)
at net.sf.hibernate.cfg.Binder.bindComponent(Binder.java:911)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:282)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1257)
at net.sf.hibernate.cfg.Configuration.add(Configuration.java:252)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:288)
at net.sf.hibernate.cfg.Configuration.addClass(Configuration.java:354)
at com.aaok.blog.dao.FindContentByIDDAOHibernate.FindContentBYID(FindContentByIDDAOHibernate.java:21)
at com.aaok.blog.dao.FindContentByIDDAOHibernate.main(FindContentByIDDAOHibernate.java:42)
执行的文件
package com.aaok.blog.dao;
import java.util.List;
import net.sf.hibernate.*;
import net.sf.hibernate.cfg.Configuration;
//import com.aaok.blog.dto.Content;
public class FindContentByIDDAOHibernate { public void FindContentBYID() throws HibernateException {
// System.out.println("23222222222222"+"what id is?"+ID);
List list = null;
Content content = new Content();
StringBuffer sb = new StringBuffer();
// sb.append(" from content,BlogItem where content.contentID='"+ID+"'");
System.out.println(sb);
Configuration config=new Configuration();
config.addClass(Content.class);
SessionFactory sf = config.buildSessionFactory();
Session session = sf.openSession();
Transaction tx = session.beginTransaction();
tx.commit();
session.close();
} public static void main(String[] arg) throws HibernateException{
FindContentByIDDAOHibernate FC= new FindContentByIDDAOHibernate();
FC.FindContentBYID(); }}content.java文件
package com.aaok.blog.dao;import java.io.Serializable;
import java.util.List;import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;/**
* @hibernate.class
* table="content"
*
*/
public class Content implements Serializable { /** identifier field */
private String contentId; /** identifier field */
private String content; /** identifier field */
private String abstracts;
private List list; /** full constructor */
public Content(String contentId, String content, String abstracts) {
this.contentId = contentId;
this.content = content;
this.abstracts = abstracts;
} /** default constructor */
public Content() {
} /**
* @hibernate.property
* column="contentID"
*
*/
public String getContentId() {
return this.contentId;
} public void setContentId(String contentId) {
this.contentId = contentId;
} /**
* @hibernate.property
* column="content"
*
*/
public String getContent() {
return this.content;
} public void setContent(String content) {
this.content = content;
} /**
* @hibernate.property
* column="abstract"
*
*/
public String getAbstract() {
return this.abstracts;
} public void setAbstract(String abstracts) {
this.abstracts = abstracts;
} public String toString() {
return new ToStringBuilder(this)
.append("contentId", getContentId())
.append("content", getContent())
.append("abstract", getAbstract())
.toString();
} public boolean equals(Object other) {
if ( !(other instanceof Content) ) return false;
Content castOther = (Content) other;
return new EqualsBuilder()
.append(this.getContentId(), castOther.getContentId())
.append(this.getContent(), castOther.getContent())
.append(this.getAbstract(), castOther.getAbstract())
.isEquals();
} public int hashCode() {
return new HashCodeBuilder()
.append(getContentId())
.append(getContent())
.append(getAbstract())
.toHashCode();
} /**
* @param list
*/
public void setList(List list) {
// TODO 自动生成方法存根
}
public List getList(){
return this.list;
}
}
content.hbm.xml文件
<?xml version="1.0"?>
<hibernate-mapping><class
name="com.aaok.blog.dto.Content"
table="content"
>
<meta attribute="class-description" inherit="false">
@hibernate.class
table="content"
</meta> <composite-id>
<meta attribute="field-description" inherit="false">
@hibernate.id
generator-class="assigned"
</meta>
<key-property
name="contentId"
column="contentID"
type="java.lang.String"
length="13"
>
<meta attribute="field-description">
@hibernate.property
column="contentID"
</meta>
</key-property>
<key-property
name="content"
column="content"
type="java.lang.String"
length="65535"
>
<meta attribute="field-description">
@hibernate.property
column="content"
</meta>
</key-property>
<key-property
name="abstract"
column="abstract"
type="java.lang.String"
length="65535"
>
<meta attribute="field-description">
@hibernate.property
column="abstract"
</meta>
</key-property>
</composite-id>
<!-- Associations -->
<!-- derived association(s) for compound key -->
<!-- end of derived association(s) -->
</class>
</hibernate-mapping>
2006-1-20 10:34:24 net.sf.hibernate.cfg.Environment <clinit>
信息: Hibernate 2.1.7
2006-1-20 10:34:24 net.sf.hibernate.cfg.Environment <clinit>
信息: loaded properties from resource hibernate.properties: {hibernate.cglib.use_reflection_optimizer=true}
2006-1-20 10:34:24 net.sf.hibernate.cfg.Environment <clinit>
信息: using CGLIB reflection optimizer
2006-1-20 10:34:24 net.sf.hibernate.cfg.Environment <clinit>
信息: using JDK 1.4 java.sql.Timestamp handling
2006-1-20 10:34:24 net.sf.hibernate.cfg.Configuration addClass
信息: Mapping resource: com/aaok/blog/dao/Content.hbm.xml
2006-1-20 10:34:24 net.sf.hibernate.cfg.Binder bindRootClass
信息: Mapping class: com.aaok.blog.dto.Content -> content
Exception in thread "main" java.lang.NoClassDefFoundError: net/sf/cglib/beans/BulkBeanException
at net.sf.hibernate.util.ReflectHelper.getBulkBean(ReflectHelper.java:180)
at net.sf.hibernate.type.ComponentType.<init>(ComponentType.java:111)
at net.sf.hibernate.cfg.Binder.bindComponent(Binder.java:911)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:282)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1257)
at net.sf.hibernate.cfg.Configuration.add(Configuration.java:252)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:288)
at net.sf.hibernate.cfg.Configuration.addClass(Configuration.java:354)
at com.aaok.blog.dao.FindContentByIDDAOHibernate.FindContentBYID(FindContentByIDDAOHibernate.java:21)
at com.aaok.blog.dao.FindContentByIDDAOHibernate.main(FindContentByIDDAOHibernate.java:42)
执行的文件
package com.aaok.blog.dao;
import java.util.List;
import net.sf.hibernate.*;
import net.sf.hibernate.cfg.Configuration;
//import com.aaok.blog.dto.Content;
public class FindContentByIDDAOHibernate { public void FindContentBYID() throws HibernateException {
// System.out.println("23222222222222"+"what id is?"+ID);
List list = null;
Content content = new Content();
StringBuffer sb = new StringBuffer();
// sb.append(" from content,BlogItem where content.contentID='"+ID+"'");
System.out.println(sb);
Configuration config=new Configuration();
config.addClass(Content.class);
SessionFactory sf = config.buildSessionFactory();
Session session = sf.openSession();
Transaction tx = session.beginTransaction();
tx.commit();
session.close();
} public static void main(String[] arg) throws HibernateException{
FindContentByIDDAOHibernate FC= new FindContentByIDDAOHibernate();
FC.FindContentBYID(); }}content.java文件
package com.aaok.blog.dao;import java.io.Serializable;
import java.util.List;import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;/**
* @hibernate.class
* table="content"
*
*/
public class Content implements Serializable { /** identifier field */
private String contentId; /** identifier field */
private String content; /** identifier field */
private String abstracts;
private List list; /** full constructor */
public Content(String contentId, String content, String abstracts) {
this.contentId = contentId;
this.content = content;
this.abstracts = abstracts;
} /** default constructor */
public Content() {
} /**
* @hibernate.property
* column="contentID"
*
*/
public String getContentId() {
return this.contentId;
} public void setContentId(String contentId) {
this.contentId = contentId;
} /**
* @hibernate.property
* column="content"
*
*/
public String getContent() {
return this.content;
} public void setContent(String content) {
this.content = content;
} /**
* @hibernate.property
* column="abstract"
*
*/
public String getAbstract() {
return this.abstracts;
} public void setAbstract(String abstracts) {
this.abstracts = abstracts;
} public String toString() {
return new ToStringBuilder(this)
.append("contentId", getContentId())
.append("content", getContent())
.append("abstract", getAbstract())
.toString();
} public boolean equals(Object other) {
if ( !(other instanceof Content) ) return false;
Content castOther = (Content) other;
return new EqualsBuilder()
.append(this.getContentId(), castOther.getContentId())
.append(this.getContent(), castOther.getContent())
.append(this.getAbstract(), castOther.getAbstract())
.isEquals();
} public int hashCode() {
return new HashCodeBuilder()
.append(getContentId())
.append(getContent())
.append(getAbstract())
.toHashCode();
} /**
* @param list
*/
public void setList(List list) {
// TODO 自动生成方法存根
}
public List getList(){
return this.list;
}
}
content.hbm.xml文件
<?xml version="1.0"?>
<hibernate-mapping><class
name="com.aaok.blog.dto.Content"
table="content"
>
<meta attribute="class-description" inherit="false">
@hibernate.class
table="content"
</meta> <composite-id>
<meta attribute="field-description" inherit="false">
@hibernate.id
generator-class="assigned"
</meta>
<key-property
name="contentId"
column="contentID"
type="java.lang.String"
length="13"
>
<meta attribute="field-description">
@hibernate.property
column="contentID"
</meta>
</key-property>
<key-property
name="content"
column="content"
type="java.lang.String"
length="65535"
>
<meta attribute="field-description">
@hibernate.property
column="content"
</meta>
</key-property>
<key-property
name="abstract"
column="abstract"
type="java.lang.String"
length="65535"
>
<meta attribute="field-description">
@hibernate.property
column="abstract"
</meta>
</key-property>
</composite-id>
<!-- Associations -->
<!-- derived association(s) for compound key -->
<!-- end of derived association(s) -->
</class>
</hibernate-mapping>
解决方案 »
- 异常:Exception creating bean of class form.LoginForm under form name LoginForm
- 咨询标签库开发的者(实际开发过)几个问题
- linux下的编码问题?在线等
- Blog内容显示指定数字的内容问题,请高手帮忙!!!
- 跪求:为什么安装tomcat后无法启动??
- Javascript 如何做到调节纸张的横纵向打印
- 两天了还没弄好,老出错!求教,急……在线等了
- 用Tomcat做web服务器时,遇到的连接池错误
- 问一个最简单的,但大家可能很少用过问题!关于out.print()!
- 【求助】使用ssm实现bug管理系统
- windows下,如何让tomcat在后台执行?
- 救命呀!浏览器不能随便关呀!可是它不听话呀!
添加cglib的jar到类路径