• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to use Hibernate along with GWT instantiation on eclipse 3.2

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Everybody,
i am making a web application which is based on GWT instantiation.. at server end i want to use hibernate for accessing database but when i run it on eclipse 3.2 having GWT instantiation plug in(after writing all the code of client side and server side including use of hibernate)it is giving this error

Error is org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml

which comes for these lines in the server side code


SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
Session session =sessionFactory.openSession();
Manager manager = new Manager(session);
user=manager.searchUser(username);

where user is object of database entity and manager is the class which access the database ...

my hibernate.cfg.xml is as following

///////////////////////////////

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.url">
jdbc:mysql://localhost:3306/test
</property>
<property name="connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="connection.username">
root
</property>
<property name="connection.password">
dexter
</property>
<!-- Set AutoCommit to true -->
<property name="connection.autocommit">
true
</property>
<!-- SQL Dialect to use. Dialects are database specific -->
<property name="dialect">
org.hibernate.dialect.MySQLDialect
</property>
<!-- Mapping files -->
<mapping resource="com/visualbuilder/hibernate/User.hbm.xml" />
</session-factory>
</hibernate-configuration>

///////////////////////////////

what i think that when i run this as GWT application on eclipse 3.2 it is giving this error due to absence of hibernate lib at server end i am not so clear...
if somebody will help me i will be thankful to him...
please reply soonn....
 
Ranch Hand
Posts: 364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by sudhansu goyal:

Error is org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml



This message means that something is wrong with the hibernate.cfg.xml configuration file.
Are there any other messages in the exception stack that point more precisely to what went wrong?
 
sudhansu goyal
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No there is only single exception that a written previously...
i have used try catch on the code written above session etc..
i think it is due to because server does not find hibernate library at its end
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmm. You are probably hidding some of the stacktrace; stacetraces in Java are never one-liners. It unlikely to be down to a missing library, there is a specific error (NoClassDefFoundError) for that sort of issue. Edvins has called it right I think, there is something wrong with your hibernate.cfg.xml. Looking at it though it loks like valid XML and appears to conform to the DTD. Is User.hbm.xml valid and deployed to the correct place?
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Along with Paul's thoughts, is your hibernate.cfg.xml file located at the base of your classpath?

Mark
 
sudhansu goyal
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this is my User.hbm.xml

///////////



<?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="com.visualbuilder.hibernate.User" table="details" >
<id name="User_Name" type="java.lang.String" column="User_Name" >
</id>
<property name="Password" type="java.lang.String" column="Password" length="45" />

</class>

</hibernate-mapping>

///////////

this file ismapping a table details having two columns User_Name and Password both are of type varchar and User_Name is primary key of the database...
my directory structure is as following----

innvu is the GWT project name that a make on eclipse 3.2

innvy
src (folder)
com.innvy.home.register (package)
public (folder)
register.gwt.xml
com.innvy.home.register.client (package)
register.java
registerService.java
registerServiceAsync.java
com.innvy.home.register.server (package)
registerServiceImpl.java
com.visualbuilder.hibernate (package)
User.java
User.hbm.xml
com.visualbuilder.hibernate.client (package)
Manager.java

hibernate.cfg.xml
web.xml
Hibernate_library (Library for hibernate)
Mysql_Library (Library for mysql dbms)
Jre_system_library (Library for jdk)
Gwt library (Library for gwt designer)

i am mapping the User entity in User.java and User.hbm.xml..
the error that i told you was coming when i dont add mysql mibrary in my project..
but when i add it also in my project the error is coming

//////////////////////////////////////

[ERROR] Failure to load module 'com.innvy.home.register.register'
java.lang.NoSuchMethodError: org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.kind()I
at com.google.gwt.dev.jdt.TypeOracleBuilder.isInterface(TypeOracleBuilder.java:481)
at com.google.gwt.dev.jdt.TypeOracleBuilder.processType(TypeOracleBuilder.java:531)
at com.google.gwt.dev.jdt.TypeOracleBuilder.access$000(TypeOracleBuilder.java:93)
at com.google.gwt.dev.jdt.TypeOracleBuilder$2.visit(TypeOracleBuilder.java:410)
at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:1007)
at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse(CompilationUnitDeclaration.java:305)
at com.google.gwt.dev.jdt.TypeOracleBuilder.build(TypeOracleBuilder.java:395)
at com.google.gwt.dev.cfg.ModuleDef.getTypeOracle(ModuleDef.java:294)
at com.google.gwt.dev.cfg.ModuleDef.refresh(ModuleDef.java:359)
at com.google.gwt.dev.cfg.ModuleDefLoader.loadFromClassPath(ModuleDefLoader.java:86)


//////////////////////////////////////

i want to implement GWT RPC and simultaneously want to access database at server side(registerServiceImpl.java) using hibernate.. i think now a make clear almost of my project.. if somebody could help me the i will be thankful to him..
 
sudhansu goyal
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Directory Structure is as following---

innvy
#--#src (main folder containg all the things)
------com.innvy.home.register (package)
>----------------------public (folder)
>----------------------register.gwt.xml
------com.innvy.home.register.client (package)
>----------------------register.java
>----------------------registerService.java
>----------------------registerServiceAsync.java
------com.innvy.home.register.server (package)
>----------------------registerServiceImpl.java
------com.visualbuilder.hibernate (package)
>----------------------User.java
>----------------------User.hbm.xml
------com.visualbuilder.hibernate.client (package)
>----------------------Manager.java
------hibernate.cfg.xml (file)
------web.xml (filr)
Hibernate_library (Library for hibernate)
Mysql_Library (Library for mysql dbms)
Jre_system_library (Library for jdk)
Gwt library (Library for gwt designer)
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic