Initialization of bean failed :net.sf.hibernate.MappingException: org.dom4j.DocumentException:

36 views
Skip to first unread message

Jeff Mutonho

unread,
May 30, 2007, 12:58:42 PM5/30/07
to CTJUG...@googlegroups.com
I'm getting the following error message during deployment of an ear file :

org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'mySessionFactory' defined in ServletContext
resource
[/WEB-INF/appcontext/databaseContext.xml]: Initialization of bean
failed; nested exception is net.sf.hibernate.MappingException:
org.dom4j.DocumentException:
Error on line 198 of document : <Line 198, Column 11>: XML-20124:
(Fatal Error) An attribute cannot appear more than once in the same
start tag. Nested exception: <Line 198, Column 11>: XML-20124:
(Fatal Error) An attribute cannot appear more than once in the same
start
tag.


The document databaseContext.xml only ends at line 186, which suggests
the error is coming from elsewhere.

Any ideas?


--

"Don't take the name of root in vain."

Jeff Mutonho
Cape Town
South Africa

GoogleTalk : ejbengine
Skype : ejbengine
Registered Linux user number 366042

James Mc Millan

unread,
May 30, 2007, 1:03:04 PM5/30/07
to CTJUG...@googlegroups.com
It sounds like the error is in one of your hibernate mappingings, you can try looking through all your .hbm.xml's with 198 or more lines...

Jeff Mutonho

unread,
Jun 1, 2007, 4:36:58 AM6/1/07
to CTJUG...@googlegroups.com
On 5/30/07, James Mc Millan <jmcm...@gmail.com> wrote:
> It sounds like the error is in one of your hibernate mappingings, you can
> try looking through all your .hbm.xml's with 198 or more lines...
>

I used XML Spy to validate the generated hbm.xml files and found
out that indeed
one of my hbm.xml , namely Person.hbm.xml , file is failing validation
in XML Spy .The offending part is "unique" attribute which appears
twice in the following entry :
<many-to-one
name="contactDetails"
class="za.co.introspect.portal.ContactDetails"
cascade="save-update"
outer-join="auto"
update="true"
insert="true"
unique="true"
column="contactdetails_id"
not-null="false"
unique="true"
/>

These hbm.xml files are being generated using the xdoclet tool.I'm
using both Ant and Maven to build my application's ear files.The ear
file build by Ant deploys successfully even and the Maven one fails ,
even though they both have the same NOT-WELL formed Person.hbm.xml.
Initially I thought there's a difference in version between the dom4j
jars in the ear files , but both are using the same one ,
dom4j-1.6.1.jar.
How then is it possible that the NOT-WELL formed Person.hbm.xml
passes validation in the Ant generated ear file , but fails in the
Maven generated ear file?What could I be over looking here?

Why is xdoclet generating the two "unique" fields ? The code looks like :

/**
* @return the contact details linked to the person
* @hibernate.many-to-one class="za.co.introspect.portal.ContactDetails"
* cascade="save-update"
* column="contactdetails_id" not-null="false" unique="true"
*/
public ContactDetails getContactDetails() {
return contactDetails;
}

public void setContactDetails(ContactDetails contactDetails) {
this.contactDetails = contactDetails;

}

Bobby Quinne

unread,
Jun 1, 2007, 4:57:19 AM6/1/07
to CTJUG...@googlegroups.com
I've seen this problem. When unique="true" it outputs a duplicate entry. I went and modified the xdoclet template to fix the problem
Reply all
Reply to author
Forward
0 new messages