Play! with "Spring Data - JPA"

225 views
Skip to first unread message

BreuJa

unread,
Oct 13, 2011, 8:27:36 AM10/13/11
to play-framework
Hi all,

I would like to use Play! together with "Spring Data - JPA" (formerly
known as hades)
( http://www.springsource.org/spring-data/jpa )
in addition to the built-in Play! model-support.
I like the idea of having a DAO where I can call
===3<===
User user = userDao.findByEmail(username);
===3<===
instead of having to write
===3<===
User user = User.find("byEmail", username).first();
===3<===

However, I wasn't able to set up a simple testproject according to the
spring-data-jpa-examples-project:
https://github.com/SpringSource/spring-data-jpa-examples

I am using the current spring-module for Play. My dependencies.yml
looks like this:
===3<===
require:
- play
- play -> spring 1.0.2
- org.springframework.data -> spring-data-jpa 1.0.1.RELEASE
repositories:
- jboss:
type: iBiblio
root: "http://eclipse.ialto.com/rt/eclipselink/maven.repo/"
contains:
- org.eclipse.persistence -> *
===3<===

I use a minimal application-context.xml:
===3<===
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://
www.springsource.org/dtd/spring-beans-2.0.dtd">
<beans>

</beans>
===3<===

Then I adapted
https://github.com/SpringSource/spring-data-jpa-examples/blob/master/spring-data-jpa-example/src/test/java/org/springframework/data/jpa/example/repository/UserRepositorySample.java
like this:
http://pastebin.com/g3eBNRAi
So that it yields a minimal Test for use with Play.

When running the test I get NullPointerExceptions in Lines 26 and 38
of the test. It seems as if the autowiring does not work.

When setting "play.spring.component-scan=true" I get a
BeanDefinitionStoreException:
===3<===
Oops: BeanDefinitionStoreException
An unexpected error occured caused by exception
BeanDefinitionStoreException: I/O failure during classpath scanning;
nested exception is java.io.FileNotFoundException: /home/foo/
playframework/springtest/precompiled/java/helpers/CheatSheetHelper
$1.class (File or directory not found)
===3<===
Which makes me wonder because there is no "precompiled" folder inside
my project-directory anyways.

I can't get rid of the feeling that I missed something...

I really hope that it is possible to use Play! together with spring-
data-jpa and that someone could provide a minimal Play!-project using
spring-data-jpa as an example.
Additionally any hint for a possible solution would be greatly
appreciated.

Thanks & Kind regards

digiarnie

unread,
Nov 23, 2011, 6:58:42 PM11/23/11
to play-fr...@googlegroups.com
I've been using the Spring 1.0.1 module for a while now successfully.  I have started a new project and decided to upgrade to 1.0.2.  Setting up the Spring module the same way as my previous project (with scanning), I started seeing the same error that you got:


An unexpected error occured caused by exception
BeanDefinitionStoreException: I/O failure during classpath scanning;
nested exception is java.io.FileNotFoundException: /home/foo/
playframework/springtest/
precompiled/java/helpers/CheatSheetHelper
$1.class (File or directory not found)

I decided to wind back to 1.0.1 in the new project and everything started working.  So I'm assuming either there is an issue with 1.0.2 or there is some new setup required for 1.0.2(??)

Reply all
Reply to author
Forward
0 new messages