I am trying to upgrade the 'spring-data-neo4j' dependency on our project from 2-1-0-M1 version (using neo4j 1.6) to 2.2.0.RELEASE (with neo4j 1.8.1) version. However, when I change the version of spring-data-neo4j dependency, even to 2.1.0.RELEASE, I get the following exception when starting application on Tomcat:
[ERROR] [host-startStop-1] [org.springframework.web.context.ContextLoader:307] - Context initialization failed
org.springframework.data.neo4j.mapping.InvalidEntityTypeException: Type class java.lang.RuntimeException is neither a @NodeEntity nor a @RelationshipEntity
at org.springframework.data.neo4j.support.mapping.Neo4jMappingContext.createPersistentEntity(Neo4jMappingContext.java:56)
at org.springframework.data.neo4j.support.mapping.Neo4jMappingContext.createPersistentEntity(Neo4jMappingContext.java:46)
at org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:269)
at org.springframework.data.neo4j.support.mapping.Neo4jMappingContext.addPersistentEntity(Neo4jMappingContext.java:61)
at org.springframework.data.neo4j.support.mapping.Neo4jMappingContext.addPersistentEntity(Neo4jMappingContext.java:46)
at org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:246)
at org.springframework.data.mapping.context.AbstractMappingContext.initialize(AbstractMappingContext.java:346)
at org.springframework.data.mapping.context.AbstractMappingContext.onApplicationEvent(AbstractMappingContext.java:336)
at org.springframework.data.mapping.context.AbstractMappingContext.onApplicationEvent(AbstractMappingContext.java:69)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:97)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:324)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:929)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:467)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:384)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4887)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5381)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:977)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1655)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
I have also tried to only 'upgrade' the 'spring-data-neo4j' library (and let neo4j on v1.6) and got the exception too. Thus the exception seems to be only related to the spring-data-neo4j library and not neo4j itself.
Has anyone seen this behaviour before, or has any clue why Spring-data-neo4j thinks that RuntimeException should be either NodeEntity or RelationshipEntity?
Unfortunatly, the code is distributed among multiple projects, what makes it difficult to paste a minimum configuration here that causes the problem. Still working on that. Already 'cleaned up' all neo4j entity (and relation) classes and DAO's by removing all annotations and content to be sure that it's not related to any of them. Still, when starting the application the exception arises.
Edit: below is the spring configuration used:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:neo4j="http://www.springframework.org/schema/data/neo4j"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/data/neo4j
http://www.springframework.org/schema/data/neo4j/spring-neo4j-2.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<context:annotation-config />
<context:component-scan base-package="nl.graph" />
<tx:annotation-driven mode="proxy"/>
<bean id="graphDb" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/neo4j/graphDb" />
</bean>
<bean id="graphDatabaseService" class="org.neo4j.kernel.EmbeddedGraphDatabase"
destroy-method="shutdown">
<constructor-arg index="0" ref="graphDb" />
</bean>
<neo4j:config graphDatabaseService="graphDatabaseService" />
<neo4j:repositories base-package="nl.graph.repositories" />
<bean id="neo4jTransactionManager"
class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="transactionManager">
<bean class="org.neo4j.kernel.impl.transaction.SpringTransactionManager">
<constructor-arg index="0" ref="graphDatabaseService" />
</bean>
</property>
<property name="userTransaction">
<bean class="org.neo4j.kernel.impl.transaction.UserTransactionImpl">
<constructor-arg index="0" ref="graphDatabaseService" />
</bean>
</property>
</bean>
</beans>
Edit 21-05: Found the cause, in some application context the following bean was defined:
<bean id="runtimeException" class="java.lang.Class" factory-method="forName">
<constructor-arg value="java.lang.RuntimeException"/>
</bean>
Removing this bean (which was defined for spring-batch's FaultTolerantStepFactoryBean's skippableExceptionClasses property) solved the problem. Somehow this bean was thus found by neo4j component scan?