Spring data repositories not working after enabling Spring AOP [JAVA 11]
Hi I have an application using Spring 5, Spring Data and Spring AOP and Java 11 (I am using JAVA 9 module system as well).
My spring-context/spring-aspects version is 5.1.2.RELEASE
Spring Data version is 2.1.2.RELEASE
Both the versions are the latest available.
I have created repositories in following manner:
@Repository
public interface AirportRepository extends JpaRepository<Airport, Long>
I have enabled Spring Data Repositories using
@Configuration
@EnableTransactionManagement
@PropertySource("classpath:persistence-jndi.properties")
@PropertySource("classpath:hibernate.properties")
@EnableJpaRepositories(basePackages = "com.xx.yy.persistence")
public class PersistenceJNDIConfig
//Datasource configs
It was working perfectly until I introduced Spring AOP, using following configuration.
@ComponentScan(basePackages = "com.xx.yy")
@EnableAspectJAutoProxy(exposeProxy = true)
public class AdminServicesConfiguration
And
@Aspect
@Component
public class DasErrorHandler
@Around("@target(com.xx.yy.commons.aop.ErrorManagedDAS)")
public Object handle(ProceedingJoinPoint proceedingJoinPoint)
//Some code
But now on server startup I am getting following error:
Caused by: java.lang.IllegalStateException: Cannot convert value of type 'com.sun.proxy.$Proxy82 implementing org.springframework.data.util.Streamable,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised,org.springframework.core.DecoratingProxy' to required type 'org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments' for property 'repositoryFragments': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:299)
at org.springframework.beans.AbstractNestablePropertyAccessor.convertIfNecessary(AbstractNestablePropertyAccessor.java:585)
... 103 more
It seems there is a mismatch in the proxy types generated by Spring which is causing the above error, I tried forcing spring to use CGLIB proxies by making:
@EnableAspectJAutoProxy(exposeProxy = true, proxyTargetClass = true )
then the error changes to following, even when I have SpringProxy class on my classpath. Please help:
Caused by: org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class org.apache.tomcat.dbcp.dbcp2.BasicDataSource: Common causes of this problem include using a final class or a non-visible class; nested exception is org.springframework.cglib.core.CodeGenerationException: java.lang.NoClassDefFoundError-->org/springframework/aop/SpringProxy
at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:208)
at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:110)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.createProxy(AbstractAutoProxyCreator.java:473)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:352)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:301)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:434)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1749)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:576)
... 88 more
Caused by: org.springframework.cglib.core.CodeGenerationException: java.lang.NoClassDefFoundError-->org/springframework/aop/SpringProxy
at org.springframework.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:503)
at org.springframework.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:359)
at org.springframework.cglib.proxy.Enhancer.generate(Enhancer.java:582)
at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:106)
at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:104)
at org.springframework.cglib.core.internal.LoadingCache$2.call(LoadingCache.java:54)
at java.base/java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java)
at org.springframework.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:61)
at org.springframework.cglib.core.internal.LoadingCache.get(LoadingCache.java:34)
at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:130)
at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:315)
at org.springframework.cglib.proxy.Enhancer.createHelper(Enhancer.java:569)
at org.springframework.cglib.proxy.Enhancer.createClass(Enhancer.java:416)
at org.springframework.aop.framework.ObjenesisCglibAopProxy.createProxyClassAndInstance(ObjenesisCglibAopProxy.java:58)
at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:205)
... 95 more
Caused by: java.lang.NoClassDefFoundError: org/springframework/aop/SpringProxy
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.System$2.defineClass(System.java:2123)
at java.base/java.lang.invoke.MethodHandles$Lookup.defineClass(MethodHandles.java:962)
at java.base/jdk.internal.reflect.GeneratedMethodAccessor42.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:498)
... 110 more
Caused by: java.lang.ClassNotFoundException: org.springframework.aop.SpringProxy
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 117 more
Edit: module-info.java for modules are as follows
module com.xx.yy.admin.services
//External
requires spring.webmvc;
requires spring.web;
requires spring.context;
requires javax.servlet.api;
requires org.apache.commons.collections4;
requires org.apache.logging.log4j;
requires org.apache.logging.log4j.core;
requires spring.aop;
requires org.aspectj.weaver;
requires spring.aspects;
//Internal
requires com.xx.yy.utils;
requires com.xx.yy.persistence;
module com.xx.yy.persistence
requires spring.context;
requires spring.beans;
requires spring.core;
requires spring.data.commons;
requires spring.data.jpa;
requires spring.tx;
requires spring.jdbc;
requires spring.orm;
requires spring.aop;
requires java.sql;
requires java.persistence;
requires java.naming;
requires java.xml;
module com.xx.yy.utils
requires com.fasterxml.jackson.core;
requires com.fasterxml.jackson.databind;
requires com.fasterxml.jackson.datatype.jsr310;
requires orika.core;
requires spring.context;
requires org.aspectj.weaver;
requires spring.aspects;
spring spring-data-jpa spring-aop java-11
|
show 5 more comments
Hi I have an application using Spring 5, Spring Data and Spring AOP and Java 11 (I am using JAVA 9 module system as well).
My spring-context/spring-aspects version is 5.1.2.RELEASE
Spring Data version is 2.1.2.RELEASE
Both the versions are the latest available.
I have created repositories in following manner:
@Repository
public interface AirportRepository extends JpaRepository<Airport, Long>
I have enabled Spring Data Repositories using
@Configuration
@EnableTransactionManagement
@PropertySource("classpath:persistence-jndi.properties")
@PropertySource("classpath:hibernate.properties")
@EnableJpaRepositories(basePackages = "com.xx.yy.persistence")
public class PersistenceJNDIConfig
//Datasource configs
It was working perfectly until I introduced Spring AOP, using following configuration.
@ComponentScan(basePackages = "com.xx.yy")
@EnableAspectJAutoProxy(exposeProxy = true)
public class AdminServicesConfiguration
And
@Aspect
@Component
public class DasErrorHandler
@Around("@target(com.xx.yy.commons.aop.ErrorManagedDAS)")
public Object handle(ProceedingJoinPoint proceedingJoinPoint)
//Some code
But now on server startup I am getting following error:
Caused by: java.lang.IllegalStateException: Cannot convert value of type 'com.sun.proxy.$Proxy82 implementing org.springframework.data.util.Streamable,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised,org.springframework.core.DecoratingProxy' to required type 'org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments' for property 'repositoryFragments': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:299)
at org.springframework.beans.AbstractNestablePropertyAccessor.convertIfNecessary(AbstractNestablePropertyAccessor.java:585)
... 103 more
It seems there is a mismatch in the proxy types generated by Spring which is causing the above error, I tried forcing spring to use CGLIB proxies by making:
@EnableAspectJAutoProxy(exposeProxy = true, proxyTargetClass = true )
then the error changes to following, even when I have SpringProxy class on my classpath. Please help:
Caused by: org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class org.apache.tomcat.dbcp.dbcp2.BasicDataSource: Common causes of this problem include using a final class or a non-visible class; nested exception is org.springframework.cglib.core.CodeGenerationException: java.lang.NoClassDefFoundError-->org/springframework/aop/SpringProxy
at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:208)
at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:110)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.createProxy(AbstractAutoProxyCreator.java:473)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:352)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:301)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:434)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1749)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:576)
... 88 more
Caused by: org.springframework.cglib.core.CodeGenerationException: java.lang.NoClassDefFoundError-->org/springframework/aop/SpringProxy
at org.springframework.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:503)
at org.springframework.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:359)
at org.springframework.cglib.proxy.Enhancer.generate(Enhancer.java:582)
at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:106)
at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:104)
at org.springframework.cglib.core.internal.LoadingCache$2.call(LoadingCache.java:54)
at java.base/java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java)
at org.springframework.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:61)
at org.springframework.cglib.core.internal.LoadingCache.get(LoadingCache.java:34)
at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:130)
at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:315)
at org.springframework.cglib.proxy.Enhancer.createHelper(Enhancer.java:569)
at org.springframework.cglib.proxy.Enhancer.createClass(Enhancer.java:416)
at org.springframework.aop.framework.ObjenesisCglibAopProxy.createProxyClassAndInstance(ObjenesisCglibAopProxy.java:58)
at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:205)
... 95 more
Caused by: java.lang.NoClassDefFoundError: org/springframework/aop/SpringProxy
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.System$2.defineClass(System.java:2123)
at java.base/java.lang.invoke.MethodHandles$Lookup.defineClass(MethodHandles.java:962)
at java.base/jdk.internal.reflect.GeneratedMethodAccessor42.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:498)
... 110 more
Caused by: java.lang.ClassNotFoundException: org.springframework.aop.SpringProxy
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 117 more
Edit: module-info.java for modules are as follows
module com.xx.yy.admin.services
//External
requires spring.webmvc;
requires spring.web;
requires spring.context;
requires javax.servlet.api;
requires org.apache.commons.collections4;
requires org.apache.logging.log4j;
requires org.apache.logging.log4j.core;
requires spring.aop;
requires org.aspectj.weaver;
requires spring.aspects;
//Internal
requires com.xx.yy.utils;
requires com.xx.yy.persistence;
module com.xx.yy.persistence
requires spring.context;
requires spring.beans;
requires spring.core;
requires spring.data.commons;
requires spring.data.jpa;
requires spring.tx;
requires spring.jdbc;
requires spring.orm;
requires spring.aop;
requires java.sql;
requires java.persistence;
requires java.naming;
requires java.xml;
module com.xx.yy.utils
requires com.fasterxml.jackson.core;
requires com.fasterxml.jackson.databind;
requires com.fasterxml.jackson.datatype.jsr310;
requires orika.core;
requires spring.context;
requires org.aspectj.weaver;
requires spring.aspects;
spring spring-data-jpa spring-aop java-11
Thats not spring AOP but AspectJ ;P
– Antoniossss
Nov 10 '18 at 9:21
Are you using a compatible version of Spring with Java11 ?
– nullpointer
Nov 10 '18 at 9:25
@Antoniossss This is Spring AOP using AspectJ annotations. Spring supports AspectJ annotations.
– Abhisar
Nov 10 '18 at 9:47
@nullpointer Yes I am, I have updated the question with versions
– Abhisar
Nov 10 '18 at 9:49
@Abhisar Since you're creating a modular project, can you also share your module declarations and dependencies (with versions) in use?
– nullpointer
Nov 10 '18 at 11:55
|
show 5 more comments
Hi I have an application using Spring 5, Spring Data and Spring AOP and Java 11 (I am using JAVA 9 module system as well).
My spring-context/spring-aspects version is 5.1.2.RELEASE
Spring Data version is 2.1.2.RELEASE
Both the versions are the latest available.
I have created repositories in following manner:
@Repository
public interface AirportRepository extends JpaRepository<Airport, Long>
I have enabled Spring Data Repositories using
@Configuration
@EnableTransactionManagement
@PropertySource("classpath:persistence-jndi.properties")
@PropertySource("classpath:hibernate.properties")
@EnableJpaRepositories(basePackages = "com.xx.yy.persistence")
public class PersistenceJNDIConfig
//Datasource configs
It was working perfectly until I introduced Spring AOP, using following configuration.
@ComponentScan(basePackages = "com.xx.yy")
@EnableAspectJAutoProxy(exposeProxy = true)
public class AdminServicesConfiguration
And
@Aspect
@Component
public class DasErrorHandler
@Around("@target(com.xx.yy.commons.aop.ErrorManagedDAS)")
public Object handle(ProceedingJoinPoint proceedingJoinPoint)
//Some code
But now on server startup I am getting following error:
Caused by: java.lang.IllegalStateException: Cannot convert value of type 'com.sun.proxy.$Proxy82 implementing org.springframework.data.util.Streamable,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised,org.springframework.core.DecoratingProxy' to required type 'org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments' for property 'repositoryFragments': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:299)
at org.springframework.beans.AbstractNestablePropertyAccessor.convertIfNecessary(AbstractNestablePropertyAccessor.java:585)
... 103 more
It seems there is a mismatch in the proxy types generated by Spring which is causing the above error, I tried forcing spring to use CGLIB proxies by making:
@EnableAspectJAutoProxy(exposeProxy = true, proxyTargetClass = true )
then the error changes to following, even when I have SpringProxy class on my classpath. Please help:
Caused by: org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class org.apache.tomcat.dbcp.dbcp2.BasicDataSource: Common causes of this problem include using a final class or a non-visible class; nested exception is org.springframework.cglib.core.CodeGenerationException: java.lang.NoClassDefFoundError-->org/springframework/aop/SpringProxy
at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:208)
at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:110)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.createProxy(AbstractAutoProxyCreator.java:473)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:352)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:301)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:434)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1749)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:576)
... 88 more
Caused by: org.springframework.cglib.core.CodeGenerationException: java.lang.NoClassDefFoundError-->org/springframework/aop/SpringProxy
at org.springframework.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:503)
at org.springframework.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:359)
at org.springframework.cglib.proxy.Enhancer.generate(Enhancer.java:582)
at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:106)
at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:104)
at org.springframework.cglib.core.internal.LoadingCache$2.call(LoadingCache.java:54)
at java.base/java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java)
at org.springframework.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:61)
at org.springframework.cglib.core.internal.LoadingCache.get(LoadingCache.java:34)
at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:130)
at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:315)
at org.springframework.cglib.proxy.Enhancer.createHelper(Enhancer.java:569)
at org.springframework.cglib.proxy.Enhancer.createClass(Enhancer.java:416)
at org.springframework.aop.framework.ObjenesisCglibAopProxy.createProxyClassAndInstance(ObjenesisCglibAopProxy.java:58)
at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:205)
... 95 more
Caused by: java.lang.NoClassDefFoundError: org/springframework/aop/SpringProxy
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.System$2.defineClass(System.java:2123)
at java.base/java.lang.invoke.MethodHandles$Lookup.defineClass(MethodHandles.java:962)
at java.base/jdk.internal.reflect.GeneratedMethodAccessor42.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:498)
... 110 more
Caused by: java.lang.ClassNotFoundException: org.springframework.aop.SpringProxy
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 117 more
Edit: module-info.java for modules are as follows
module com.xx.yy.admin.services
//External
requires spring.webmvc;
requires spring.web;
requires spring.context;
requires javax.servlet.api;
requires org.apache.commons.collections4;
requires org.apache.logging.log4j;
requires org.apache.logging.log4j.core;
requires spring.aop;
requires org.aspectj.weaver;
requires spring.aspects;
//Internal
requires com.xx.yy.utils;
requires com.xx.yy.persistence;
module com.xx.yy.persistence
requires spring.context;
requires spring.beans;
requires spring.core;
requires spring.data.commons;
requires spring.data.jpa;
requires spring.tx;
requires spring.jdbc;
requires spring.orm;
requires spring.aop;
requires java.sql;
requires java.persistence;
requires java.naming;
requires java.xml;
module com.xx.yy.utils
requires com.fasterxml.jackson.core;
requires com.fasterxml.jackson.databind;
requires com.fasterxml.jackson.datatype.jsr310;
requires orika.core;
requires spring.context;
requires org.aspectj.weaver;
requires spring.aspects;
spring spring-data-jpa spring-aop java-11
Hi I have an application using Spring 5, Spring Data and Spring AOP and Java 11 (I am using JAVA 9 module system as well).
My spring-context/spring-aspects version is 5.1.2.RELEASE
Spring Data version is 2.1.2.RELEASE
Both the versions are the latest available.
I have created repositories in following manner:
@Repository
public interface AirportRepository extends JpaRepository<Airport, Long>
I have enabled Spring Data Repositories using
@Configuration
@EnableTransactionManagement
@PropertySource("classpath:persistence-jndi.properties")
@PropertySource("classpath:hibernate.properties")
@EnableJpaRepositories(basePackages = "com.xx.yy.persistence")
public class PersistenceJNDIConfig
//Datasource configs
It was working perfectly until I introduced Spring AOP, using following configuration.
@ComponentScan(basePackages = "com.xx.yy")
@EnableAspectJAutoProxy(exposeProxy = true)
public class AdminServicesConfiguration
And
@Aspect
@Component
public class DasErrorHandler
@Around("@target(com.xx.yy.commons.aop.ErrorManagedDAS)")
public Object handle(ProceedingJoinPoint proceedingJoinPoint)
//Some code
But now on server startup I am getting following error:
Caused by: java.lang.IllegalStateException: Cannot convert value of type 'com.sun.proxy.$Proxy82 implementing org.springframework.data.util.Streamable,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised,org.springframework.core.DecoratingProxy' to required type 'org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments' for property 'repositoryFragments': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:299)
at org.springframework.beans.AbstractNestablePropertyAccessor.convertIfNecessary(AbstractNestablePropertyAccessor.java:585)
... 103 more
It seems there is a mismatch in the proxy types generated by Spring which is causing the above error, I tried forcing spring to use CGLIB proxies by making:
@EnableAspectJAutoProxy(exposeProxy = true, proxyTargetClass = true )
then the error changes to following, even when I have SpringProxy class on my classpath. Please help:
Caused by: org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class org.apache.tomcat.dbcp.dbcp2.BasicDataSource: Common causes of this problem include using a final class or a non-visible class; nested exception is org.springframework.cglib.core.CodeGenerationException: java.lang.NoClassDefFoundError-->org/springframework/aop/SpringProxy
at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:208)
at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:110)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.createProxy(AbstractAutoProxyCreator.java:473)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:352)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:301)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:434)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1749)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:576)
... 88 more
Caused by: org.springframework.cglib.core.CodeGenerationException: java.lang.NoClassDefFoundError-->org/springframework/aop/SpringProxy
at org.springframework.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:503)
at org.springframework.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:359)
at org.springframework.cglib.proxy.Enhancer.generate(Enhancer.java:582)
at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:106)
at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:104)
at org.springframework.cglib.core.internal.LoadingCache$2.call(LoadingCache.java:54)
at java.base/java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java)
at org.springframework.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:61)
at org.springframework.cglib.core.internal.LoadingCache.get(LoadingCache.java:34)
at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:130)
at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:315)
at org.springframework.cglib.proxy.Enhancer.createHelper(Enhancer.java:569)
at org.springframework.cglib.proxy.Enhancer.createClass(Enhancer.java:416)
at org.springframework.aop.framework.ObjenesisCglibAopProxy.createProxyClassAndInstance(ObjenesisCglibAopProxy.java:58)
at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:205)
... 95 more
Caused by: java.lang.NoClassDefFoundError: org/springframework/aop/SpringProxy
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.System$2.defineClass(System.java:2123)
at java.base/java.lang.invoke.MethodHandles$Lookup.defineClass(MethodHandles.java:962)
at java.base/jdk.internal.reflect.GeneratedMethodAccessor42.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:498)
... 110 more
Caused by: java.lang.ClassNotFoundException: org.springframework.aop.SpringProxy
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 117 more
Edit: module-info.java for modules are as follows
module com.xx.yy.admin.services
//External
requires spring.webmvc;
requires spring.web;
requires spring.context;
requires javax.servlet.api;
requires org.apache.commons.collections4;
requires org.apache.logging.log4j;
requires org.apache.logging.log4j.core;
requires spring.aop;
requires org.aspectj.weaver;
requires spring.aspects;
//Internal
requires com.xx.yy.utils;
requires com.xx.yy.persistence;
module com.xx.yy.persistence
requires spring.context;
requires spring.beans;
requires spring.core;
requires spring.data.commons;
requires spring.data.jpa;
requires spring.tx;
requires spring.jdbc;
requires spring.orm;
requires spring.aop;
requires java.sql;
requires java.persistence;
requires java.naming;
requires java.xml;
module com.xx.yy.utils
requires com.fasterxml.jackson.core;
requires com.fasterxml.jackson.databind;
requires com.fasterxml.jackson.datatype.jsr310;
requires orika.core;
requires spring.context;
requires org.aspectj.weaver;
requires spring.aspects;
spring spring-data-jpa spring-aop java-11
spring spring-data-jpa spring-aop java-11
edited Dec 18 '18 at 20:01
Brian Clozel
30k67298
30k67298
asked Nov 10 '18 at 9:18
Abhisar
1116
1116
Thats not spring AOP but AspectJ ;P
– Antoniossss
Nov 10 '18 at 9:21
Are you using a compatible version of Spring with Java11 ?
– nullpointer
Nov 10 '18 at 9:25
@Antoniossss This is Spring AOP using AspectJ annotations. Spring supports AspectJ annotations.
– Abhisar
Nov 10 '18 at 9:47
@nullpointer Yes I am, I have updated the question with versions
– Abhisar
Nov 10 '18 at 9:49
@Abhisar Since you're creating a modular project, can you also share your module declarations and dependencies (with versions) in use?
– nullpointer
Nov 10 '18 at 11:55
|
show 5 more comments
Thats not spring AOP but AspectJ ;P
– Antoniossss
Nov 10 '18 at 9:21
Are you using a compatible version of Spring with Java11 ?
– nullpointer
Nov 10 '18 at 9:25
@Antoniossss This is Spring AOP using AspectJ annotations. Spring supports AspectJ annotations.
– Abhisar
Nov 10 '18 at 9:47
@nullpointer Yes I am, I have updated the question with versions
– Abhisar
Nov 10 '18 at 9:49
@Abhisar Since you're creating a modular project, can you also share your module declarations and dependencies (with versions) in use?
– nullpointer
Nov 10 '18 at 11:55
Thats not spring AOP but AspectJ ;P
– Antoniossss
Nov 10 '18 at 9:21
Thats not spring AOP but AspectJ ;P
– Antoniossss
Nov 10 '18 at 9:21
Are you using a compatible version of Spring with Java11 ?
– nullpointer
Nov 10 '18 at 9:25
Are you using a compatible version of Spring with Java11 ?
– nullpointer
Nov 10 '18 at 9:25
@Antoniossss This is Spring AOP using AspectJ annotations. Spring supports AspectJ annotations.
– Abhisar
Nov 10 '18 at 9:47
@Antoniossss This is Spring AOP using AspectJ annotations. Spring supports AspectJ annotations.
– Abhisar
Nov 10 '18 at 9:47
@nullpointer Yes I am, I have updated the question with versions
– Abhisar
Nov 10 '18 at 9:49
@nullpointer Yes I am, I have updated the question with versions
– Abhisar
Nov 10 '18 at 9:49
@Abhisar Since you're creating a modular project, can you also share your module declarations and dependencies (with versions) in use?
– nullpointer
Nov 10 '18 at 11:55
@Abhisar Since you're creating a modular project, can you also share your module declarations and dependencies (with versions) in use?
– nullpointer
Nov 10 '18 at 11:55
|
show 5 more comments
1 Answer
1
active
oldest
votes
Try adding AOP lib to your dependencies
<!-- https://mvnrepository.com/artifact/org.springframework/spring-aop -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>5.1.2.RELEASE</version>
</dependency>
Its already present. Also, I have included it in module-info.java
– Abhisar
Nov 10 '18 at 9:51
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53237556%2fspring-data-repositories-not-working-after-enabling-spring-aop-java-11%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Try adding AOP lib to your dependencies
<!-- https://mvnrepository.com/artifact/org.springframework/spring-aop -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>5.1.2.RELEASE</version>
</dependency>
Its already present. Also, I have included it in module-info.java
– Abhisar
Nov 10 '18 at 9:51
add a comment |
Try adding AOP lib to your dependencies
<!-- https://mvnrepository.com/artifact/org.springframework/spring-aop -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>5.1.2.RELEASE</version>
</dependency>
Its already present. Also, I have included it in module-info.java
– Abhisar
Nov 10 '18 at 9:51
add a comment |
Try adding AOP lib to your dependencies
<!-- https://mvnrepository.com/artifact/org.springframework/spring-aop -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>5.1.2.RELEASE</version>
</dependency>
Try adding AOP lib to your dependencies
<!-- https://mvnrepository.com/artifact/org.springframework/spring-aop -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>5.1.2.RELEASE</version>
</dependency>
answered Nov 10 '18 at 9:49
Antoniossss
15.1k12153
15.1k12153
Its already present. Also, I have included it in module-info.java
– Abhisar
Nov 10 '18 at 9:51
add a comment |
Its already present. Also, I have included it in module-info.java
– Abhisar
Nov 10 '18 at 9:51
Its already present. Also, I have included it in module-info.java
– Abhisar
Nov 10 '18 at 9:51
Its already present. Also, I have included it in module-info.java
– Abhisar
Nov 10 '18 at 9:51
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53237556%2fspring-data-repositories-not-working-after-enabling-spring-aop-java-11%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Thats not spring AOP but AspectJ ;P
– Antoniossss
Nov 10 '18 at 9:21
Are you using a compatible version of Spring with Java11 ?
– nullpointer
Nov 10 '18 at 9:25
@Antoniossss This is Spring AOP using AspectJ annotations. Spring supports AspectJ annotations.
– Abhisar
Nov 10 '18 at 9:47
@nullpointer Yes I am, I have updated the question with versions
– Abhisar
Nov 10 '18 at 9:49
@Abhisar Since you're creating a modular project, can you also share your module declarations and dependencies (with versions) in use?
– nullpointer
Nov 10 '18 at 11:55