-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 11 posts ] 
Author Message
 Post subject: java.lang.ClassNotFoundException
PostPosted: Mon Jan 23, 2006 10:36 pm 
Beginner
Beginner

Joined: Mon Dec 05, 2005 2:59 am
Posts: 31
this is the error i got when i click the 'database' icon at hibernate configuration console.

java.lang.ClassNotFoundException: model.User
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:405)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:350)
at org.eclipse.osgi.framework.adaptor.core.AbstractClassLoader.loadClass(AbstractClassLoader.java:78)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:108)
at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:96)
at org.hibernate.tuple.PropertyFactory.getGetter(PropertyFactory.java:166)
at org.hibernate.tuple.PropertyFactory.buildIdentifierProperty(PropertyFactory.java:44)
at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:115)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:412)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:108)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:215)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1154)
at org.hibernate.console.ConsoleConfiguration$2.execute(ConsoleConfiguration.java:265)
at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:35)
at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:68)
at org.hibernate.console.ConsoleConfiguration.buildSessionFactory(ConsoleConfiguration.java:260)
at org.hibernate.eclipse.console.workbench.ConsoleConfigurationWorkbenchAdapter.getChildren(ConsoleConfigurationWorkbenchAdapter.java:24)
at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.fetchDeferredChildren(BasicWorkbenchAdapter.java:70)
at org.eclipse.ui.progress.DeferredTreeContentManager$1.run(DeferredTreeContentManager.java:192)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:76)


i'm using hibernate3.1 and eclipse 3.1. can anyone help????


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 23, 2006 10:47 pm 
Beginner
Beginner

Joined: Mon Dec 05, 2005 2:59 am
Posts: 31
this is my object file.

package model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;


public class User implements Serializable{
private String empNo;
private String firstName;
private String lastName;
private String company;
private String department;
private String designation;
private String extNo;
private List userInfo = new ArrayList();



public String getCompany() {
return company;
}
public void setCompany(String company) {
this.company = company;
}
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
public String getDesignation() {
return designation;
}
public void setDesignation(String designation) {
this.designation = designation;
}

public String getEmpNo() {
return empNo;
}
public void setEmpNo(String empNo) {
this.empNo = empNo;
}
public String getExtNo() {
return extNo;
}
public void setExtNo(String extNo) {
this.extNo = extNo;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public List getUserInfo() {
return userInfo;
}
public void setUserInfo(List userInfo) {
this.userInfo = userInfo;
}
}


and this is my mapping file:

<?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
>
<class
name="model.User"
table="USER"
>

<id
name="empNo"
column="EMP_NO"
type="java.lang.String"
>
<generator class="assigned">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-User.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>

<property
name="firstName"
type="string"
update="true"
insert="true"
>
<column
name="FIRST_NAME"
/>
</property>

<property
name="lastName"
type="string"
update="true"
insert="true"
>
<column
name="LAST_NAME"
/>
</property>

<property
name="company"
type="string"
update="true"
insert="true"
>
<column
name="COMPANY"
/>
</property>

<property
name="department"
type="string"
update="true"
insert="true"
>
<column
name="DEPARTMENT"
/>
</property>

<property
name="designation"
type="string"
update="true"
insert="true"
>
<column
name="DESIGNATION"
/>
</property>

<property
name="extNo"
type="string"
update="true"
insert="true"
>
<column
name="EXT_NO"
/>
</property>

<list
name="userInfo"
lazy="false"
inverse="true"
cascade="none"
>

<key
column="EMP_NO"
>
</key>

<index
column="USER_INFO"
type="string"
/>

<one-to-many
class="model.Service"
/>

</list>


<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-User.xml
containing the additional properties and place it in your merge dir.
-->

</class>

</hibernate-mapping>


what's wrong??? can anyone help me to figure out?? it's urgent.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 23, 2006 10:59 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Looks like a simple bad classpath. Configure it in Project -> Properties.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 23, 2006 11:08 pm 
Beginner
Beginner

Joined: Mon Dec 05, 2005 2:59 am
Posts: 31
sorry coz i can't get what u mean. can u tell me in a clearer way? thanx.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 24, 2006 12:53 am 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Your java VM can't find User.class. Search through the dialogs that configure whichever eclipse plugin you're using; you're looking for a text field called "Class Path" or similar. Type in the name of the directory that contains the "model" directory. If you use different directories for .java files and .class files, it's the one with the .class files that's important.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 24, 2006 3:46 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you need to put the build path of your code in the classpath of the hibernate console configuration. Done when you create the configuration or by right clicking and click Edit.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 24, 2006 4:19 am 
Beginner
Beginner

Joined: Mon Dec 05, 2005 2:59 am
Posts: 31
i finally can see the table in my mysql administrator. now my problem is when i create a jsp to test the data. i failed to do so. after i key in the data, the webpage shows this error:

java.lang.NoClassDefFoundError: model/User
servlet.UserServlet.doPost(UserServlet.java:41)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)



the servlet java file is as shown below:

package servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import model.User;


/**
* Servlet implementation class for Servlet: UserServlet
*
* @web.servlet
* name="UserServlet"
* display-name="UserServlet"
*
* @web.servlet-mapping
* url-pattern="/UserServlet"
*
*/
public class UserServlet extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
/* (non-Java-doc)
* @see javax.servlet.http.HttpServlet#HttpServlet()
*/
public UserServlet() {
super();
}

/* (non-Java-doc)
* @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
}

/* (non-Java-doc)
* @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String title = request.getParameter("title");

model.User user = new model.User();

user.setEmpNo(title);
Object [] args = {user};
Class [] argsType = new Class[]{model.User.class};
Object ob = ejb.EJBInvoker.invokeRemoteEJB("jnp://127.0.0.1:1099",bean.UserBHome.JNDI_NAME,"saveUser",args,argsType);
user = (model.User)ob;

getServletContext().getRequestDispatcher("/default.jsp").forward(request, response);
}
}


i'm using eclipse 3.1 and hibernate 3.1. i create teh UserServlet.java in a package in dynamic web project.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 24, 2006 4:27 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
http://www.hibernate.org/hib_docs/v3/re ... l-firstapp

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Problem in your classpath
PostPosted: Tue Jan 24, 2006 8:37 am 
Newbie

Joined: Tue Nov 29, 2005 6:33 am
Posts: 6
it seems that problem is in your classpath. JVM cant find the model.User.class .

when u are working with jsp please add these classes externally before configure.

-Devarajanp


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 24, 2006 8:22 pm 
Beginner
Beginner

Joined: Mon Dec 05, 2005 2:59 am
Posts: 31
"it seems that problem is in your classpath. JVM cant find the model.User.class .when u are working with jsp please add these classes externally before configure."

how to add these cl"sses externally???


Top
 Profile  
 
 Post subject: Do like this for adding classes externally
PostPosted: Wed Jan 25, 2006 12:28 am 
Newbie

Joined: Tue Nov 29, 2005 6:33 am
Posts: 6
moonny wrote:
"it seems that problem is in your classpath. JVM cant find the model.User.class .when u are working with jsp please add these classes externally before configure."

how to add these cl"sses externally???


Code:
[b]

Configuration cfg = new Configuration()
    .addClass(example.Player.class)
    .addClass(example.Team.class);
SessionFactory factory = cfg.buildSessionFactory();[/b]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 11 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.