java.lang.NullPointerException: null

Spring JIRA | Ondřej Havelka | 9 months ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    Hi, I'm using SpringData JPA Hopper-SR1 and I want to upgrade to Hopper-SR2 but I'm facing NullPointer exception in AbstractStringBasedJpaQuery.isJpaManaged() which in newly introduced in Hopper-SR2 (with Hopper-SR1 everything works fine) I'm using Envers I have entity DonwloadItem which has correspoding table "download_item" {code:java} @Entity @Table(name = "download_item") public class DownloadItem extends BaseVersionEntity { @Audited @NotNull @Size(max = DOWNLOAD_ITEM_NAME_LENGTH) @Column(nullable=false) private String name; .... } {code} but in db there is also envers auditing table "download_item_AUD" which doesn't have corresponding Java Type and thats the problem In method _isJpaManaged()_ is called _managedType.getJavaType()_ that returns null for ManagedType that contains DownloadItem_aud entity Stacktrace: {noformat} java.lang.NullPointerException: null at org.springframework.data.jpa.repository.query.AbstractStringBasedJpaQuery.isJpaManaged(AbstractStringBasedJpaQuery.java:155) ~[spring-data-jpa-1.10.2.RELEASE.jar:na] at org.springframework.data.jpa.repository.query.AbstractStringBasedJpaQuery.createJpaQuery(AbstractStringBasedJpaQuery.java:141) ~[spring-data-jpa-1.10.2.RELEASE.jar:na] at org.springframework.data.jpa.repository.query.AbstractStringBasedJpaQuery.doCreateQuery(AbstractStringBasedJpaQuery.java:80) ~[spring-data-jpa-1.10.2.RELEASE.jar:na] at org.springframework.data.jpa.repository.query.AbstractJpaQuery.createQuery(AbstractJpaQuery.java:176) ~[spring-data-jpa-1.10.2.RELEASE.jar:na] at org.springframework.data.jpa.repository.query.JpaQueryExecution$CollectionExecution.doExecute(JpaQueryExecution.java:114) ~[spring-data-jpa-1.10.2.RELEASE.jar:na] at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:78) ~[spring-data-jpa-1.10.2.RELEASE.jar:na] at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:102) ~[spring-data-jpa-1.10.2.RELEASE.jar:na] at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:92) ~[spring-data-jpa-1.10.2.RELEASE.jar:na] at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:482) ~[spring-data-commons-1.12.2.RELEASE.jar:na] at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:460) ~[spring-data-commons-1.12.2.RELEASE.jar:na] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.2.7.RELEASE.jar:4.2.7.RELEASE] at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:61) ~[spring-data-commons-1.12.2.RELEASE.jar:na] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.2.7.RELEASE.jar:4.2.7.RELEASE] at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) ~[spring-tx-4.2.7.RELEASE.jar:4.2.7.RELEASE] at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281) ~[spring-tx-4.2.7.RELEASE.jar:4.2.7.RELEASE] at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) ~[spring-tx-4.2.7.RELEASE.jar:4.2.7.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.2.7.RELEASE.jar:4.2.7.RELEASE] at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136) ~[spring-tx-4.2.7.RELEASE.jar:4.2.7.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.2.7.RELEASE.jar:4.2.7.RELEASE] at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:133) ~[spring-data-jpa-1.10.2.RELEASE.jar:na] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.2.7.RELEASE.jar:4.2.7.RELEASE] at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) ~[spring-aop-4.2.7.RELEASE.jar:4.2.7.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.2.7.RELEASE.jar:4.2.7.RELEASE] at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208) ~[spring-aop-4.2.7.RELEASE.jar:4.2.7.RELEASE] .... {noformat}

    Spring JIRA | 9 months ago | Ondřej Havelka
    java.lang.NullPointerException: null

    Root Cause Analysis

    1. java.lang.NullPointerException

      null

      at org.springframework.data.jpa.repository.query.AbstractStringBasedJpaQuery.isJpaManaged()
    2. Spring Data JPA
      AbstractJpaQuery.execute
      1. org.springframework.data.jpa.repository.query.AbstractStringBasedJpaQuery.isJpaManaged(AbstractStringBasedJpaQuery.java:155)[spring-data-jpa-1.10.2.RELEASE.jar:na]
      2. org.springframework.data.jpa.repository.query.AbstractStringBasedJpaQuery.createJpaQuery(AbstractStringBasedJpaQuery.java:141)[spring-data-jpa-1.10.2.RELEASE.jar:na]
      3. org.springframework.data.jpa.repository.query.AbstractStringBasedJpaQuery.doCreateQuery(AbstractStringBasedJpaQuery.java:80)[spring-data-jpa-1.10.2.RELEASE.jar:na]
      4. org.springframework.data.jpa.repository.query.AbstractJpaQuery.createQuery(AbstractJpaQuery.java:176)[spring-data-jpa-1.10.2.RELEASE.jar:na]
      5. org.springframework.data.jpa.repository.query.JpaQueryExecution$CollectionExecution.doExecute(JpaQueryExecution.java:114)[spring-data-jpa-1.10.2.RELEASE.jar:na]
      6. org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:78)[spring-data-jpa-1.10.2.RELEASE.jar:na]
      7. org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:102)[spring-data-jpa-1.10.2.RELEASE.jar:na]
      8. org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:92)[spring-data-jpa-1.10.2.RELEASE.jar:na]
      8 frames
    3. Spring Data Core
      RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke
      1. org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:482)[spring-data-commons-1.12.2.RELEASE.jar:na]
      2. org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:460)[spring-data-commons-1.12.2.RELEASE.jar:na]
      2 frames
    4. Spring AOP
      ReflectiveMethodInvocation.proceed
      1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)[spring-aop-4.2.7.RELEASE.jar:4.2.7.RELEASE]
      1 frame
    5. org.springframework.data
      DefaultMethodInvokingMethodInterceptor.invoke
      1. org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:61)[spring-data-commons-1.12.2.RELEASE.jar:na]
      1 frame
    6. Spring AOP
      ReflectiveMethodInvocation.proceed
      1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)[spring-aop-4.2.7.RELEASE.jar:4.2.7.RELEASE]
      1 frame
    7. Spring Tx
      TransactionInterceptor.invoke
      1. org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)[spring-tx-4.2.7.RELEASE.jar:4.2.7.RELEASE]
      2. org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)[spring-tx-4.2.7.RELEASE.jar:4.2.7.RELEASE]
      3. org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)[spring-tx-4.2.7.RELEASE.jar:4.2.7.RELEASE]
      3 frames
    8. Spring AOP
      ReflectiveMethodInvocation.proceed
      1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)[spring-aop-4.2.7.RELEASE.jar:4.2.7.RELEASE]
      1 frame
    9. Spring Tx
      PersistenceExceptionTranslationInterceptor.invoke
      1. org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)[spring-tx-4.2.7.RELEASE.jar:4.2.7.RELEASE]
      1 frame
    10. Spring AOP
      ReflectiveMethodInvocation.proceed
      1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)[spring-aop-4.2.7.RELEASE.jar:4.2.7.RELEASE]
      1 frame
    11. Spring Data JPA
      CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke
      1. org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:133)[spring-data-jpa-1.10.2.RELEASE.jar:na]
      1 frame
    12. Spring AOP
      JdkDynamicAopProxy.invoke
      1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)[spring-aop-4.2.7.RELEASE.jar:4.2.7.RELEASE]
      2. org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)[spring-aop-4.2.7.RELEASE.jar:4.2.7.RELEASE]
      3. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)[spring-aop-4.2.7.RELEASE.jar:4.2.7.RELEASE]
      4. org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)[spring-aop-4.2.7.RELEASE.jar:4.2.7.RELEASE]
      4 frames