Bobby
Bobby

Reputation: 594

org.springframework.data.mapping.PropertyReferenceException what do I need to change?

The text of exception says "No property fid found for type" (sic!), I tried to google but got nothing for that. Probably it stands for "feature id", but I'm not sure what's going on with it anyway. How do I fix it? Is there something wrong with my class?

My Attribute class:

@Entity
@Table(name = "LAB3_ATTRIBUTES")
public class Attribute {

@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
@Column(name = "ATTR_ID", length = 10, nullable = false)
private Integer id;

@Column(name = "NAME")
private String name;

@ManyToOne
@JoinColumn(name = "OBJECT_TYPE_ID", referencedColumnName = "OBJECT_TYPE_ID")
private ObjectType objectType;

@OneToMany(mappedBy = "attribute", cascade = CascadeType.ALL)
private List<Parameter> parameters;

public Attribute() {
}

public Attribute(String name, ObjectType objectType) {
    this.name = name;
    this.objectType = objectType;
}

public Integer getId() {
    return id;
}

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

public ObjectType getObjectType() {
    return objectType;
}

public void setObjectType(ObjectType objectType) {
    this.objectType = objectType;
}

public List<Parameter> getParameters() {
    return parameters;
}

public void setParameters(List<Parameter> parameters) {
    this.parameters = parameters;
}
}

My AttributeRepository interface:

public interface AttributeRepository extends JpaRepository<Attribute, Integer > {

    Attribute findById(int id);
    List<Attribute> findByName(String name);
    List<Attribute> fidByObjectType(ObjectType objectType);
}

My AttributeService interface:

public interface AttributeService {
    void save(Attribute attribute);
    Attribute findById(int id);
    List<Attribute> findByName(String name);
    List<Attribute> findByObjectType(ObjectType objectType);
}

My AttributeServiceImpl class:

@Service
public class AttributeServiceImpl implements AttributeService {

    @Autowired
    private AttributeRepository attributeRepository;    

    public void save(Attribute attribute) {
        attributeRepository.save(attribute);
    }
    public Attribute findById(int id) {
        return attributeRepository.findById(id);
    }
    public List<Attribute> findByName(String name) {
        return attributeRepository.findByName(name);
    }
    public List<Attribute> findByObjectType(ObjectType objectType) {
        return attributeRepository.fidByObjectType(objectType);
    }
}

My Exception:

    <15 ìàÿ 2017, 8:49:22,550 AM EEST> <Error> <org.springframework.web.context.ContextLoader> <BEA-000000> <Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'attributeServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.shop.database.repositories.AttributeRepository com.shop.database.services.impl.AttributeServiceImpl.attributeRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'attributeRepository': FactoryBean threw exception on object creation; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property fid found for type com.shop.database.entities.Attribute
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:305)
    Truncated. see log file for complete stacktrace
Caused By: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.shop.database.repositories.AttributeRepository com.shop.database.services.impl.AttributeServiceImpl.attributeRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'attributeRepository': FactoryBean threw exception on object creation; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property fid found for type com.shop.database.entities.Attribute
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:571)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
    Truncated. see log file for complete stacktrace
Caused By: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'attributeRepository': FactoryBean threw exception on object creation; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property fid found for type com.shop.database.entities.Attribute
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:175)
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:103)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1574)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:316)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196)
    Truncated. see log file for complete stacktrace
Caused By: org.springframework.data.mapping.PropertyReferenceException: No property fid found for type com.shop.database.entities.Attribute
    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:353)
    at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:353)
    Truncated. see log file for complete stacktrace
> 
<15 ìàÿ 2017, 8:49:22,561 AM EEST> <Warning> <HTTP> <BEA-101162> <User defined listener org.springframework.web.context.ContextLoaderListener failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'attributeServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.shop.database.repositories.AttributeRepository com.shop.database.services.impl.AttributeServiceImpl.attributeRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'attributeRepository': FactoryBean threw exception on object creation; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property fid found for type com.shop.database.entities.Attribute.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'attributeServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.shop.database.repositories.AttributeRepository com.shop.database.services.impl.AttributeServiceImpl.attributeRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'attributeRepository': FactoryBean threw exception on object creation; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property fid found for type com.shop.database.entities.Attribute
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:305)
    Truncated. see log file for complete stacktrace
Caused By: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.shop.database.repositories.AttributeRepository com.shop.database.services.impl.AttributeServiceImpl.attributeRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'attributeRepository': FactoryBean threw exception on object creation; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property fid found for type com.shop.database.entities.Attribute
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:571)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
    Truncated. see log file for complete stacktrace
Caused By: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'attributeRepository': FactoryBean threw exception on object creation; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property fid found for type com.shop.database.entities.Attribute
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:175)
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:103)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1574)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:316)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196)
    Truncated. see log file for complete stacktrace
Caused By: org.springframework.data.mapping.PropertyReferenceException: No property fid found for type com.shop.database.entities.Attribute
    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:353)
    at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:353)
    Truncated. see log file for complete stacktrace
> 
<15 ìàÿ 2017, 8:49:22,608 AM EEST> <Warning> <EclipseLink> <BEA-2005000> <2017-05-15 08:49:22.592--No partition instance associated with current SessionManager instance.> 
<15 ìàÿ 2017, 8:49:22,614 AM EEST> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID "4217989485440" for task "0" on [partition-name: DOMAIN]. Error is: "weblogic.application.ModuleException: org.springframework.data.mapping.PropertyReferenceException: No property fid found for type com.shop.database.entities.Attribute"
weblogic.application.ModuleException: org.springframework.data.mapping.PropertyReferenceException: No property fid found for type com.shop.database.entities.Attribute
    at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:140)
    at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)
    at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:233)
    at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:228)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:45)
    Truncated. see log file for complete stacktrace
Caused By: org.springframework.data.mapping.PropertyReferenceException: No property fid found for type com.shop.database.entities.Attribute
    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:353)
    at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:353)
    Truncated. see log file for complete stacktrace
> 
<15 ìàÿ 2017, 8:49:22,618 AM EEST> <Error> <Deployer> <BEA-149202> <Encountered an exception while attempting to commit the 9 task for the application "packear_ear" on [partition-name: DOMAIN].> 
<15 ìàÿ 2017, 8:49:22,662 AM EEST> <Warning> <Deployer> <BEA-149004> <Failures were detected while initiating deploy task for application "packear_ear".> 
<15 ìàÿ 2017, 8:49:22,663 AM EEST> <Warning> <Deployer> <BEA-149078> <Stack trace for message 149004
weblogic.application.ModuleException: org.springframework.data.mapping.PropertyReferenceException: No property fid found for type com.shop.database.entities.Attribute:org.springframework.data.mapping.PropertyReferenceException:No property fid found for type com.shop.database.entities.Attribute
    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:353)
    at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:353)
    Truncated. see log file for complete stacktrace

Upvotes: 0

Views: 484

Answers (1)

Jens Schauder
Jens Schauder

Reputation: 82008

You have a typo in this line:

List<Attribute> fidByObjectType(ObjectType objectType);

It should be

List<Attribute> findByObjectType(ObjectType objectType);

Due to the typo, Spring Data is looking for a property named "fid", which of course does not exist.

Upvotes: 1

Related Questions