Announcement Announcement Module
No announcement yet.
findAll() fails with NPE Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • findAll() fails with NPE


    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.

    > db.institutions.findOne()
    	"_id" : 1048598,
    	"_class" : "",
    	"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" : "",
    		"port" : -1,
    		"file" : "/au/ccaf/",
    		"authority" : "",
    		"hashCode" : -1
    	"type" : "UNSPECIFIED"
    However, a variety of calls to the find() family of methods failed. findAll() is the simpliest example

    List<AccreditedPostsecondaryInstitution> results = 

    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?


    Exception in thread "main" java.lang.NullPointerException
    at edConstructor.<init>(
    at 212)
    at 200)
    at ingMongoConverter.getValueInternal(MappingMongoCon
    at ingMongoConverter$1.doWithPersistentProperty(Mappi
    at ingMongoConverter$1.doWithPersistentProperty(Mappi
    at tentEntity.doWithProperties(BasicPersistentEntity. java:173)
    at 220)
    at 200)
    at 164)
    at 73)
    at e$ReadDbObjectCallback.doWith( 693)
    at e.executeFindMultiInternal( )
    at e.findAll(
    at$$FastClassByCGLIB $$7799dab9.invoke(<generated>)
    at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy. java:191)
    at org.springframework.aop.framework.Cglib2AopProxy$C glibMethodInvocation.invokeJoinpoint(Cglib2AopProx
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed( :150)
    at onTranslationInterceptor.invoke(PersistenceExcepti
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed( :172)
    at org.springframework.aop.framework.Cglib2AopProxy$D ynamicAdvisedInterceptor.intercept(Cglib2AopProxy. java:622)
    at$$EnhancerByCGLIB$ $2be4b036.dump(<generated>)

  • #2
    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, 10:23 AM.


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