org.springframework.data.mapping.PropertyReferenceException: No property service found for type com.fm.ts.domain.finance.ExpenseSpecialInfo

Spring JIRA | Bilguun Bayarmagnai | 3 years ago
  1. 0

    Below is my model. {code:title=Expense.java|borderStyle=solid} public class Expense { @Id private String id; private ExpenseSpecialInfo specialInfo; } {code} I need abstract class for polymorphism {code:title=ExpenseSpecialInfo.java|borderStyle=solid} public abstract class ExpenseSpecialInfo {} {code} {code:title=SupplierPaymentInfo.java|borderStyle=solid} public class SupplierPaymentInfo extends ExpenseSpecialInfo { private StringRef supplierRef; private List<ServicePayment> servicePayments = new ArrayList<ServicePayment>(); } {code} {code:title=ServicePayment.java|borderStyle=solid} public class ServicePayment { private String serviceId; } {code} *Expense* collection data {code:JavaScript} { "_id" : ObjectId("5296ccaa84ae91ce951de079"), "specialInfo" : { "supplierRef" : { "_id" : "1", "text" : "My supp1", }, "servicePayments" : [ { "serviceId" : "1", }, { "serviceId" : "2", } ] } } {code} It runs ok from javascript shell {code:JavaScript} > db.expense.aggregate({$unwind:"$specialInfo.servicePayments"} {code} However from spring data aggregation {code:title=ExpenseDaoTest.java|borderStyle=solid} @Test public void testServiceExpense(){ TypedAggregation<Expense> agg = newAggregation(Expense.class, unwind("specialInfo.servicePayments") ); List<DBObject> result = mongoTemplate.aggregate(agg, DBObject.class).getMappedResults(); assertEquals(2, result.size()); } {code} I result in this exception. Looks like it can not resolve from run-time set class property. If its not a bug, is there a work around? We would really appreciate if there's a solution. Thanks {code} org.springframework.data.mapping.PropertyReferenceException: No property service found for type com.fm.ts.domain.finance.ExpenseSpecialInfo at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:75) at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:327) at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:353) at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:307) at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:290) at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:274) at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:245) at org.springframework.data.mongodb.core.aggregation.TypeBasedAggregationOperationContext.getReference(TypeBasedAggregationOperationContext.java:91) at org.springframework.data.mongodb.core.aggregation.ProjectionOperation$ProjectionOperationBuilder$FieldProjection.renderFieldValue(ProjectionOperation.java:509) at org.springframework.data.mongodb.core.aggregation.ProjectionOperation$ProjectionOperationBuilder$FieldProjection.toDBObject(ProjectionOperation.java:500) at org.springframework.data.mongodb.core.aggregation.ProjectionOperation.toDBObject(ProjectionOperation.java:185) at org.springframework.data.mongodb.core.aggregation.Aggregation.toDbObject(Aggregation.java:228) at org.springframework.data.mongodb.core.MongoTemplate.aggregate(MongoTemplate.java:1296) at org.springframework.data.mongodb.core.MongoTemplate.aggregate(MongoTemplate.java:1273) at org.springframework.data.mongodb.core.MongoTemplate.aggregate(MongoTemplate.java:1262) at com.fm.ts.dao.ExpenseDaoTest.testServiceExpense(ExpenseDaoTest.java:50) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.lang.reflect.Method.invoke(Method.java:606) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.lang.reflect.Method.invoke(Method.java:606) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:88) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) {code}

    Spring JIRA | 3 years ago | Bilguun Bayarmagnai
    org.springframework.data.mapping.PropertyReferenceException: No property service found for type com.fm.ts.domain.finance.ExpenseSpecialInfo
  2. 0

    Below is my model. {code:title=Expense.java|borderStyle=solid} public class Expense { @Id private String id; private ExpenseSpecialInfo specialInfo; } {code} I need abstract class for polymorphism {code:title=ExpenseSpecialInfo.java|borderStyle=solid} public abstract class ExpenseSpecialInfo {} {code} {code:title=SupplierPaymentInfo.java|borderStyle=solid} public class SupplierPaymentInfo extends ExpenseSpecialInfo { private StringRef supplierRef; private List<ServicePayment> servicePayments = new ArrayList<ServicePayment>(); } {code} {code:title=ServicePayment.java|borderStyle=solid} public class ServicePayment { private String serviceId; } {code} *Expense* collection data {code:JavaScript} { "_id" : ObjectId("5296ccaa84ae91ce951de079"), "specialInfo" : { "supplierRef" : { "_id" : "1", "text" : "My supp1", }, "servicePayments" : [ { "serviceId" : "1", }, { "serviceId" : "2", } ] } } {code} It runs ok from javascript shell {code:JavaScript} > db.expense.aggregate({$unwind:"$specialInfo.servicePayments"} {code} However from spring data aggregation {code:title=ExpenseDaoTest.java|borderStyle=solid} @Test public void testServiceExpense(){ TypedAggregation<Expense> agg = newAggregation(Expense.class, unwind("specialInfo.servicePayments") ); List<DBObject> result = mongoTemplate.aggregate(agg, DBObject.class).getMappedResults(); assertEquals(2, result.size()); } {code} I result in this exception. Looks like it can not resolve from run-time set class property. If its not a bug, is there a work around? We would really appreciate if there's a solution. Thanks {code} org.springframework.data.mapping.PropertyReferenceException: No property service found for type com.fm.ts.domain.finance.ExpenseSpecialInfo at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:75) at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:327) at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:353) at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:307) at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:290) at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:274) at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:245) at org.springframework.data.mongodb.core.aggregation.TypeBasedAggregationOperationContext.getReference(TypeBasedAggregationOperationContext.java:91) at org.springframework.data.mongodb.core.aggregation.ProjectionOperation$ProjectionOperationBuilder$FieldProjection.renderFieldValue(ProjectionOperation.java:509) at org.springframework.data.mongodb.core.aggregation.ProjectionOperation$ProjectionOperationBuilder$FieldProjection.toDBObject(ProjectionOperation.java:500) at org.springframework.data.mongodb.core.aggregation.ProjectionOperation.toDBObject(ProjectionOperation.java:185) at org.springframework.data.mongodb.core.aggregation.Aggregation.toDbObject(Aggregation.java:228) at org.springframework.data.mongodb.core.MongoTemplate.aggregate(MongoTemplate.java:1296) at org.springframework.data.mongodb.core.MongoTemplate.aggregate(MongoTemplate.java:1273) at org.springframework.data.mongodb.core.MongoTemplate.aggregate(MongoTemplate.java:1262) at com.fm.ts.dao.ExpenseDaoTest.testServiceExpense(ExpenseDaoTest.java:50) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.lang.reflect.Method.invoke(Method.java:606) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.lang.reflect.Method.invoke(Method.java:606) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:88) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) {code}

    Spring JIRA | 3 years ago | Bilguun Bayarmagnai
    org.springframework.data.mapping.PropertyReferenceException: No property service found for type com.fm.ts.domain.finance.ExpenseSpecialInfo
  3. 0

    How to perform Sum on a Map Key in the Mongo DB document within Spring

    Stack Overflow | 2 years ago | Puneet Pal
    org.springframework.data.mapping.PropertyReferenceException: No property work found for type java.lang.String at org.springframework.data.mapping.PropertyPath.&lt;init&gt;(PropertyPath.java:75)
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    How to write Spring Data method name to retrieve all elements in a column?

    Stack Overflow | 3 years ago | m3th0dman
    org.springframework.data.mapping.PropertyReferenceException: No property find found for type Trade at org.springframework.data.mapping.PropertyPath.&lt;init&gt;(PropertyPath.java:75)
  6. 0

    Autowired JpaRepository is always null

    Stack Overflow | 3 years ago | Vineet
    org.springframework.data.mapping.PropertyReferenceException: No property find found for type com.myclassregister.model.base.misc.School at org.springframework.data.mapping.PropertyPath.&lt;init&gt;(PropertyPath.java:75)

  1. Malcshour 2 times, last 6 months ago
1 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. org.springframework.data.mapping.PropertyReferenceException

    No property service found for type com.fm.ts.domain.finance.ExpenseSpecialInfo

    at org.springframework.data.mapping.PropertyPath.<init>()
  2. Spring Data Core
    PropertyPath.from
    1. org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:75)
    2. org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:327)
    3. org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:353)
    4. org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:307)
    5. org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:290)
    6. org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:274)
    7. org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:245)
    7 frames
  3. Spring Data MongoDB - Core
    MongoTemplate.aggregate
    1. org.springframework.data.mongodb.core.aggregation.TypeBasedAggregationOperationContext.getReference(TypeBasedAggregationOperationContext.java:91)
    2. org.springframework.data.mongodb.core.aggregation.ProjectionOperation$ProjectionOperationBuilder$FieldProjection.renderFieldValue(ProjectionOperation.java:509)
    3. org.springframework.data.mongodb.core.aggregation.ProjectionOperation$ProjectionOperationBuilder$FieldProjection.toDBObject(ProjectionOperation.java:500)
    4. org.springframework.data.mongodb.core.aggregation.ProjectionOperation.toDBObject(ProjectionOperation.java:185)
    5. org.springframework.data.mongodb.core.aggregation.Aggregation.toDbObject(Aggregation.java:228)
    6. org.springframework.data.mongodb.core.MongoTemplate.aggregate(MongoTemplate.java:1296)
    7. org.springframework.data.mongodb.core.MongoTemplate.aggregate(MongoTemplate.java:1273)
    8. org.springframework.data.mongodb.core.MongoTemplate.aggregate(MongoTemplate.java:1262)
    8 frames
  4. com.fm.ts
    ExpenseDaoTest.testServiceExpense
    1. com.fm.ts.dao.ExpenseDaoTest.testServiceExpense(ExpenseDaoTest.java:50)
    1 frame
  5. Java RT
    Method.invoke
    1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    2. java.lang.reflect.Method.invoke(Method.java:606)
    3. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    4. java.lang.reflect.Method.invoke(Method.java:606)
    4 frames
  6. Spring TestContext
    SpringJUnit4ClassRunner.run
    1. org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
    2. org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
    3. org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
    4. org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
    5. org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:88)
    6. org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
    7. org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
    8. org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
    8 frames
  7. JUnit4 Runner
    JUnit4TestReference.run
    1. org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    1 frame
  8. JUnit3 Runner
    RemoteTestRunner.main
    1. org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    2. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    3. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    4. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    5. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
    5 frames