Spring data repositories not working after enabling Spring AOP [JAVA 11]











up vote
1
down vote

favorite












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;
}









share|improve this question
























  • Thats not spring AOP but AspectJ ;P
    – Antoniossss
    16 hours ago










  • Are you using a compatible version of Spring with Java11 ?
    – nullpointer
    16 hours ago










  • @Antoniossss This is Spring AOP using AspectJ annotations. Spring supports AspectJ annotations.
    – Abhisar
    16 hours ago










  • @nullpointer Yes I am, I have updated the question with versions
    – Abhisar
    16 hours ago










  • @Abhisar Since you're creating a modular project, can you also share your module declarations and dependencies (with versions) in use?
    – nullpointer
    14 hours ago















up vote
1
down vote

favorite












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;
}









share|improve this question
























  • Thats not spring AOP but AspectJ ;P
    – Antoniossss
    16 hours ago










  • Are you using a compatible version of Spring with Java11 ?
    – nullpointer
    16 hours ago










  • @Antoniossss This is Spring AOP using AspectJ annotations. Spring supports AspectJ annotations.
    – Abhisar
    16 hours ago










  • @nullpointer Yes I am, I have updated the question with versions
    – Abhisar
    16 hours ago










  • @Abhisar Since you're creating a modular project, can you also share your module declarations and dependencies (with versions) in use?
    – nullpointer
    14 hours ago













up vote
1
down vote

favorite









up vote
1
down vote

favorite











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;
}









share|improve this question















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-5






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 13 hours ago

























asked 16 hours ago









Abhisar

964




964












  • Thats not spring AOP but AspectJ ;P
    – Antoniossss
    16 hours ago










  • Are you using a compatible version of Spring with Java11 ?
    – nullpointer
    16 hours ago










  • @Antoniossss This is Spring AOP using AspectJ annotations. Spring supports AspectJ annotations.
    – Abhisar
    16 hours ago










  • @nullpointer Yes I am, I have updated the question with versions
    – Abhisar
    16 hours ago










  • @Abhisar Since you're creating a modular project, can you also share your module declarations and dependencies (with versions) in use?
    – nullpointer
    14 hours ago


















  • Thats not spring AOP but AspectJ ;P
    – Antoniossss
    16 hours ago










  • Are you using a compatible version of Spring with Java11 ?
    – nullpointer
    16 hours ago










  • @Antoniossss This is Spring AOP using AspectJ annotations. Spring supports AspectJ annotations.
    – Abhisar
    16 hours ago










  • @nullpointer Yes I am, I have updated the question with versions
    – Abhisar
    16 hours ago










  • @Abhisar Since you're creating a modular project, can you also share your module declarations and dependencies (with versions) in use?
    – nullpointer
    14 hours ago
















Thats not spring AOP but AspectJ ;P
– Antoniossss
16 hours ago




Thats not spring AOP but AspectJ ;P
– Antoniossss
16 hours ago












Are you using a compatible version of Spring with Java11 ?
– nullpointer
16 hours ago




Are you using a compatible version of Spring with Java11 ?
– nullpointer
16 hours ago












@Antoniossss This is Spring AOP using AspectJ annotations. Spring supports AspectJ annotations.
– Abhisar
16 hours ago




@Antoniossss This is Spring AOP using AspectJ annotations. Spring supports AspectJ annotations.
– Abhisar
16 hours ago












@nullpointer Yes I am, I have updated the question with versions
– Abhisar
16 hours ago




@nullpointer Yes I am, I have updated the question with versions
– Abhisar
16 hours ago












@Abhisar Since you're creating a modular project, can you also share your module declarations and dependencies (with versions) in use?
– nullpointer
14 hours ago




@Abhisar Since you're creating a modular project, can you also share your module declarations and dependencies (with versions) in use?
– nullpointer
14 hours ago












1 Answer
1






active

oldest

votes

















up vote
0
down vote













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>





share|improve this answer





















  • Its already present. Also, I have included it in module-info.java
    – Abhisar
    16 hours ago











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',
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
});


}
});














 

draft saved


draft discarded


















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
































1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













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>





share|improve this answer





















  • Its already present. Also, I have included it in module-info.java
    – Abhisar
    16 hours ago















up vote
0
down vote













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>





share|improve this answer





















  • Its already present. Also, I have included it in module-info.java
    – Abhisar
    16 hours ago













up vote
0
down vote










up vote
0
down vote









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>





share|improve this answer












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>






share|improve this answer












share|improve this answer



share|improve this answer










answered 16 hours ago









Antoniossss

14.6k12149




14.6k12149












  • Its already present. Also, I have included it in module-info.java
    – Abhisar
    16 hours ago


















  • Its already present. Also, I have included it in module-info.java
    – Abhisar
    16 hours ago
















Its already present. Also, I have included it in module-info.java
– Abhisar
16 hours ago




Its already present. Also, I have included it in module-info.java
– Abhisar
16 hours ago


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














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




















































































Popular posts from this blog

Florida Star v. B. J. F.

Danny Elfman

Lugert, Oklahoma