Announcement Announcement Module
No announcement yet.
"Failed to load ApplicationContext" when using repository data access layer Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • "Failed to load ApplicationContext" when using repository data access layer


    I'm trying to build up a small app using roo. Here is the roo script:

    // Spring Roo 1.2.0.RELEASE [rev 39eb957] log opened at 2012-01-06 13:22:07
    project --topLevelPackage de.mygasoline
    jpa setup --provider HIBERNATE --database HYPERSONIC_IN_MEMORY  
    entity jpa --class ~.domain.Fuel --abstract --activeRecord false
    field string --fieldName Name --sizeMin 3 --sizeMax 50
    entity jpa --class ~.domain.Gasoline --extends ~.domain.Fuel --activeRecord false --testAutomatically 
    field number --type int --fieldName oktan --min 0 --max 100
    entity jpa --class ~.domain.Diesel --extends ~.domain.Fuel --activeRecord false --testAutomatically 
    field number --type int --min 0 --max 100 --fieldName cetan
    entity jpa --class ~.domain.Address --activeRecord false
    field string --fieldName street --sizeMax 50 --sizeMin 3 --notNull 
    field string --fieldName city --sizeMax 50 --sizeMin 3 --notNull 
    field string --fieldName country --sizeMax 50 --sizeMin 3 --notNull 
    field string --fieldName department --sizeMax 50 --sizeMin 3 --notNull 
    field string --fieldName zip --sizeMax 10 --sizeMin 3 --notNull 
    entity jpa --class ~.domain.AbstractPetrolStation --abstract --activeRecord false
    field other --type ~.domain.Address --fieldName address --notNull 
    entity jpa --class ~.domain.FreePetrolStation --extends ~.domain.AbstractPetrolStation --activeRecord false --testAutomatically
    entity jpa --class ~.domain.PetrolCompany --activeRecord false --testAutomatically
    field string --fieldName name --sizeMin 3 --sizeMax  50
    entity jpa --class ~.domain.PetrolStation --activeRecord false --testAutomatically
    field reference --type ~.domain.PetrolCompany --fieldName company --notNull
    entity jpa --class ~.domain.Price --activeRecord false --testAutomatically
    field number --fieldName amount --type float --min 0
    field other --fieldName currency --type java.util.Currency --notNull
    entity jpa --class ~.domain.FuelEntry --activeRecord false --testAutomatically
    field date --fieldName lastUpdate --type java.util.Date --notNull 
    field reference --type ~.domain.Price --fieldName price --notNull
    field reference --fieldName fuel --type ~.domain.Fuel --notNull
    repository jpa --interface ~.repository.GasolineRepository --entity ~.domain.Gasoline
    repository jpa --interface ~.repository.DieselRepository --entity ~.domain.Diesel
    repository jpa --interface ~.repository.FuelEntryRepository --entity ~.domain.FuelEntry
    repository jpa --interface ~.repository.FreePetrolStationRepository --entity ~.domain.FreePetrolStation
    repository jpa --interface ~.repository.PetrolCompanyRepository --entity ~.domain.PetrolCompany
    repository jpa --interface ~.repository.PetrolStationRepository --entity ~.domain.PetrolStation
    perform eclipse
    When I imported the project to eclipse I ran into problems: roo (1.2.0.RELEASE [rev 39eb957]) generated an incompartible applicationContext-jpa.xml. It seems that spring-data-jpa-1.0.2 is not compartible to spring-core-3.1.0. Eclipse will show you some strange XSD validation errors. So I modified my pom.xml to use Spring 3.0.0 and everything seemed to work fine. But when I run perform tests on my project nothing seems to work and I do not have a clue why. I'm getting "Failed to laod ApplicationContext" on 54 of 55 tests.

    I checked the AspectJ test configuration and it configures the applicationContext correctly:
    @ContextConfiguration(locations = "classpath:/META-INF/spring/applicationContext*.xml");
    Does anybody have an idea what I am missing?


  • #2
    Are you using STS or regular Eclipse? So far I've only had luck getting my projects to work properly in STS so would recommend using that instead, at least in the beginning to get things going.


    • #3
      I'm kind of using STS. In fact I downloaded eclipse 3.7.1 and installed STS features from the marketplace. Unfortunately the STS feature installed a version AJDT that was incompartible to eclipse Indigo. So I had to manually remove AJDT and reinstall the correct version. But that is just a side info :-)

      I have re-startet my project using plain spring, because I couldn't get roo to work and I ran into similar problems. But this time I was able to fix those, because they were not hidden in the depth of generated aspects. I can not recall every single problem and the solution, but as far as I can tell you have to be very cautions that your framework versions will work together. For example hibernate-jpa-3.5.4-Final will NOT work with spring release 3.0.0 (you will get some AbstractMethodError). You will have to use release 3.0.1.

      For those how are quite new to spring and are facing similar problems I can just recommend to look at the root cause of your exception (don't get confused by "Failed to load ApplicationContext"). If you will see NoClassDefFound oder AbstractMethod execptions, try to search your workspace for the mentioned classes. It is likely, that you are using incompartible libraries.