0
votes

I'm using Grails 2.3.3 for an application which has built successfully.

I'm now incorporating Spring security into the application adding the line in the plugins:

compile ":spring-security-core:2.0-RC5"

As a result I am getting this GrailsContextLoader error relating to transactionManager and sessionfactory - here is the error:

Error | 2017-10-13 12:46:09,299 [localhost-startStop-1] ERROR context.GrailsContextLoader - Error initializing the application: Error creating bean with name 'transactionManagerPostProcessor': 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.MappingException: Association references unmapped class: homevu1.PicturesNWShr Message: Error creating bean with name 'transactionManagerPostProcessor': 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.MappingException: Association references unmapped class: homevu1.PicturesNWShr

PicturesNWShr is one of my domains and there is no problem compiling it if the spring-security plugin is removed.

I have scanned a of related posts although I've not so far found one with an identical problem. But a number are suggesting making modifications to the dependency file in the root folder of the project in order to impose or exclude dependencies from the build.

I would welcome some suggestions?

Here is the domain definition of PicturesNWShr:

package homevu1

import java.util.Date;

class PicturesNWShr {

    static constraints = {
        name()
        filename(blank: true, nullable: true)
        dateCreated()
        caption(blank: true, nullable: true)
        slotType(blank: true, nullable: true)
        groupName(blank: true, nullable: true)
    }

    static mapping = {
        datasource 'publish'
    }

    String name
    String filename
    String caption
    Date dateCreated
    VideoSlotTypeShr slotType
    String groupName // link pictures together for multifile upload 
    // ideal for linking al images of a house together for EAs.
    Date updateDate // The multiple file upload process - checks each instance update is complete 
    // before adding to vidSlot.
    static belongsTo = [userBT: UserShr]


    String toString() {
        "${name}"
    }
}

-mike

1
show us the class in questioninjecteer
@injecteer have added the domain file for PicturesNWShr.mikek
Use the 2.0.0 final version of the plugin org.grails.plugins:spring-security-core:2.0.0saw303
I was side-lined by other app building problem for a few days - gettting back to this problem which is still unresolved. I've tried a variety of versions of spring-security-core from 1.2..7.4 to 2.0.0. all produce the same the unmapped error on class PicturesNWShr. I am using an identical set of versions of plugins in the BuildConfig to successfully build a separate application incorporating spring-security-core. Is there anything I could try regarding the domain class which I have posted in the initial question? All ideas and thoughts are welcome!mikek

1 Answers

0
votes

Having delved further into the Stackoverflow post archive regarding this mapping error - I have determined what the error is.

It's to do with having two separate data sources for my domains and when I extend UserShr which is a foreign key of PicturesNWShr it cannot map this as SecUser, SecRole & SecUserSecRole are in different datasources.

That said I'm not sure how to resolve this at the moment as now I need to 'undo' what s2-quickstart did to my application and ensure that SecUser, SecRole & SecUserRole are placed in the 'publish' datasource as referenced in the above domain class definition.

Will need to explore Stackoverflow further.

-mike