Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression? Cannot invoke "org.antlr.v4.runtime.ParserRuleContext.getParent()" because "ctx" is null #3656

Closed
mpretzer opened this issue Oct 30, 2024 · 1 comment
Labels
status: duplicate A duplicate of another issue

Comments

@mpretzer
Copy link

When upgrading to org.springframework.data:spring-data-jpa:jar:3.2.11 (via spring-boot 3.2.11) we experience the following error. Upgrading to spring-boot 3.3.5 raises the same error, 3.3.4 seems to be fine.

Caused by: org.springframework.data.repository.query.QueryCreationException: Could not create query for public abstract void de....repositories.AuditEntryRepository.deleteBefore(java.time.LocalDateTime); Reason: Cannot invoke "org.antlr.v4.runtime.ParserRuleContext.getParent()" because "ctx" is null
	at org.springframework.data.repository.query.QueryCreationException.create(QueryCreationException.java:101)
	at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.lookupQuery(QueryExecutorMethodInterceptor.java:119)
	at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.mapMethodsToQuery(QueryExecutorMethodInterceptor.java:103)
	at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.lambda$new$0(QueryExecutorMethodInterceptor.java:92)
	at java.base/java.util.Optional.map(Optional.java:260)
	at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.<init>(QueryExecutorMethodInterceptor.java:92)
	at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:357)
	at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$5(RepositoryFactoryBeanSupport.java:290)
	at org.springframework.data.util.Lazy.getNullable(Lazy.java:135)
	at org.springframework.data.util.Lazy.get(Lazy.java:113)
	at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:296)
	at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:132)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1853)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1802)
	... 52 more
Caused by: java.lang.NullPointerException: Cannot invoke "org.antlr.v4.runtime.ParserRuleContext.getParent()" because "ctx" is null
	at org.springframework.data.jpa.repository.query.HqlQueryTransformer.isSubquery(HqlQueryTransformer.java:105)
	at org.springframework.data.jpa.repository.query.HqlQueryTransformer.isSubquery(HqlQueryTransformer.java:105)
	at org.springframework.data.jpa.repository.query.HqlQueryTransformer.isSubquery(HqlQueryTransformer.java:105)
	at org.springframework.data.jpa.repository.query.HqlQueryTransformer.isSubquery(HqlQueryTransformer.java:105)
	at org.springframework.data.jpa.repository.query.HqlQueryTransformer.isSubquery(HqlQueryTransformer.java:105)
	at org.springframework.data.jpa.repository.query.HqlQueryTransformer.isSubquery(HqlQueryTransformer.java:105)
	at org.springframework.data.jpa.repository.query.HqlQueryTransformer.visitVariable(HqlQueryTransformer.java:362)
	at org.springframework.data.jpa.repository.query.HqlQueryRenderer.visitVariable(HqlQueryRenderer.java:1)
	at org.springframework.data.jpa.repository.query.HqlParser$VariableContext.accept(HqlParser.java:10200)
	at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
	at org.springframework.data.jpa.repository.query.HqlQueryRenderer.visitTargetEntity(HqlQueryRenderer.java:481)
	at org.springframework.data.jpa.repository.query.HqlQueryRenderer.visitTargetEntity(HqlQueryRenderer.java:1)
	at org.springframework.data.jpa.repository.query.HqlParser$TargetEntityContext.accept(HqlParser.java:2018)
	at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
	at org.springframework.data.jpa.repository.query.HqlQueryRenderer.visitDeleteStatement(HqlQueryRenderer.java:526)
	at org.springframework.data.jpa.repository.query.HqlQueryRenderer.visitDeleteStatement(HqlQueryRenderer.java:1)
	at org.springframework.data.jpa.repository.query.HqlParser$DeleteStatementContext.accept(HqlParser.java:2198)
	at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
	at org.springframework.data.jpa.repository.query.HqlQueryRenderer.visitQl_statement(HqlQueryRenderer.java:46)
	at org.springframework.data.jpa.repository.query.HqlQueryRenderer.visitQl_statement(HqlQueryRenderer.java:1)
	at org.springframework.data.jpa.repository.query.HqlParser$Ql_statementContext.accept(HqlParser.java:303)
	at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
	at org.springframework.data.jpa.repository.query.HqlQueryRenderer.visitStart(HqlQueryRenderer.java:35)
	at org.springframework.data.jpa.repository.query.HqlQueryRenderer.visitStart(HqlQueryRenderer.java:1)
	at org.springframework.data.jpa.repository.query.HqlParser$StartContext.accept(HqlParser.java:247)
	at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
	at org.springframework.data.jpa.repository.query.HqlQueryParser.doFindAlias(HqlQueryParser.java:101)
	at org.springframework.data.jpa.repository.query.JpaQueryParserSupport.findAlias(JpaQueryParserSupport.java:96)
	at org.springframework.data.jpa.repository.query.JpaQueryEnhancer.detectAlias(JpaQueryEnhancer.java:124)
	at org.springframework.data.jpa.repository.query.StringQuery.<init>(StringQuery.java:90)
	at org.springframework.data.jpa.repository.query.ExpressionBasedStringQuery.<init>(ExpressionBasedStringQuery.java:64)
	at org.springframework.data.jpa.repository.query.AbstractStringBasedJpaQuery.<init>(AbstractStringBasedJpaQuery.java:85)
	at org.springframework.data.jpa.repository.query.SimpleJpaQuery.<init>(SimpleJpaQuery.java:68)
	at org.springframework.data.jpa.repository.query.JpaQueryFactory.fromMethodWithQueryString(JpaQueryFactory.java:60)
	at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$DeclaredQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:170)
	at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:252)
	at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:95)
	at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.lookupQuery(QueryExecutorMethodInterceptor.java:115)

The offending query is

  @Modifying
  @Query("delete from  #{#entityName} as a where a.created < :before")
  void deleteBefore(@Param("before") LocalDateTime before);

Downgrading to org.springframework.data:spring-data-jpa:jar:3.2.10 (using <spring-data-bom.version>2023.1.10</spring-data-bom.version> fixes the problem.

Hibernate version is org.hibernate.orm:hibernate-core:jar:6.4.10.Final, antlr is org.antlr:antlr4-runtime:jar:4.13.0

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 30, 2024
@christophstrobl
Copy link
Member

Thanks for reporting - this is a duplicate of #3649

@christophstrobl christophstrobl added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged labels Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants