Please help. This is driving me crazy at this point.
I have a very simple class and corresponding hbm.xml file. I had it working this morning perfectly. I added a second hbm.xml file to the mix and everything stopped working. I removed the second hbm.xml and reverted back to the original and it now gives me a "Duplicate Class Entity/Mapping" message on the original hbm.xml.
I'm using spring-security-core and spring-security-cas plugins although they seem to have been causing no issues. I am letting GORM handle the Role and User_Role entities and am using hbm for the User because I need to pull data from my legacy DB during authentication.
I happened to look at my plugins directory and see a 'release 1.0.0.M2' entry that I did not install and is are not a part of any of my other projects. I can uninstall it but when I do a run-app it is redownloaded and installed.
I ran clean and then a refresh Grails Dependencies but it did not help.
I am running STS 2.7.1 RELEASE Build 201107091000. (The current Mac OSX dmg downloads that are out there on the STS download page appear to be corrupted). I mention this because I have been getting random 'Cannot resolve class E' error messages in the STS IDE ever since I download and installed STS tar.gz last week springsource-tool-suite-2.7.1.RELEASE-e3.7-macosx-carbon.tar.gz (I tried both the cocoa and carbon dmgs with no success, it opens disk utility instead of installing the app). My old STS install would have an eclipse-groovy update everyday and this one has none. I am wondering if there is an issue with the IDE itself.
Contents of my /grails-app/conf/hibernate/hibernate.cfg.xml:
Contents of the /grails-app/conf/hibernate/Person.hbm.xml:Code:<?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> <mapping resource="Person.hbm.xml" /> </session-factory> </hibernate-configuration>
Here is the /grails-app/domain/edu/conncoll/banner/Person class:Code:<?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="edu.conncoll.banner.Person" table="CC_WRKCRD_PERSON_VW" dynamic-insert="false" dynamic-update="false"> <id name="pidm" column="table_pidm" type="long"><generator class="assigned" /></id> <property name="bannerId" column="table_id" /> <property name="thirdPartyId" column="table_external_user" /> <property name="lastName" column="table_last_name" /> <property name="firstName" column="table_first_name" /> <property name="middleInitial" column="table_mi" /> <property name="preferredName" column="vw_pref_first_name" /> <property name="email" column="table_email_address" /> <joined-subclass name="edu.conncoll.banner.User" table="CC_WRKCRD_USER_VW" dynamic-insert="false" dynamic-update="false"> <key column="pidm" /> <property name="id" column="id" /> <property name="username" column="username" /> <property name="password" column="password" /> <property name="enabled" column="enabled" /> <property name="accountExpired" column="account_expired" /> <property name="accountLocked" column="account_locked" /> <property name="passwordExpired" column="password_expired" /> </joined-subclass> </class> </hibernate-mapping>
Here is the /grails-app/domain/edu/conncoll/banner/User class:Code:package edu.conncoll.banner import java.io.Serializable; class Person implements Serializable { long pidm String bannerId String thirdPartyId String lastName String firstName String middleInitial String preferredName String email static constraints = { bannerId nullable: false, unique: true pidm nullable: false, unique: true thirdPartyId nullable: true, unique: true lastName nullable: false firstName nullable: false middleInitial nullable: true preferredName nullable: true } }
Here is the stack trace:Code:package edu.conncoll.banner class User extends Person implements Serializable { String username String password boolean enabled boolean accountExpired boolean accountLocked boolean passwordExpired static constraints = { username blank: false, unique: true password blank: false } Set<Role> getAuthorities() { UserRole.findAllByUser(this).collect { it.role } as Set } }
Code:Configuring Spring Security ... 2011-08-02 11:21:07,161 [main] ERROR context.GrailsContextLoader - Error executing bootstraps: Error creating bean with name 'messageSource': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.DuplicateMappingException: Duplicate class/entity mapping edu.conncoll.banner.User org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageSource': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.DuplicateMappingException: Duplicate class/entity mapping edu.conncoll.banner.User at org.grails.tomcat.TomcatServer.start(TomcatServer.groovy:164) at grails.web.container.EmbeddableServer$start.call(Unknown Source) at _GrailsRun_groovy$_run_closure5_closure12.doCall(_GrailsRun_groovy:158) at _GrailsRun_groovy$_run_closure5_closure12.doCall(_GrailsRun_groovy) at _GrailsSettings_groovy$_run_closure10.doCall(_GrailsSettings_groovy:280) at _GrailsSettings_groovy$_run_closure10.call(_GrailsSettings_groovy) at _GrailsRun_groovy$_run_closure5.doCall(_GrailsRun_groovy:149) at _GrailsRun_groovy$_run_closure5.call(_GrailsRun_groovy) at _GrailsRun_groovy.runInline(_GrailsRun_groovy:116) at _GrailsRun_groovy.this$4$runInline(_GrailsRun_groovy) at _GrailsRun_groovy$_run_closure1.doCall(_GrailsRun_groovy:59) at RunApp$_run_closure1.doCall(RunApp.groovy:33) at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381) at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415) at gant.Gant$_dispatch_closure7.doCall(Gant.groovy) at gant.Gant.withBuildListeners(Gant.groovy:427) at gant.Gant.this$2$withBuildListeners(Gant.groovy) at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source) at gant.Gant.dispatch(Gant.groovy:415) at gant.Gant.this$2$dispatch(Gant.groovy) at gant.Gant.invokeMethod(Gant.groovy) at gant.Gant.executeTargets(Gant.groovy:590) at gant.Gant.executeTargets(Gant.groovy:589) Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.DuplicateMappingException: Duplicate class/entity mapping edu.conncoll.banner.User ... 23 more Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.DuplicateMappingException: Duplicate class/entity mapping edu.conncoll.banner.User ... 23 more Caused by: org.hibernate.DuplicateMappingException: Duplicate class/entity mapping edu.conncoll.banner.User ... 23 more


Reply With Quote