After upgrading my project to Spring AOP 4.3.7 I get this error trace on every bean auto-wire at Spring Boot startup:
Caused by: java.lang.NoSuchMethodError: org.springframework.aop.framework.AopProxyUtils.getSingletonTarget(Ljava/lang/Object;)Ljava/lang/Object;
at org.springframework.context.event.AbstractApplicationEventMulticaster.addApplicationListener(AbstractApplicationEventMulticaster.java:105)
at org.springframework.context.support.AbstractApplicationContext.addApplicationListener(AbstractApplicationContext.java:494)
at org.springframework.context.support.ApplicationListenerDetector.postProcessAfterInitialization(ApplicationListenerDetector.java:78)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:423)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1633)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
...Stack truncated here for privacy reasons...
I get the sense this is a mismatch in a Spring AOP Jar somewhere in the stack, but cannot find anything that references an actual object to trace.
I was able to resolve this by upgrading to Spring AOP 4.3.13
See these links for the old and new versions of these libraries in the API.
Related
I have a springboot application which uses Cassandra Connection.Also my testClasses has mocked Cassandra Connection.
The following mocks worked till i was using Sprinboot 2.3.3.Release CqlSession,CqlSessionFactoryBean,CassandraProperties,InterfaceRepos,CassandraConverter,DriverContextCodecRegistryCassandraMappingContextReactiveCassandraTemplate
Now I am trying to upgrade Springboot application
from 2.3.3.Release to 2.5.12,
The following are upgraded because of springboot upgrade
Springjars upgraded from 5.2.8.Release to 5.3.18,
Spring-data-Cassandra from 3.0.3.Release to 3.2.10
java-driver-core from 4.6.1 to 4.11.3
com.datastax.cassandra:cassandra-driver-core:jar is still 3.11.0
My main application is able to connect with cassandra without issues, whereas my testCases fails while overriding the Cassandra Connection.Now when i run my testCases, it fails with the below error:
Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException:
Failed to instantiate [org.springframework.data.cassandra.ReactiveSession]: Factory method 'reactiveCassandraSession' threw exception;
nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.datastax.oss.driver.api.core.CqlSession' available
Troubleshooting measure i did:
i)After i upgrade spring boot 2.5.12 , if i downgrade spring-context-5.3.18.Release to 5.2.8.Release i am able to run test cases without issues , so even when i increment to 5.2.9.Release i am getting the above issue , but i believe downgrading to spring-context:5.2.8 is not a good solution.
ii)I have downgraded Spring-data-Cassandra & java-driver-core with different combinations but it didn't provide any fix.
iii)I tried replacing #Mock annotations with mock()
i add spring boot project as dependency in spring mvc project , application can run successfully but when i call service i faced below error
Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed
to read candidate component class: nested exception is
org.springframework.core.annotation.AnnotationConfigurationException:
Attribute 'proxyBeanMethods' in annotation
[org.springframework.boot.SpringBootConfiguration] is declared as an
#AliasFor nonexistent attribute 'proxyBeanMethods' in annotation
[org.springframework.context.annotation.Configuration].; nested
exception is java.lang.NoSuchMethodException:
org.springframework.context.annotation.Configuration.proxyBeanMethods()
Attribute 'proxyBeanMethods' in annotation
[org.springframework.boot.SpringBootConfiguration] is declared as an
#AliasFor nonexistent attribute 'proxyBeanMethods' in annotation
[org.springframework.context.annotation.Configuration].; nested
exception is java.lang.NoSuchMethodException:
org.springframework.context.annotation.Configuration.proxyBeanMethods()
It mainly complains about your #Configuration does not have an attribute called proxyBeanMethods. Checking from the javadoc , this attribute is added since Spring 5.2.
Most probably it is because you are messing up the spring version with your spring-boot version. Your spring version is too old (before 5.2) such that the above attribute of the #Configuration is not defined.
You should use the spring framework which the version is defined by the spring-boot version that you use . Show me the pom.xml and I can help to check which <dependency> causes such version mismatch. Thanks.
Adding a Jadira dependency with Maven causes AbstractMethodError when trying to launch SpringApplication. There is nothing helpful in the stack trace; it is not referencing any of my own classes. What is causing this error and how can I fix it?
Here is the dependency:
<dependency>
<groupId>org.jadira.usertype</groupId>
<artifactId>usertype.core</artifactId>
<version>3.1.0.CR1</version>
</dependency>
Here is part of the stacktrace:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.AbstractMethodError
...
at sec.project.CyberSecurityBaseProjectApplication.main(CyberSecurityBaseProjectApplication.java:17) [classes/:na] // this is simply the line that launches the Spring app
...
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-1.4.2.RELEASE.jar:1.4.2.RELEASE]
Caused by: java.lang.AbstractMethodError: null
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:280) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
...
FWIW, I was trying to do this.
The article you are referring to says that
The code works with Spring Boot 1.2.2 and Hibernate 4.5
From your log it looks like you are using Spring Boot 1.4.2 which will fetch Hibernate 5 jars. There are some issues with Hibernate 5 and the old version of jadira (you are using 3.1.0.CR1). This issue has been fixed since 5.0.0.GA release of jadira usertype. Can you please try with new version available at https://mvnrepository.com/artifact/org.jadira.usertype/usertype.core
I'm having the following issue with my hibernate 3.6.10 project:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testSessionFactory' defined in class path resource [db.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax.persistence.OneToMany.orphanRemoval()Z
Reading some of the issues here on stack overflow, it said I was using the wrong persistence API. So I downloaded the matching hibernate (I've been using the Spring deployment) and copied out the hibernate-jpa-2.0-api-1.0.1.Final.jar which comes with the hibernate distrib, only to get the self-same message.
Is this telling me that OneToMany is not supported by Hibernate 3.6.10?
It tells your that you have a JPA 1.0 API jar somewhere in your classpath. Such a problem cannot be reliably solved by adding proper JPA 2.0 jar to the classpath, you need to find and remove the offending jar before.
I am getting an exception while deploying on Weblogic Server:
[2012-01-13 01:17:11,496] ERROR [org.springframework.web.servlet.DispatcherServlet] Context
initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name
'org.springframework.validation.beanvalidation.LocalValidatorFactoryBean#0': Invocation of init method
failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.
I have some jars as below:
log4j-1.2.14.jar
spring-asm-3.0.3.RELEASE.jar
spring-beans-3.0.3.RELEASE.jar
spring-context-3.0.3.RELEASE.jar
spring-core-3.0.3.RELEASE.jar
spring-expression-3.0.3.RELEASE.jar
spring-web-3.0.3.RELEASE.jar
spring-webmvc-3.0.3.RELEASE.jar
servlet-2.3.jar
validation-api-1.0.0.GA.jar
commons-logging-1.1.1.jar
hibernate-validator-4.0.2.GA.jar
slf4j-api-1.5.6.jar
slf4j-log4j12-1.5.6.jar
standard.jar
commons-fileupload-1.1.1.jar
ESAPI-1.4.4.jar
I am guessing the issues can be but need guidance to solve it:
After researching the issue, 2 likely scenarios came to the forefront:
Hibernate Validator Library has a bug resulting in a dependency on JDK 6
Hibernate Validator has a dependency on the JAXBException Class, and the class is not present in the existing Weblogic Environment
Upon further research, the hibernate-validator-4.0.2.jar build states a clear dependency on JDK 5.
Digging deeper into the Hibernate Validator code, it appears that version 4.0.2 relies on JAXB API 2.1.
Weblogic servers are on java 1.5 and code is also compiled on java 1.5 then why the exceptions seems to pop up??
You're being bitten by JAr incompatibilities. Your project has one version of the JAR, but WebLogic has another. The two don't match. (This is what OSGi was born to solve.)
You'll need to tell WebLogic which JAR you prefer. There's a setting in the weblogic.xml for "prefer WAR file JARs." I'm sorry, I can't recall the exact tag name; please Google for it.