Question

I am using Play Framework 2.2, Hibernate as JPA provider (4.2.8.Final), Spring (4.0.1.RELEASE) and Spring Data JPA (1.4.3.RELEASE).

I am using spring to instantiate to the controllers and using context:component-scan at the application load time to collect and configure all the required dependencies(repositories etc).

The way I have configured spring with play framework is

public class Global extends GlobalSettings {

     private ApplicationContext applicationContext;

     @Override
     public void onStart(Application arg0) {
           String configLocation = Play.application().configuration().getString("spring.context.location");
           applicationContext = new ClassPathXmlApplicationContext(configLocation);
     }

     @Override
     public <A> A getControllerInstance(Class<A> type) throws Exception {
           return applicationContext.getBean(type);
     }

}

and relevant section in application-context.xml is

Everything works extremely good when application loads for the first time. How ever as soon as I make any changes either in views or controllers and application reloads, Spring Data Jpa breaks and complains that my models are not of managed types.

Caused by: java.lang.IllegalArgumentException: Not an managed type: class models.User

Though it is not a problem in general, restarts works fine, I would really appreciate if someone can provide any inputs to reload the applicationContext completely on play reload.

Était-ce utile?

La solution

I've had the same problem. Changing Spring Data JPA 1.4.3.RELEASE to 1.4.2.RELEASE solved it. I didn't have time to look further into the problem, so I don't know what is the cause.

This project is a good starting point: https://github.com/typesafehub/play-spring-data-jpa but it uses 1.3 version of Spring Data JPA.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top