pepite/Play--framework-Spring-module — Issue #8: Spring plugin error - BeanDefinitionStoreException I/O failure during classpath scanning 
Author: ni-ka
Created: 2011-12-06 17:13:47+00:00
State: open

(this is a copy of https://play.lighthouseapp.com/projects/57987/tickets/1300-spring-plugin-error-beandefinitionstoreexception-io-failure-during-classpath-scanning , check there for the project files I used to get the error)

Hi,

I'm trying to use Neo4j with Play framework (1.2.4) using the spring-data-
neo4j library 2.0 (http://www.springsource.org/spring-data/neo4j).

In order to use the spring-data-neo4j library, I enabled the spring and
maven plugins and copied the dependencies (using the pom.xml from spring-data neo4j examples), copied the
spring context beans to conf/applicationContext.xml. As the beans use
annotations, I enabled classpath scanning and namespace aware parsing using these settings in
application.conf:

play.spring.component-scan=true
play.spring.namespace-aware=true

The application starts but when spring is initialized it gives me the following error:

Listening for transport dt_socket at address: 8000
18:47:10,996 INFO ~ Starting D:\Projects\Danceit\Tests\play\neo4j-
test
18:47:11,004 WARN ~ Declaring modules in application.conf is
deprecated. Use dependencies.yml instead (module.maven)
18:47:11,006 INFO ~ Module maven is available (C:\play-1.2.4\modules
\maven)
18:47:11,008 WARN ~ Declaring modules in application.conf is
deprecated. Use dependencies.yml instead (module.spring)
18:47:11,011 INFO ~ Module spring is available (C:\play-1.2.4\modules
\spring)
18:47:12,209 WARN ~ You're running Play! in DEV mode
18:47:12,387 INFO ~ Listening for HTTP on port 9000 (Waiting a first
request to start) ...
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/D:/Projects/Danceit/Tests/play/
neo4j-test/lib/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl
/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/play-1.2.4/framework/lib/slf4j-
log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinde
r.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an
explanation.
18:47:24,980 INFO ~ JSR-330 'javax.inject.Named' annotation found and
supported for component scanning
18:47:26,408 ERROR ~

@68j1jnc3p
Internal Server Error (500) for request GET /

Oops: BeanDefinitionStoreException
An unexpected error occured caused by exception
BeanDefinitionStoreException: I/O failure during classpath scanning;
nes
ted exception is java.io.FileNotFoundException: D:\Projects\Danceit
\Tests\play\neo4j-test\precompiled\java\controllers\A
pplication.class (Das System kann den angegebenen Pfad nicht finden)

play.exceptions.UnexpectedException: Unexpected Error
at play.Play.start(Play.java:545)
at play.Play.detectChanges(Play.java:618)
at play.Invoker$Invocation.init(Invoker.java:198)
at Invocation.HTTP Request(Play!)
Caused by:
org.springframework.beans.factory.BeanDefinitionStoreException: I/O
failure during classpath scanning; nested
exception is java.io.FileNotFoundException: D:\Projects\Danceit\Tests
\play\neo4j-test\precompiled\java\controllers\Appl
ication.class (Das System kann den angegebenen Pfad nicht finden)
at
play.modules.spring.PlayClassPathBeanDefinitionScanner.findCandidateComponents(PlayClassPathBeanDefinitionSca
nner.java:91)
at
org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.j
ava:204)
at
org.springframework.context.annotation.ClassPathBeanDefinitionScanner.scan(ClassPathBeanDefinitionScanner.jav
a:183)
at
play.modules.spring.SpringPlugin.onApplicationStart(SpringPlugin.java:
93)
at
play.plugins.PluginCollection.onApplicationStart(PluginCollection.java:
480)
at play.Play.start(Play.java:515)
... 3 more
Caused by: java.io.FileNotFoundException: D:\Projects\Danceit\Tests
\play\neo4j-test\precompiled\java\controllers\Applica
tion.class (Das System kann den angegebenen Pfad nicht finden)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.(FileInputStream.java:106)
at
play.modules.spring.PlayClassPathBeanDefinitionScanner.findCandidateComponents(PlayClassPathBeanDefinitionSca
nner.java:67)
... 8 more

I tried to debug the spring plugin and changed the following code:

if (System.clearProperty("precompile") == null) {
File f = Play.getFile("precompiled/java/" + (appClass.name.replace(".", "/")) + ".class");
res = new InputStreamResource(new FileInputStream(f));
} else {
res = new ByteArrayResource(appClass.enhance());
}

to (reversed the condition)

if (System.clearProperty("precompile") != null) {
File f = Play.getFile("precompiled/java/" + (appClass.name.replace(".", "/")) + ".class");
res = new InputStreamResource(new FileInputStream(f));
} else {
res = new ByteArrayResource(appClass.enhance());
}

and now it seems to work fine. But maybe I didnt set up something correctly?

Find attached a project causing the error - I'm glad the error happened right at the beginning so the project is small. You need maven and spring modules.