java.lang.NoSuchMethodError: com.mysema.query.jpa.JPQLQuery.from([Lcom/mysema/query/types/EntityPath;)Lcom/mysema/query/jpa/JPQLCommonQuery;

Spring JIRA | Thomas Hackel | 4 years 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

    When using QueryDSL 3.0.0 my testcase is broken at run-time: {code} java.lang.NoSuchMethodError: com.mysema.query.jpa.JPQLQuery.from([Lcom/mysema/query/types/EntityPath;)Lcom/mysema/query/jpa/JPQLCommonQuery; at org.springframework.data.jpa.repository.support.Querydsl.createQuery(Querydsl.java:88) at org.springframework.data.jpa.repository.support.QueryDslJpaRepository.createQuery(QueryDslJpaRepository.java:131) at org.springframework.data.jpa.repository.support.QueryDslJpaRepository.findAll(QueryDslJpaRepository.java:93) at org.springframework.data.jpa.repository.support.QueryDslJpaRepository.findAll(QueryDslJpaRepository.java:42) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:333) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:318) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:155) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.data.jpa.repository.support.LockModeRepositoryPostProcessor$LockModePopulatingMethodIntercceptor.invoke(LockModeRepositoryPostProcessor.java:92) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:91) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at com.sun.proxy.$Proxy97.findAll(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198) at com.sun.proxy.$Proxy98.findAll(Unknown Source) {code}

    Spring JIRA | 4 years ago | Thomas Hackel
    java.lang.NoSuchMethodError: com.mysema.query.jpa.JPQLQuery.from([Lcom/mysema/query/types/EntityPath;)Lcom/mysema/query/jpa/JPQLCommonQuery;
  2. 0

    When using QueryDSL 3.0.0 my testcase is broken at run-time: {code} java.lang.NoSuchMethodError: com.mysema.query.jpa.JPQLQuery.from([Lcom/mysema/query/types/EntityPath;)Lcom/mysema/query/jpa/JPQLCommonQuery; at org.springframework.data.jpa.repository.support.Querydsl.createQuery(Querydsl.java:88) at org.springframework.data.jpa.repository.support.QueryDslJpaRepository.createQuery(QueryDslJpaRepository.java:131) at org.springframework.data.jpa.repository.support.QueryDslJpaRepository.findAll(QueryDslJpaRepository.java:93) at org.springframework.data.jpa.repository.support.QueryDslJpaRepository.findAll(QueryDslJpaRepository.java:42) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:333) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:318) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:155) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.data.jpa.repository.support.LockModeRepositoryPostProcessor$LockModePopulatingMethodIntercceptor.invoke(LockModeRepositoryPostProcessor.java:92) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:91) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at com.sun.proxy.$Proxy97.findAll(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198) at com.sun.proxy.$Proxy98.findAll(Unknown Source) {code}

    Spring JIRA | 4 years ago | Thomas Hackel
    java.lang.NoSuchMethodError: com.mysema.query.jpa.JPQLQuery.from([Lcom/mysema/query/types/EntityPath;)Lcom/mysema/query/jpa/JPQLCommonQuery;
  3. 0

    I have a Jpa repository that utilizes QueryDSL's fluent API: {code:title=IUserRepository.java|borderStyle=solid} public interface IUserRepository extends JpaRepository<User, Long>, QueryDslPredicateExecutor<User> {code} Then I have a service that reads records from the repository via the findAll() method. I have a requirement that the fields must be dynamic and the records are pageable: {code:title=UserService.java|borderStyle=solid} @Service @Transactional public class UserService implements IUserService { @Autowired private IUserRepository userRepository; @Autowired private EntityManagerFactory emf; @Override public Page<User> readFromRepository(String username, Pageable page) { PathBuilder<User> entityPath = new PathBuilder<User>(User.class, "user"); StringPath path = entityPath.get(new StringPath("username")); BooleanExpression hasUsername = path.eq(username); BooleanBuilder builder = new BooleanBuilder(); builder.and(hasUsername); return userRepository.findAll(builder, page); } ... } {code} However an exception is thrown whenever that method is called: {noformat} java.lang.NoSuchMethodError: com.mysema.query.jpa.JPQLQuery.offset(J)Lcom/mysema/query/Query; at org.springframework.data.jpa.repository.support.QueryDslJpaRepository.applyPagination(QueryDslJpaRepository.java:168) at org.springframework.data.jpa.repository.support.QueryDslJpaRepository.findAll(QueryDslJpaRepository.java:128) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:322) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:307) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:155) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) at $Proxy24.findAll(Unknown Source) at org.demo.service.UserService.readFromRepository(UserService.java:43) {noformat} I tried digging into the code and the source and I can't find the reasons why. The internal implementation doesn't show any missing methods. I have checked my jars but I didn't find any old dependencies. I tested my project both at home and at work (Ubuntu, Windows, proxied, non-proxied environments). But I keep getting the same exception. When I check the following: {noformat} org.springframework.data.jpa.repository.support.QueryDslJpaRepository.applyPagination(QueryDslJpaRepository.java:168) {noformat} {code:title=QueryDslJpaRepository.java|borderStyle=solid} protected JPQLQuery applyPagination(JPQLQuery query, Pageable pageable) { if (pageable == null) { return query; } query.offset(pageable.getOffset()); query.limit(pageable.getPageSize()); return applySorting(query, pageable.getSort()); } {code} As a workaround, I did the following code: {code:title=UserService.java|borderStyle=solid} @Service @Transactional public class UserService implements IUserService { @Autowired private IUserRepository userRepository; @Autowired private EntityManagerFactory emf; ... @Override public List<User> readFromEntityManager(String username, Pageable page) { PathBuilder<User> entityPath = new PathBuilder<User>(User.class, "user"); StringPath path = entityPath.get(new StringPath("username")); BooleanExpression hasUsername = path.ne(username); BooleanBuilder builder = new BooleanBuilder(); builder.and(hasUsername); EntityManager em = emf.createEntityManager(); JPQLQuery result = new JPAQuery(em).from(entityPath).where(builder); if (page != null) { result.offset(page.getOffset()); result.limit(page.getPageSize()); } return result.list(entityPath); } ... } {code} And it works perfectly. I tried to match as possible the original Spring JPA implementation. I don't really know what's wrong with the findAll() method, but directly calling the EntityManagerFactory somehow did the trick. I have attached a strip-down version of my webapp. It's a Maven project with unit tests included. Just run Maven test to verify the error. You need to have MySQL and create a db "testdb". No data is needed but you can prepopulate them. There's a data.sql inside the classpath. (I'm trying to initialize the db with jdbc:initialize-database but it keeps throwing an error. You might wanna take a peek of that error if you like). By the way my Maven properties: {noformat} <properties> <spring.version>3.1.0.RC1</spring.version> <spring.data.jpa.version>1.1.0.M1</spring.data.jpa.version> <querydsl.version>2.2.3</querydsl.version> </properties> {noformat} Thanks.

    Spring JIRA | 5 years ago | Mark Serrano
    java.lang.NoSuchMethodError: com.mysema.query.jpa.JPQLQuery.offset(J)Lcom/mysema/query/Query;
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    I have a Jpa repository that utilizes QueryDSL's fluent API: {code:title=IUserRepository.java|borderStyle=solid} public interface IUserRepository extends JpaRepository<User, Long>, QueryDslPredicateExecutor<User> {code} Then I have a service that reads records from the repository via the findAll() method. I have a requirement that the fields must be dynamic and the records are pageable: {code:title=UserService.java|borderStyle=solid} @Service @Transactional public class UserService implements IUserService { @Autowired private IUserRepository userRepository; @Autowired private EntityManagerFactory emf; @Override public Page<User> readFromRepository(String username, Pageable page) { PathBuilder<User> entityPath = new PathBuilder<User>(User.class, "user"); StringPath path = entityPath.get(new StringPath("username")); BooleanExpression hasUsername = path.eq(username); BooleanBuilder builder = new BooleanBuilder(); builder.and(hasUsername); return userRepository.findAll(builder, page); } ... } {code} However an exception is thrown whenever that method is called: {noformat} java.lang.NoSuchMethodError: com.mysema.query.jpa.JPQLQuery.offset(J)Lcom/mysema/query/Query; at org.springframework.data.jpa.repository.support.QueryDslJpaRepository.applyPagination(QueryDslJpaRepository.java:168) at org.springframework.data.jpa.repository.support.QueryDslJpaRepository.findAll(QueryDslJpaRepository.java:128) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:322) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:307) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:155) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) at $Proxy24.findAll(Unknown Source) at org.demo.service.UserService.readFromRepository(UserService.java:43) {noformat} I tried digging into the code and the source and I can't find the reasons why. The internal implementation doesn't show any missing methods. I have checked my jars but I didn't find any old dependencies. I tested my project both at home and at work (Ubuntu, Windows, proxied, non-proxied environments). But I keep getting the same exception. When I check the following: {noformat} org.springframework.data.jpa.repository.support.QueryDslJpaRepository.applyPagination(QueryDslJpaRepository.java:168) {noformat} {code:title=QueryDslJpaRepository.java|borderStyle=solid} protected JPQLQuery applyPagination(JPQLQuery query, Pageable pageable) { if (pageable == null) { return query; } query.offset(pageable.getOffset()); query.limit(pageable.getPageSize()); return applySorting(query, pageable.getSort()); } {code} As a workaround, I did the following code: {code:title=UserService.java|borderStyle=solid} @Service @Transactional public class UserService implements IUserService { @Autowired private IUserRepository userRepository; @Autowired private EntityManagerFactory emf; ... @Override public List<User> readFromEntityManager(String username, Pageable page) { PathBuilder<User> entityPath = new PathBuilder<User>(User.class, "user"); StringPath path = entityPath.get(new StringPath("username")); BooleanExpression hasUsername = path.ne(username); BooleanBuilder builder = new BooleanBuilder(); builder.and(hasUsername); EntityManager em = emf.createEntityManager(); JPQLQuery result = new JPAQuery(em).from(entityPath).where(builder); if (page != null) { result.offset(page.getOffset()); result.limit(page.getPageSize()); } return result.list(entityPath); } ... } {code} And it works perfectly. I tried to match as possible the original Spring JPA implementation. I don't really know what's wrong with the findAll() method, but directly calling the EntityManagerFactory somehow did the trick. I have attached a strip-down version of my webapp. It's a Maven project with unit tests included. Just run Maven test to verify the error. You need to have MySQL and create a db "testdb". No data is needed but you can prepopulate them. There's a data.sql inside the classpath. (I'm trying to initialize the db with jdbc:initialize-database but it keeps throwing an error. You might wanna take a peek of that error if you like). By the way my Maven properties: {noformat} <properties> <spring.version>3.1.0.RC1</spring.version> <spring.data.jpa.version>1.1.0.M1</spring.data.jpa.version> <querydsl.version>2.2.3</querydsl.version> </properties> {noformat} Thanks.

    Spring JIRA | 5 years ago | Mark Serrano
    java.lang.NoSuchMethodError: com.mysema.query.jpa.JPQLQuery.offset(J)Lcom/mysema/query/Query;

    1 unregistered visitors

    Root Cause Analysis

    1. java.lang.NoSuchMethodError

      com.mysema.query.jpa.JPQLQuery.from([Lcom/mysema/query/types/EntityPath;)Lcom/mysema/query/jpa/JPQLCommonQuery;

      at org.springframework.data.jpa.repository.support.Querydsl.createQuery()
    2. Spring Data JPA
      QueryDslJpaRepository.findAll
      1. org.springframework.data.jpa.repository.support.Querydsl.createQuery(Querydsl.java:88)
      2. org.springframework.data.jpa.repository.support.QueryDslJpaRepository.createQuery(QueryDslJpaRepository.java:131)
      3. org.springframework.data.jpa.repository.support.QueryDslJpaRepository.findAll(QueryDslJpaRepository.java:93)
      4. org.springframework.data.jpa.repository.support.QueryDslJpaRepository.findAll(QueryDslJpaRepository.java:42)
      4 frames
    3. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      4. java.lang.reflect.Method.invoke(Method.java:601)
      4 frames
    4. Spring Data Core
      RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke
      1. org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:333)
      2. org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:318)
      2 frames
    5. Spring AOP
      ReflectiveMethodInvocation.proceed
      1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      1 frame
    6. Spring Tx
      TransactionInterceptor.invoke
      1. org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96)
      2. org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)
      3. org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
      3 frames
    7. Spring AOP
      ReflectiveMethodInvocation.proceed
      1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      1 frame
    8. Spring Tx
      PersistenceExceptionTranslationInterceptor.invoke
      1. org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:155)
      1 frame
    9. Spring AOP
      ReflectiveMethodInvocation.proceed
      1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      1 frame
    10. Spring Data JPA
      LockModeRepositoryPostProcessor$LockModePopulatingMethodIntercceptor.invoke
      1. org.springframework.data.jpa.repository.support.LockModeRepositoryPostProcessor$LockModePopulatingMethodIntercceptor.invoke(LockModeRepositoryPostProcessor.java:92)
      1 frame
    11. Spring AOP
      JdkDynamicAopProxy.invoke
      1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      2. org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:91)
      3. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      4. org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
      4 frames
    12. com.sun.proxy
      $Proxy97.findAll
      1. com.sun.proxy.$Proxy97.findAll(Unknown Source)
      1 frame
    13. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      4. java.lang.reflect.Method.invoke(Method.java:601)
      4 frames
    14. Spring AOP
      JdkDynamicAopProxy.invoke
      1. org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
      2. org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198)
      2 frames
    15. com.sun.proxy
      $Proxy98.findAll
      1. com.sun.proxy.$Proxy98.findAll(Unknown Source)
      1 frame