Results 1 to 3 of 3

Thread: findAll() fails with NPE

  1. #1
    Join Date
    Jun 2012
    Posts
    3

    Default findAll() fails with NPE

    Hello,

    I am using Spring Data MongoDB version 1.0.1.RELEASE. I am able to successfully insert objects
    into mongo. I can iterate of the collections. Here is an example of the collection.

    Code:
    > db.institutions.findOne()
    {
    	"_id" : 1048598,
    	"_class" : "org.john.app.domain.AccreditedPostsecondaryInstitution",
    	"OPEID" : 19073024,
    	"IPEDS_UnitID" : 1050166,
    	"campusMap" : {
    		"2" : {
    			"_id" : 2,
    			"name" : "Community College of the Air Force - Sheppard",
    			"address" : "917 Missile Road",
    			"city" : "Sheppard AFB",
    			"us_state" : "TX",
    			"zipCode" : "76311-2263",
    			"type" : "CAMPUS"
    		}
    	},
    	"programSet" : [
    		{
    			"_id" : null,
    			"programName" : "Physical Therapy (PTAA) - Programs for the physical therapist assistant",
    			"agencyName" : "American Physical Therapy Association. Commission on Accreditation in Physical Therapy Education",
    			"initialDate" : ISODate("1976-12-01T08:00:00Z"),
    			"accreditationStatus" : "Accredited",
    			"accreditationDataType" : "Actual"
    		}
    	],
    	"accreditationType" : "SPECIALIZED",
    	"name" : "Community College of the Air Force",
    	"address" : "130 W Maxwell Blvd",
    	"city" : "Montgomery",
    	"us_state" : "AL",
    	"zipCode" : "36112-6613",
    	"website" : {
    		"protocol" : "http",
    		"host" : "www.maxwell.af.mil",
    		"port" : -1,
    		"file" : "/au/ccaf/",
    		"authority" : "www.maxwell.af.mil",
    		"hashCode" : -1
    	},
    	"type" : "UNSPECIFIED"
    }
    However, a variety of calls to the find() family of methods failed. findAll() is the simpliest example

    Code:
    List<AccreditedPostsecondaryInstitution> results = 
    	mongoTemplate.findAll(AccreditedPostsecondaryInstitution.class,"institutions");

    It fails with an NPE in the core libraries(see below ). Unfortunately, my build isn't setup to debug it. Does anyone have an insight into this problem?

    Thanks,
    John

    Exception in thread "main" java.lang.NullPointerException
    at org.springframework.data.mongodb.core.convert.Mapp edConstructor.<init>(MappedConstructor.java:56)
    at org.springframework.data.mongodb.core.convert.Mapp ingMongoConverter.read(MappingMongoConverter.java: 212)
    at org.springframework.data.mongodb.core.convert.Mapp ingMongoConverter.read(MappingMongoConverter.java: 200)
    at org.springframework.data.mongodb.core.convert.Mapp ingMongoConverter.getValueInternal(MappingMongoCon verter.java:713)
    at org.springframework.data.mongodb.core.convert.Mapp ingMongoConverter$1.doWithPersistentProperty(Mappi ngMongoConverter.java:230)
    at org.springframework.data.mongodb.core.convert.Mapp ingMongoConverter$1.doWithPersistentProperty(Mappi ngMongoConverter.java:220)
    at org.springframework.data.mapping.model.BasicPersis tentEntity.doWithProperties(BasicPersistentEntity. java:173)
    at org.springframework.data.mongodb.core.convert.Mapp ingMongoConverter.read(MappingMongoConverter.java: 220)
    at org.springframework.data.mongodb.core.convert.Mapp ingMongoConverter.read(MappingMongoConverter.java: 200)
    at org.springframework.data.mongodb.core.convert.Mapp ingMongoConverter.read(MappingMongoConverter.java: 164)
    at org.springframework.data.mongodb.core.convert.Mapp ingMongoConverter.read(MappingMongoConverter.java: 73)
    at org.springframework.data.mongodb.core.MongoTemplat e$ReadDbObjectCallback.doWith(MongoTemplate.java:1 693)
    at org.springframework.data.mongodb.core.MongoTemplat e.executeFindMultiInternal(MongoTemplate.java:1444 )
    at org.springframework.data.mongodb.core.MongoTemplat e.findAll(MongoTemplate.java:964)
    at org.john.app.InstituteRepository.dump(InstituteRep ository.java:50)
    at org.john.app.InstituteRepository$$FastClassByCGLIB $$7799dab9.invoke(<generated>)
    at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy. java:191)
    at org.springframework.aop.framework.Cglib2AopProxy$C glibMethodInvocation.invokeJoinpoint(Cglib2AopProx y.java:689)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :150)
    at org.springframework.dao.support.PersistenceExcepti onTranslationInterceptor.invoke(PersistenceExcepti onTranslationInterceptor.java:155)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :172)
    at org.springframework.aop.framework.Cglib2AopProxy$D ynamicAdvisedInterceptor.intercept(Cglib2AopProxy. java:622)
    at org.john.app.InstituteRepository$$EnhancerByCGLIB$ $2be4b036.dump(<generated>)
    at org.john.app.ReaperApp.main(ReaperApp.java:49)

  2. #2
    Join Date
    Apr 2006
    Location
    Dresden, Germany
    Posts
    483

    Default

    Would you mind posting the domain class you're trying to map the data onto? Potentially the ones of the nested documents as well? This seems to be a bug so you might wanna raise a JIRA issue containing the classes as well.

    Generally speaking, the error seems to indicate that you have multiple constructors taking parameters for the entity trying to be instantiated but none is annotated with @PersistenceConstructor. While I agree that this situation should be brought to attention in a more discoverable manner it might just solve the problem to annotate either one of the with the @PersistenceConstructor annotation. Please raise a JIRA issue nevertheless.
    Last edited by Oliver Gierke; Jun 19th, 2012 at 10:23 AM.

  3. #3
    Join Date
    Apr 2006
    Location
    Dresden, Germany
    Posts
    483

    Default

    I went ahead and created [0]. Fix is on it's way.

    [0] https://jira.springsource.org/browse/DATAMONGO-461

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •