MappingException in 3.0.1.RELEASE
monitorjbl opened this issue · 20 comments
I tried updating to 3.0.1.RELEASE today from 3.0.0.RELEASE. I'm unable to use the new version at all due this exception below. I ended up switching back to 3.0.0.RELEASE.
Caused by: org.springframework.data.mapping.model.MappingException: Unknown persistent entity my.class.name
at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:169)
at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:141)
at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:67)
at org.springframework.data.neo4j.repository.query.CypherQueryBuilder.<init>(CypherQueryBuilder.java:37)
at org.springframework.data.neo4j.repository.query.CypherQueryCreator.create(CypherQueryCreator.java:72)
at org.springframework.data.neo4j.repository.query.CypherQueryCreator.create(CypherQueryCreator.java:35)
at org.springframework.data.repository.query.parser.AbstractQueryCreator.createCriteria(AbstractQueryCreator.java:109)
at org.springframework.data.repository.query.parser.AbstractQueryCreator.createQuery(AbstractQueryCreator.java:88)
at org.springframework.data.repository.query.parser.AbstractQueryCreator.createQuery(AbstractQueryCreator.java:73)
at org.springframework.data.neo4j.repository.query.DerivedCypherRepositoryQuery.<init>(DerivedCypherRepositoryQuery.java:59)
at org.springframework.data.neo4j.repository.query.GraphQueryMethod.createQuery(GraphQueryMethod.java:146)
at org.springframework.data.neo4j.repository.GraphRepositoryFactory$1.resolveQuery(GraphRepositoryFactory.java:113)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:304)
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:161)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:224)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:210)
at org.springframework.data.neo4j.repository.GraphRepositoryFactoryBean.afterPropertiesSet(GraphRepositoryFactoryBean.java:69)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1571)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1509)
... 43 more
This class has the @NodeEntity
annotation, so I'm not sure what's going on here. Did something change in the latest version? Do I need to include a different kind of annotation on my model POJOs now?
Is there an upgrade guide for 3.0.1.RELEASE? I am seeing similar issues.
Did you both specificy base-package for your entities in the configuration? It is now mandatory, and what you see is the enabled strict-checking in the MappingContext.
see the blog post: http://blog.neo4j.org/2014/03/spring-data-neo4j-progress-update-sdn-3.html
Yep, that was the problem for me. Put that in my <neo4j:config/>
and everything worked. Thanks Michael!
Not sure if this would be possible, but it would be nice if the exception message was more helpful. The docs for Spring are often hard to deal with; tracking down info for your specific version and combination of components is pretty tough at times.
Unfortunately that exception is generated by SD-Commons. We could only capture that, check he message and re-throw with a better message which also sucks. Actually the base-package attribute is mandatory in the 3.0 xsd but the xsd alias still points to 2.x
Ah, I see. Well, hopefully uncle Google will find this issue if anyone else runs into it :)
I am trying to upgrade and I cannot get past this error at all! below is my current XML set up, I am getting the same error with Java Config
<neo4j:config graphDatabaseService="graphDatabaseService" base-package="com.company.dataservice.entities" />
<neo4j:repositories base-package="com.company.dataservice.repositories" />
<bean id="graphDatabaseService" class="org.springframework.data.neo4j.rest.SpringRestGraphDatabase"
destroy-method="shutdown">
<constructor-arg index="0" value="http://localhost:7474/db/data" />
</bean>
<bean id="neo4jTemplate" class="org.springframework.data.neo4j.support.Neo4jTemplate">
<constructor-arg index="0" ref="graphDatabaseService" />
</bean>
<bean id="neo4jMappingContext" class="org.springframework.data.neo4j.support.mapping.Neo4jMappingContext" />
<bean id="transactionManager" class="org.springframework.data.neo4j.config.JtaTransactionManagerFactoryBean">
<constructor-arg index="0" ref="graphDatabaseService" />
</bean>
<bean id="hibernateExceptionTranslator" class="org.springframework.orm.hibernate4.HibernateExceptionTranslator" />
@scuthbertson Which error are you exactly getting?
Btw. there are not real transactions over REST.
Youu usually don't have to configure the template, mappingcontext or tx-Manager.
Hi @jexp, it was the exact error that @monitorjbl was having, the Unknown persistent entity error.
Ah, OK, thanks for the pointer.
I am upgrading from 2.3.2.RELEASE to 3.0.1.RELEASE and moving from Neo4J 1.9.5 to 2.0.1
I have rolled back to the 3.0.0.RELEASE of Spring Data Neo4J and appear to be having better success.
Cheers for the help.
Don't roll back, it is a feature not a bug. Strict checking would have been enabled in 3.0.0 already if there hadn't been an issue in SD-Commons.
What is the exact error message? Which bean is not found? Is it part of the base-package
that you provide to neo4j:config
?
Hi @jexp
OK, since my last communication, I have reverted back to 3.0.0, and have it in a semi-working state using the Java Config, I just need to update all of our custom Cypher to be Neo4J compliant.
I changed my gradle settings to use SDN 3.0.1.RELEASE and the following error happens:
Caused by: org.springframework.data.mapping.model.MappingException: Unknown persistent entity com.company.dataservice.entities.Member
at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:169)
at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:141)
at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:67)
at org.springframework.data.neo4j.repository.query.CypherQueryBuilder.<init>(CypherQueryBuilder.java:37)
at org.springframework.data.neo4j.repository.query.CypherQueryCreator.create(CypherQueryCreator.java:72)
at org.springframework.data.neo4j.repository.query.CypherQueryCreator.create(CypherQueryCreator.java:35)
at org.springframework.data.repository.query.parser.AbstractQueryCreator.createCriteria(AbstractQueryCreator.java:109)
at org.springframework.data.repository.query.parser.AbstractQueryCreator.createQuery(AbstractQueryCreator.java:88)
at org.springframework.data.repository.query.parser.AbstractQueryCreator.createQuery(AbstractQueryCreator.java:73)
at org.springframework.data.neo4j.repository.query.DerivedCypherRepositoryQuery.<init>(DerivedCypherRepositoryQuery.java:59)
at org.springframework.data.neo4j.repository.query.GraphQueryMethod.createQuery(GraphQueryMethod.java:146)
at org.springframework.data.neo4j.repository.GraphRepositoryFactory$1.resolveQuery(GraphRepositoryFactory.java:113)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:304)
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:161)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:224)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:210)
at org.springframework.data.neo4j.repository.GraphRepositoryFactoryBean.afterPropertiesSet(GraphRepositoryFactoryBean.java:69)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1571)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1509)
My Java Config is (It's identical to my previous XML):
@Configuration
@EnableNeo4jRepositories(basePackageClasses = { Neo4jRepositoryConfig.class },
excludeFilters = { @Filter(Configuration.class) })
@EnableTransactionManagement(mode = AdviceMode.ASPECTJ)
@PropertySource({ "classpath:company.application.properties" })
public class Neo4jRepositoryConfig extends Neo4jConfiguration {
@Resource
private PropertyResolver propResolver;
public Neo4jRepositoryConfig() throws ClassNotFoundException {
setBasePackage("com.company.dataservice.entities", "org.springframework.social.connect.neo4j");
}
@Bean(destroyMethod = "shutdown")
public GraphDatabaseService graphDatabaseService() throws IOException {
return new SpringRestGraphDatabase(propResolver.getRequiredProperty("neo4j.server.url") + "/db/data");
}
@Bean
public Neo4jTemplate neo4jTemplate() throws IOException {
return new Neo4jTemplate((GraphDatabase) graphDatabaseService());
}
@Bean
public Neo4jMappingContext neo4jMappingContext() {
return new Neo4jMappingContext();
}
@Bean
public JtaTransactionManagerFactoryBean transactionManager() throws Exception {
return new JtaTransactionManagerFactoryBean(graphDatabaseService());
}
@Bean
public HibernateExceptionTranslator hibernateExceptionTranslator() {
return new HibernateExceptionTranslator();
}
}
The Member entity is inside my entities package. This config works with SDN 3.0.0.RELEASE as I have said but just that my Cypher does not comply at the moment.
Weird
Can you try it with only one parameter passed to setBasePackage() ? I assume in spring-social there are no @NodeEntity annotated Pojos?
I also saw that there is no base-package on @EnableNeo4jRepositories ?
And as I said there are no transactions over the wire. Just so that you are not surprised by the behavior. Currently I rather recommend going with embedded Neo4j than server if you want to have fun. :)
I have
basePackageClasses = { Neo4jRepositoryConfig.class }
in the @EnableNeo4jRepositories, is this not the same behaviour as
base-package?
There is one POJO with @NodeEntity in there but it is a Jar that I have
control off and is just included into the project.
Trying with just one in there, has the same result. :-(
On 25 March 2014 17:22, Michael Hunger notifications@github.com wrote:
Weird
Can you try it with only one parameter passed to setBasePackage() ? I
assume in spring-social there are no @NodeEntity annotated Pojos?I also saw that there is no base-package on @EnableNeo4jRepositories ?
And as I said there are no transactions over the wire. Just so that you
are not surprised by the behavior. Currently I rather recommend going with
embedded Neo4j than server if you want to have fun. :)Reply to this email directly or view it on GitHubhttps://github.com//issues/161#issuecomment-38594237
.
Would you be able to create a test project that exhibits this behavior?
I can't reproduce it locally.
Thanks!
Hi Michael,
I will have a look at this tomorrow for you.
Cheers,
Steven
On 25 March 2014 18:02, Michael Hunger notifications@github.com wrote:
Would you be able to create a test project that exhibits this behavior?
I can't reproduce it locally.
Thanks!
Reply to this email directly or view it on GitHubhttps://github.com//issues/161#issuecomment-38599211
.
@jexp I was able to produce this error by following the spring.io example
https://github.com/spring-guides/gs-accessing-neo4j-data-rest
Same error as above
Tried the following versions.
spring-data-neo4j:3.0.1.RELEASE -- FAILED
spring-data-neo4j:3.1.0.BUILD-SNAPSHOT --FAILED
spring-data-neo4j:3.0.1.RELEASE --WORKED
@ccit-spence Sent a pull request to that project, you have to add a constructor to the Application that sets the base package:
public Application() {
setBasePackage("hello");
}
Works perfectly now... spring-data-neo4j:3.1.0.BUILD-SNAPSHOT
Hi @jexp, I have been trying to create a project for you that is replicating this issue but I cannot seem to get a project set up that replicates this.
It appears to be something in the setup then of our full project that is throwing this all off. Sorry for the bother.
Closed. Issue out of date.