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;
}
spring spring-data-jpa spring-aop java-11 spring-5
|
show 4 more comments
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;
}
spring spring-data-jpa spring-aop java-11 spring-5
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
|
show 4 more comments
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;
}
spring spring-data-jpa spring-aop java-11 spring-5
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
spring spring-data-jpa spring-aop java-11 spring-5
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
|
show 4 more comments
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
|
show 4 more comments
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>
Its already present. Also, I have included it in module-info.java
– Abhisar
16 hours ago
add a comment |
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>
Its already present. Also, I have included it in module-info.java
– Abhisar
16 hours ago
add a comment |
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>
Its already present. Also, I have included it in module-info.java
– Abhisar
16 hours ago
add a comment |
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>
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 16 hours ago
Antoniossss
14.6k12149
14.6k12149
Its already present. Also, I have included it in module-info.java
– Abhisar
16 hours ago
add a comment |
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
add a comment |
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
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
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
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
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
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