java.lang.NullPointerException

Spring JIRA | Mohsin Husen | 3 years ago
  1. 0

    I'm trying to store a Map field as part of my persistent entity as follows: @Document(indexName="main", type="account") public class AccountItem { @Id private String id; @Field(type = FieldType.Nested) private Map<Integer, Collection<String>> buckets = new HashMap(); public String getId() { return id; } public void setId(String id) { this.id = id; } public Map<Integer, Collection<String>> getBuckets() { return buckets; } public void setBuckets(Map<Integer, Collection<String>> buckets) { this.buckets = buckets; } } Is something like this possible? The above does not work for me. I have tried with FieldType.Nested, FieldType.Object, and not setting the @Field annotation. I get the following stack trace when calling ElasticsearchTemplate#putMapping(AccountItem.class): java.lang.NullPointerException at org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchPersistentProperty.getFieldName(SimpleElasticsearchPersistentProperty.java:53) at org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchPersistentProperty.isIdProperty(SimpleElasticsearchPersistentProperty.java:58) at org.springframework.data.mapping.model.BasicPersistentEntity.returnPropertyIfBetterIdPropertyCandidateOrNull(BasicPersistentEntity.java:204) at org.springframework.data.mapping.model.BasicPersistentEntity.addPersistentProperty(BasicPersistentEntity.java:178) at org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchPersistentEntity.addPersistentProperty(SimpleElasticsearchPersistentEntity.java:120) at org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchPersistentEntity.addPersistentProperty(SimpleElasticsearchPersistentEntity.java:41) at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.createAndRegisterProperty(AbstractMappingContext.java:459) at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.addPropertiesForRemainingDescriptors(AbstractMappingContext.java:442) at org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:296) at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.createAndRegisterProperty(AbstractMappingContext.java:474) at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.doWith(AbstractMappingContext.java:427) at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:570) at org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:295) at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:181) 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.elasticsearch.core.ElasticsearchTemplate.getPersistentEntityFor(ElasticsearchTemplate.java:695) at org.springframework.data.elasticsearch.core.ElasticsearchTemplate.putMapping(ElasticsearchTemplate.java:130) I only want to persist my key/value pairs from the Map. From debug console, it is barfing on a null Field for 'isEmpty' in Collection: this = {org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator@7180} field = null descriptor = {java.beans.PropertyDescriptor@7181}"java.beans.PropertyDescriptor[name=empty; propertyType=boolean; readMethod=public abstract boolean java.util.Collection.isEmpty()]" entity = {org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchPersistentEntity@7182} simpleTypeHolder = {org.springframework.data.mapping.model.SimpleTypeHolder@5151} Any help is much appreciated! Thanks, Erik

    Spring JIRA | 3 years ago | Mohsin Husen
    java.lang.NullPointerException
  2. 0

    I'm trying to store a Map field as part of my persistent entity as follows: @Document(indexName="main", type="account") public class AccountItem { @Id private String id; @Field(type = FieldType.Nested) private Map<Integer, Collection<String>> buckets = new HashMap(); public String getId() { return id; } public void setId(String id) { this.id = id; } public Map<Integer, Collection<String>> getBuckets() { return buckets; } public void setBuckets(Map<Integer, Collection<String>> buckets) { this.buckets = buckets; } } Is something like this possible? The above does not work for me. I have tried with FieldType.Nested, FieldType.Object, and not setting the @Field annotation. I get the following stack trace when calling ElasticsearchTemplate#putMapping(AccountItem.class): java.lang.NullPointerException at org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchPersistentProperty.getFieldName(SimpleElasticsearchPersistentProperty.java:53) at org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchPersistentProperty.isIdProperty(SimpleElasticsearchPersistentProperty.java:58) at org.springframework.data.mapping.model.BasicPersistentEntity.returnPropertyIfBetterIdPropertyCandidateOrNull(BasicPersistentEntity.java:204) at org.springframework.data.mapping.model.BasicPersistentEntity.addPersistentProperty(BasicPersistentEntity.java:178) at org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchPersistentEntity.addPersistentProperty(SimpleElasticsearchPersistentEntity.java:120) at org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchPersistentEntity.addPersistentProperty(SimpleElasticsearchPersistentEntity.java:41) at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.createAndRegisterProperty(AbstractMappingContext.java:459) at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.addPropertiesForRemainingDescriptors(AbstractMappingContext.java:442) at org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:296) at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.createAndRegisterProperty(AbstractMappingContext.java:474) at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.doWith(AbstractMappingContext.java:427) at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:570) at org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:295) at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:181) 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.elasticsearch.core.ElasticsearchTemplate.getPersistentEntityFor(ElasticsearchTemplate.java:695) at org.springframework.data.elasticsearch.core.ElasticsearchTemplate.putMapping(ElasticsearchTemplate.java:130) I only want to persist my key/value pairs from the Map. From debug console, it is barfing on a null Field for 'isEmpty' in Collection: this = {org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator@7180} field = null descriptor = {java.beans.PropertyDescriptor@7181}"java.beans.PropertyDescriptor[name=empty; propertyType=boolean; readMethod=public abstract boolean java.util.Collection.isEmpty()]" entity = {org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchPersistentEntity@7182} simpleTypeHolder = {org.springframework.data.mapping.model.SimpleTypeHolder@5151} Any help is much appreciated! Thanks, Erik

    Spring JIRA | 3 years ago | Mohsin Husen
    java.lang.NullPointerException
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

  4. 0

    Android: Saving Map State in Google map

    Stack Overflow | 11 months ago | Junie Negentien
    java.lang.RuntimeException: Unable to resume activity {com.ourThesis.junieNegentien2015/com.ourThesis.junieNegentien2015.MainActivity}: java.lang.NullPointerException

    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. java.lang.NullPointerException

      No message provided

      at org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchPersistentProperty.getFieldName()
    2. Spring Data Elasticsearch
      SimpleElasticsearchPersistentProperty.isIdProperty
      1. org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchPersistentProperty.getFieldName(SimpleElasticsearchPersistentProperty.java:53)
      2. org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchPersistentProperty.isIdProperty(SimpleElasticsearchPersistentProperty.java:58)
      2 frames
    3. Spring Data Core
      BasicPersistentEntity.addPersistentProperty
      1. org.springframework.data.mapping.model.BasicPersistentEntity.returnPropertyIfBetterIdPropertyCandidateOrNull(BasicPersistentEntity.java:204)
      2. org.springframework.data.mapping.model.BasicPersistentEntity.addPersistentProperty(BasicPersistentEntity.java:178)
      2 frames
    4. Spring Data Elasticsearch
      SimpleElasticsearchPersistentEntity.addPersistentProperty
      1. org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchPersistentEntity.addPersistentProperty(SimpleElasticsearchPersistentEntity.java:120)
      2. org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchPersistentEntity.addPersistentProperty(SimpleElasticsearchPersistentEntity.java:41)
      2 frames
    5. Spring Data Core
      AbstractMappingContext$PersistentPropertyCreator.doWith
      1. org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.createAndRegisterProperty(AbstractMappingContext.java:459)
      2. org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.addPropertiesForRemainingDescriptors(AbstractMappingContext.java:442)
      3. org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:296)
      4. org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.createAndRegisterProperty(AbstractMappingContext.java:474)
      5. org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.doWith(AbstractMappingContext.java:427)
      5 frames
    6. Spring Core
      ReflectionUtils.doWithFields
      1. org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:570)
      1 frame
    7. Spring Data Core
      AbstractMappingContext.getPersistentEntity
      1. org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:295)
      2. org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:181)
      3. org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:141)
      4. org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:67)
      4 frames
    8. Spring Data Elasticsearch
      ElasticsearchTemplate.putMapping
      1. org.springframework.data.elasticsearch.core.ElasticsearchTemplate.getPersistentEntityFor(ElasticsearchTemplate.java:695)
      2. org.springframework.data.elasticsearch.core.ElasticsearchTemplate.putMapping(ElasticsearchTemplate.java:130)
      2 frames