-->
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.  [ 13 posts ] 
Author Message
 Post subject: plsssssss help me with this error
PostPosted: Wed Mar 14, 2007 3:31 am 
Newbie

Joined: Sun Mar 04, 2007 9:41 pm
Posts: 15
Location: SIN
i am getting this error. m not able to resolve it.
please help me
I am using java 6, eclipse 3.2, hibernate 3.2
have created bean class for user, mapping files and config file.
I am using now swing to invoke bean class and to store user data in database but getting this error at runtime.



log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "AWT-EventQueue-0" org.hibernate.InvalidMappingException: Could not parse mapping document from resource user.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:569)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1587)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1555)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1534)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1508)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1428)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1414)
at UserCreation.actionPerformed(UserCreation.java:98)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6038)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3260)
at java.awt.Component.processEvent(Component.java:5803)
at java.awt.Container.processEvent(Container.java:2058)
at java.awt.Component.dispatchEventImpl(Component.java:4410)
at java.awt.Container.dispatchEventImpl(Container.java:2116)
at java.awt.Component.dispatchEvent(Component.java:4240)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
at java.awt.Container.dispatchEventImpl(Container.java:2102)
at java.awt.Window.dispatchEventImpl(Window.java:2429)
at java.awt.Component.dispatchEvent(Component.java:4240)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from input stream
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:508)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:566)
... 32 more
Caused by: org.dom4j.DocumentException: Error on line 25 of document : Element type "property" must be followed by either attribute specifications, ">" or "/>". Nested exception: Element type "property" must be followed by either attribute specifications, ">" or "/>".
at org.dom4j.io.SAXReader.read(SAXReader.java:482)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:499)
... 33 more


Top
 Profile  
 
 Post subject: Re: plsssssss help me with this error
PostPosted: Wed Mar 14, 2007 4:56 am 
Newbie

Joined: Tue Mar 13, 2007 4:15 am
Posts: 12
Location: Trivandrum
pls send the hbm file and the pojo

_________________
Regards
Belto


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 14, 2007 5:42 am 
Newbie

Joined: Sun Mar 04, 2007 9:41 pm
Posts: 15
Location: SIN
pojo class:


import java.util.Date;

public class User {

/**public void setName(String name) {
/** identifier field */

private String userId;
/** persistent field */

private String userName;
/** persistent field */

private String userPassword;
/** persistent field */

private String userFirstName;
/** persistent field */

private String userLastName;
/** persistent field */

private String userAddress;
/** persistent field */

private String city;
/** persistent field */

private String zipCode;
/** persistent field */

private String contactNo;
/** persistent field */

private String userEmail;
/** persistent field */

private Date userCreationDate;
/** persistent field */

private String userSal;
/** persistent field */

public User(String userId, String userName, String userPassword, String userFirstName,
String userLastName, String userAddress, String city, String zipCode,
String contactNo, String userEmail, Date userCreationDate, String userSal){

this.userId = userId;
this.userName = userName;
this.userPassword = userPassword;
this.userFirstName = userFirstName;
this.userLastName = userLastName;
this.userAddress = userAddress;
this.city = city;
this.zipCode = zipCode;
this.contactNo = contactNo;
this.userEmail = userEmail;
this.userCreationDate = userCreationDate;
this.userSal = userSal;

}

/** default constructor */
public User() {
}

public String getUserId() {
return this.userId;
}

public void setUserId(String userId) {
this.userId = userId;
}

public String getUserName() {
return this.userName;
}

public void setUserName(String userName) {
this.userName = userName;
}

public String getUserPassword() {
return this.userPassword;
}

public void setUserPassword(String userPassword) {
this.userPassword = userPassword;
}

public String getUserFirstName() {
return this.userFirstName;
}

public void setUserFirstName(String userFirstName) {
this.userFirstName = userFirstName;
}

public String getUserLastName() {
return this.userLastName;
}

public void setUserLastName(String userLastName) {
this.userLastName = userLastName;
}

public String getUserAddress(){
return this.userAddress;
}

public void setUserAddress(String userAddress){
this.userAddress = userAddress;
}

public String getCity(){
return this.city;
}

public void setCity(String city){
this.city = city;
}

public String getZipCode(){
return this.zipCode;
}

public void setZipCode(String zipCode){
this.zipCode = zipCode;
}

public String getContactNo(){
return this.contactNo;
}

public void setContactNo(String contactNo){
this.contactNo = contactNo;
}

public String getUserEmail() {
return this.userEmail;
}

public void setUserEmail(String userEmail) {
this.userEmail = userEmail;
}

public Date getUserCreationDate() {
return this.userCreationDate;
}

public void setUserCreationDate(Date userCreationDate) {
this.userCreationDate = userCreationDate;
}

public String getUserSal(){
return this.userSal;
}

public void setUserSal(String usersal){
this.userSal = userSal;
}
}

// End of class /**


This is hbm file

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class name="User" table="user">
<id column="user_id" name="userid" type="java.lang.String">

</id>

<property column="user_name"
length="100"
name="userName"
type="java.lang.String"/>
<property column="user_password"
length="50"
name="userPassword"
type="java.lang.String"/>
<property column="user_first_name"
length="100"
name="userFirstName"
type="java.lang.String"/>
<property column="user_last_name"
length="100"
name="userLastName"
type="java.lang.String"/>
<property column="user_address"
length="255"
name="userAddress"
type="java.lang.String"/>
<property column="city"
length="100"
name="city"
type="java.lang.String"/>
<property column="zip_code"
length="100"
name="zipCode"
type="java.lang.String"/>
<property column="contact_no"
length="15"
name="contactNo"
type="java.lang.String"/>
<property column="user_email"
length="100"
name="userEmail"
type="java.lang.String"/>
<property column="user_creation_date"
name="userCreationDate"
type="java.util.Date"/>
<property column="salary"
length="25"
name="userSal"
type="java.lang.String"/>
</class>
</hibernate-mapping>






[code][/code]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 14, 2007 9:33 am 
Regular
Regular

Joined: Mon Jun 12, 2006 5:33 am
Posts: 63
Hi Noem,

your mapping file cannot be parsed. The content of element type "id" is incomplete. It must contain the subelement <generator> where you should specify how hibernate should generate your id.
e.g:
Code:
<id column="user_id" name="userid" type="java.lang.String">
  <generator class="native"/>
</id>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 14, 2007 9:35 pm 
Newbie

Joined: Sun Mar 04, 2007 9:41 pm
Posts: 15
Location: SIN
hi chucky,

Actully earlier i defined this element as:
<id column="user_id" name="user_id" type="java.lang.String">
<generator class="native"/>
</id>
but it was giving some error so i removed it and again today I added this things still it giving error:

log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "AWT-EventQueue-0" org.hibernate.InvalidMappingException: Could not parse mapping document from resource user.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:569)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1587)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1555)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1534)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 15, 2007 4:52 am 
Regular
Regular

Joined: Mon Jun 12, 2006 5:33 am
Posts: 63
hi noem,

the generator is REQUIRED. So what kind of error did you have when it was there? Got the stack trace?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 15, 2007 5:07 am 
Expert
Expert

Joined: Tue Jan 30, 2007 12:45 am
Posts: 283
Location: India
Hi chucky,

It is simple xml parsing error .Instead of Hit and try set log 4j properties for Hibernate.And see log.I could see log4j.properties are missing

_________________
Dharmendra Pandey


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 15, 2007 11:03 am 
Newbie

Joined: Sun Mar 04, 2007 9:41 pm
Posts: 15
Location: SIN
I have set log4j properties already.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 15, 2007 11:50 am 
Regular
Regular

Joined: Mon Jun 12, 2006 5:33 am
Posts: 63
Hi noem,

the logging system has to be initialized somehow, so you don't have the log4j warnings. Something like " BasicConfigurator.configure();" or some more advanced stuff.
But still > what kind of error did you have when <generator> was there? Got the stack trace?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 15, 2007 1:12 pm 
Regular
Regular

Joined: Thu Oct 19, 2006 12:07 pm
Posts: 75
Isn't this quite clear, where the problem is :
Error on line 25 of document : Element type "property" must be followed by either attribute specifications, ">" or "/>".

?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 15, 2007 1:54 pm 
Regular
Regular

Joined: Mon Jun 12, 2006 5:33 am
Posts: 63
Hi xerces8,

1- if the problem was that clear, noem wouldn't be there
2- before pretending your soooo smart, have at least some respect for the one who has the problem and take a look at the posted code and propose your solution instead of posting non sense things aroung and criticizing around. If we are all here, it's because we all want to learn. So there's always someone there who is smarter than us.
3- Take a look at the entire trace (or at least the first lines) before saying strange things.
4- I've checked the mapping file and it is well formed (the lines you have read would that the file is not well-formed). So the problem is coming from somewhere else.... Maybe if we could see the stack trace about the question I asked noem...

chucky
________


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 17, 2007 10:57 am 
Expert
Expert

Joined: Tue Jan 30, 2007 12:45 am
Posts: 283
Location: India
hi chucky

Dude be cool. I can understand your dedication with this forum. I appreciate you for that. I have already check that hbm file in exadel xml editor.

_________________
Dharmendra Pandey


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 19, 2007 7:07 pm 
Newbie

Joined: Mon Mar 19, 2007 6:59 pm
Posts: 1
Hi noem,

is User class in a package? Have you tried to specify the package name for User class in the mapping xml?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 13 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.