Question : Problem with hibernate syntax

I am having a problem with my hibernate syntax or at least I think thats the problem. Here is my consoles output,
Initializing AppEngine server
   [WARN] ********************************************************
There is a new version of the SDK available.
-----------
Latest SDK:
Release: 1.3.5
Timestamp: Mon Jun 21 23:21:30 BST 2010
API versions: [1.0]

-----------
Your SDK:
Release: 1.3.2
Timestamp: Wed Mar 17 19:19:29 GMT 2010
API versions: [1.0]

-----------
Please visit http://code.google.com/appengine for the latest SDK.
********************************************************

25-Jul-2010 13:17:13 com.google.apphosting.utils.jetty.JettyLogger info
INFO: Logging to JettyLogger(null) via com.google.apphosting.utils.jetty.JettyLogger
25-Jul-2010 13:17:14 com.google.apphosting.utils.config.AppEngineWebXmlReader readAppEngineWebXml
INFO: Successfully processed C:\Users\Owner\Project\GWTProject\war\WEB-INF/appengine-web.xml
25-Jul-2010 13:17:14 com.google.apphosting.utils.config.AbstractConfigXmlReader readConfigXml
INFO: Successfully processed C:\Users\Owner\Project\GWTProject\war\WEB-INF/web.xml
The server is running at http://localhost:8888/
25-Jul-2010 13:18:18 com.google.appengine.tools.development.ApiProxyLocalImpl log
SEVERE: [1280063898722000] javax.servlet.ServletContext log: Exception while dispatching incoming RPC call
com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract com.dcu.project.dto.GPSDataDTO com.dcu.project.client.DataService.getData()' threw an unexpected exception: java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration
      at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:378)
      at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:581)
      at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:188)
      at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:224)
      at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:713)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
      at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
      at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
      at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:51)
      at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
      at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
      at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
      at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:122)
      at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
      at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
      at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
      at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
      at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
      at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
      at com.google.apphosting.utils.jetty.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:70)
      at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
      at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:349)
      at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
      at org.mortbay.jetty.Server.handle(Server.java:326)
      at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
      at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938)
      at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
      at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
      at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
      at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
      at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration
      at com.dcu.project.server.DatabaseManager.GetEntryFromDB(DatabaseManager.java:13)
      at com.dcu.project.server.DataServiceImpl.getData(DataServiceImpl.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 com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:100)
      at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:562)
      ... 30 more
Caused by: java.lang.ClassNotFoundException: org.hibernate.cfg.Configuration
      at java.net.URLClassLoader$1.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass(IsolatedAppClassLoader.java:151)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      ... 38 more


I have attached the files involved, they are used as server side components of a GWT app.
4 .java files in the attachment.
NMEADATA.JAVA and GPSDATA.JAVA are essentially the same bean. NMEADATA has annotations for use with hibernate GPSDATA does not so it can be sent via RPC for use with GWT client.

DATABASEMANAGER.JAVA handles the database actions. DATASERVIMPL creates a DATABASEMANGER to get data from the database using hibernate. If I hardcode GPSDATADTO as seen in the commented out section of DATASERVIMPL it works so it must be before this the problem lies.

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
DATABASEMANAGER.JAVA

package com.dcu.project.server;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;

import com.dcu.project.model.NMEAData;

public class DatabaseManager {

	public NMEAData GetEntryFromDB() {
		Session session = HibernateUtil.beginTransaction();
		// Comment this next line if you want to stop dropping and recreating tables every execution
		HibernateUtil.recreateDatabase();
		// First create some customer entities using a method we have created
		CreateNMEAData(session, "123456", "789123", 54.32, "N", 8.95, "W", 40, "345678");
		NMEAData data = new NMEAData();
		data = GetData(session);
		HibernateUtil.commitTransaction();
		HibernateUtil.closeSession();
		return data;
	}
	
	/**
	 * This method creates a new Customer entity in the database using the
	 * fields provided as arguments
	 */
	public static void CreateNMEAData(Session session, String Time, 
			String Date, double Latitude, String Lat_Dir, double Longitude, String Long_Dir, double Speed,
			String Course) {
		System.out.println("Creating new data");
		NMEAData gpsdata = new NMEAData();
		gpsdata.setTime(Time);
		gpsdata.setDate(Date);
		gpsdata.setLat(Latitude);
		gpsdata.setLat_Dir(Lat_Dir);
		gpsdata.setLongitude(Longitude);
		gpsdata.setLong_Dir(Long_Dir);
		gpsdata.setSpeed(Speed);
		gpsdata.setCourse(Course);
		session.save(gpsdata);
		System.out.println("NMEA Data Saved!");
	}
	
	
	/**
	 * Final method to print out all of our Customers with all their fields
	 * Demonstrates Retrieval only
	 */
	@SuppressWarnings("unchecked")
	public static void DisplayCustomers(Session session) {
		List alldata = null;
		Query queryResult = session.createQuery("from NMEAData");
		alldata = (List) queryResult.list();
		
		for (int i = 0; i < alldata.size(); i++) {
			NMEAData data = (NMEAData) alldata.get(i);
			System.out.println(data.getID() + ", " + data.getTime());
		}
	}
	public static NMEAData GetData(Session session){

	
	int idVariable = 1;
	// First Retrive the particular customer...let's assume we know the username
	String queryString = "from NMEAData where ID = :ID";
	Query query = session.createQuery(queryString);
	query.setLong("ID", idVariable);
	NMEAData data = (NMEAData) query.uniqueResult();
	System.out.println(data.getID());
	return data;
}
}

DATASERVIMPL.JAVA

package com.dcu.project.server;


import com.dcu.project.client.DataService;
import com.dcu.project.dto.GPSDataDTO;
import com.dcu.project.model.NMEAData;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;

public class DataServiceImpl extends RemoteServiceServlet implements DataService {

	private static final long serialVersionUID = 1L;

public GPSDataDTO getData() {
	
	DatabaseManager a = new DatabaseManager();
	NMEAData data = new NMEAData();
	data = a.GetEntryFromDB();

	System.out.println(data.getLat());
	
	
	GPSDataDTO myData = new GPSDataDTO();
	myData.setID(data.getID());
	myData.setDate(data.getDate());
	myData.setTime(data.getTime());
	myData.setLat(data.getLat());
	myData.setLat_Dir(data.getLat_Dir());
	myData.setLong(data.getLongitude());
	myData.setLong_Dir(data.getLong_Dir());
	myData.setSpeed(data.getSpeed());
	myData.setCourse(data.getCourse());
	
	/*
	myData.setID(1);
	myData.setDate("111111");
	myData.setTime("123456");
	myData.setLat(53.3);
	myData.setLat_Dir("N");
	myData.setLong(-8.9);
	myData.setLong_Dir("W");
	myData.setSpeed(50.2);
	myData.setCourse("123455");
	*/
	
	return myData;
	
  }

}

NMEADATA.JAVA

package com.dcu.project.model;


import java.io.Serializable;
import javax.persistence.*;

@Entity
@Table (name="barrytable")
public class NMEAData implements Serializable {
	
private static final long serialVersionUID = 1L;
protected int ID;
protected String Time;
protected String Date;
protected double Lat;
protected String Lat_Dir;
protected double Longitude;
protected String Long_Dir;
protected double Speed;
protected String Course;

public NMEAData(){
	
}
public NMEAData(int theID, String theTime, String theDate, double theLat, double theLat_Dir,
		double theLongitude, String theLongDir, double theSpeed, String theCourse)
{
	ID = theID;
	Time = theTime;
	Date = theDate;
	Lat = theLat;
	Longitude = theLongitude;
	Long_Dir = theLongDir;
	Speed = theSpeed;
	Course = theCourse;
}
@Id
@GeneratedValue
@Column(name="id")
public int getID() {
	return ID;
}
public void setID(int iD) {
	ID = iD;
}

@Column(length=30)
public String getTime() {
	return Time;
}
public void setTime(String time) {
	Time = time;
}

@Column(length=30)
public String getDate() {
	return Date;
}
public void setDate(String date) {
	Date = date;
}

@Column(length=30)
public double getLat() {
	return Lat;
}
public void setLat(double lat) {
	Lat = lat;
}

@Column(length=30)
public String getLat_Dir() {
	return Lat_Dir;
}
public void setLat_Dir(String latDir) {
	Lat_Dir = latDir;
}

@Column(length=30)
public double getLongitude() {
	return Longitude;
}
public void setLongitude(double longitude) {
	Longitude = longitude;
}

@Column(length=30)
public String getLong_Dir() {
	return Long_Dir;
}
public void setLong_Dir(String longDir) {
	Long_Dir = longDir;
}

@Column(length=30)
public double getSpeed() {
	return Speed;
}
public void setSpeed(double speed) {
	Speed = speed;
}

@Column(length=30)
public String getCourse() {
	return Course;
}
public void setCourse(String course) {
	Course = course;
}


}

GPSDATADTO.JAVA

package com.dcu.project.dto;

import com.google.gwt.user.client.rpc.IsSerializable;

public class GPSDataDTO implements IsSerializable {

private static final long serialVersionUID = 1L;
protected int ID;
protected String myTime;
protected String myDate;
protected double Lat;
protected String Lat_Dir;
protected double myLong;
protected String Long_Dir;
protected double Speed;
protected String Course;

public GPSDataDTO(){
	
}
public GPSDataDTO(int theID, String theTime, String theDate, double theLat, double theLat_Dir,
		double theLongitude, String theLongDir, double theSpeed, String theCourse)
{
	ID = theID;
	myTime = theTime;
	myDate = theDate;
	Lat = theLat;
	myLong = theLongitude;
	Long_Dir = theLongDir;
	Speed = theSpeed;
	Course = theCourse;
}

public int getID() {
	return ID;
}
public void setID(int iD) {
	ID = iD;
}


public String getTime() {
	return myTime;
}
public void setTime(String time) {
	myTime = time;
}


public String getDate() {
	return myDate;
}
public void setDate(String date) {
	myDate = date;
}


public double getLat() {
	return Lat;
}
public void setLat(double lat) {
	Lat = lat;
}


public String getLat_Dir() {
	return Lat_Dir;
}
public void setLat_Dir(String latDir) {
	Lat_Dir = latDir;
}


public double getLongitude() {
	return myLong;
}
public void setLong(double along) {
	myLong = along;
}


public String getLong_Dir() {
	return Long_Dir;
}
public void setLong_Dir(String longDir) {
	Long_Dir = longDir;
}


public double getSpeed() {
	return Speed;
}
public void setSpeed(double speed) {
	Speed = speed;
}


public String getCourse() {
	return Course;
}
public void setCourse(String course) {
	Course = course;
}


}

Answer : Problem with hibernate syntax

where you put your hibernate config file ? your file in not correct path check that !
Random Solutions  
 
programming4us programming4us