Jadira dependency causes AbstractMethodError - java

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

Related

All beans fail autowire on startup because of a NoSuchMethodError

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.

can run project on local host because error creating bean with name

I just worked in a new office, and I want to setup all the project of my office to my localhost.
When i want to run the project on my localhoost, I have this error :
Error creating bean with name 'pageController': Injection of autowired
dependencies failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Could not
autowire field: private
com.ptdam.ecomm.gateway.service.ServiceSecurity
com.ptdam.ecomm.gateway.controller.PageController.serviceSecurity;
nested exception is java.lang.NoClassDefFoundError:
org/bouncycastle/jce/provider/BouncyCastleProvider
My project was based in Java and using Maven. Can some one help me ? If my information on this question unclear, you can directly ask me on the comment. Thank you.
It cant find class BouncyCastleProvider. It is inorg.bouncycastle.bcprov-jdkXXPlease check dependencies in yourpom.xml, make sureorg.bouncycastle.bcprov-jdkXX` is included in it. For example:
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk16</artifactId>
<version>1.45</version>
</dependency>

Why Spring4.1.3 webmvc internally calling hibernate-validator in weblogic12c

I am deploying a application in weblogic12c.It is spring4.1.3 build rest service. Earlier all jars were inside war file and I set
<prefer-web-inf-classes>true</prefer-web-inf-classes>
Now we removed the supporting jars from war file and deploying the application in weblogic 12c. But now it's throwing below exception. I don't understand how SpringMVC calls the hibernate validator. I see hibernate.validator_4_0_1.jar is available in the wlserver/modules folder of weblogic.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean#0': Invocation of init method failed; nested exception is java.lang.AbstractMethodError: org.hibernate.validator.engine.ConfigurationImpl.getDefaultParameterNameProvider()Ljavax/validation/ParameterNameProvider;
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1566)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
Truncated. see log file for complete stacktrace
Caused By: java.lang.AbstractMethodError: org.hibernate.validator.engine.ConfigurationImpl.getDefaultParameterNameProvider()Ljavax/validation/ParameterNameProvider;
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
I fixed this. I got that weblogic has a weblogic.server.merged.jar which is inside weblogic/12c/wlserver/modules/features and It has javax.validation and hibernate.validator packages and causing the mess. I just updated these packages here manually by latest validation-api.jar and hibernate-validator-5.2.2.jar. It worked. Weblogic does not really cares jars under wlserver/modules but It has combined all these jars to weblogic.server.merged.jar and I needed to update the packages of the same.

No suitable default RequestUpgradeStrategy found

I'm trying to run Websocket on Spring (Not STOMP but regular websocket) as seen here. However, after following the tutorial, I get the following exception:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.socket.server.support.DefaultHandshakeHandler#0': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.web.socket.server.support.DefaultHandshakeHandler]: Constructor threw exception; nested exception is java.lang.IllegalStateException: No suitable default RequestUpgradeStrategy found
I got this on several versions of Tomcat, the newest (which I assume really should have JSR 356 support) was a Tomcat 7.0.50
What could I be doing wrong?
I was able to resolve this by simply updating to Tomcat 7.0.52.
You need tomcat websocket if you use jetty
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-websocket</artifactId>
<version>8.0.28</version>
</dependency>

Hibernate 3.6.10 NoSuchMethodError

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.

Categories