Caused by: java.lang.AbstractMethodError - spring

I have an application in Spring 5 and I am getting the following exception:
Caused by: java.lang.AbstractMethodError
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:281)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:462)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:708)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:724)
at org.springframework.orm.hibernate5.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:615)
at org.springframework.orm.hibernate5.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:599)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1804)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1741)
... 85 more
My dependecies are:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<springframework.version>5.1.4.RELEASE</springframework.version>
<springsecurity.version>5.1.4.RELEASE</springsecurity.version>
<hibernate.version>5.4.4.Final</hibernate.version>
<hibernate.validator>5.4.3.Final</hibernate.validator>
<mysql.connector.version>5.1.46</mysql.connector.version>
<jackson.version>2.9.6</jackson.version>
<joda-time.version>2.9.9</joda-time.version>
<testng.version>6.14.3</testng.version>
<mockito.version>1.10.19</mockito.version>
<h2.version>1.4.197</h2.version>
<dbunit.version>2.5.4</dbunit.version>
<log4j.version>1.2.17</log4j.version>
</properties>
I am getting this exception since I start the migration process from the Spring 4 to Spring 5. It worked fine before.
Here also have one of the two hibernate configuration and the full exception error:
https://pastebin.com/UmPjQMNf

#M. Deinum was right it is the
<dependency>
<groupId>org.jadira.usertype</groupId>
<artifactId>usertype.core</artifactId>
<version>3.0.0.CR1</version>
</dependency>
When I removed it, it works fine!

Related

SPRING BOOT UPGRADE CAUSES ISSUE WHILE STARTING UP

I'm trying to upgrade spring boot version to 2.6.6 from 2.2.x, I got
ClassNotFoundException: org.springframework.core.metrics.ApplicationStartup.
The pom.xml below:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.6</version>
<relativePath/>
</parent>
< Exception in thread "main" java.lang.NoClassDefFoundError: > >
org/springframework/core/metrics/ApplicationStartup at
org.springframework.boot.SpringApplication.(SpringApplication.java:228)
at
org.springframework.boot.SpringApplication.(SpringApplication.java:241)
at
org.springframework.boot.SpringApplication.run(SpringApplication.java:1312)
at
org.springframework.boot.SpringApplication.run(SpringApplication.java:1301)
at
com.sams.clubops.receiptcheck.transactionaudit.AuditApplication.main(AuditApplication.java:19)
Caused by: java.lang.ClassNotFoundException:
org.springframework.core.metrics.ApplicationStartup at
java.net.URLClassLoader.findClass(URLClassLoader.java:382) at
java.lang.ClassLoader.loadClass(ClassLoader.java:418) at
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352) at
java.lang.ClassLoader.loadClass(ClassLoader.java:351) ... 5 more
I don't know if there any conflict with this version. I wanna get some help, thanks.
With the version changed if you use SpringToolSuite4, forcing the Update Maven Project should work: Project > Update Maven Project > Force Update of Snapshots/Releases

Does ScyllaDB Support Latest Version of Metrics?

When I launch ScyllaDB for the first time:
Cluster cluster = Cluster.builder().addContactPoints("xx.xxx.xx.xxx").build();
Session session = cluster.connect("my_scylladb_cluster");
System.out.println(session.isClosed());
I get the following error:
===== Using optimized driver!!! =====
Exception in thread "main" java.lang.NoClassDefFoundError: com/codahale/metrics/JmxReporter
at com.datastax.driver.core.Metrics.<init>(Metrics.java:156)
at com.datastax.driver.core.Cluster$Manager.init(Cluster.java:1773)
at com.datastax.driver.core.Cluster.init(Cluster.java:228)
at com.datastax.driver.core.Cluster.connectAsync(Cluster.java:401)
at com.datastax.driver.core.Cluster.connect(Cluster.java:352)
at scylladbX.ScyllaDBXMain.main(ScyllaDBMain.java:12)
Caused by: java.lang.ClassNotFoundException: com.codahale.metrics.JmxReporter
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 6 more
In my Maven POM file I'm using the latest version of Metrics:
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
<version>4.2.9</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.dropwizard.metrics/metrics-graphite -->
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-graphite</artifactId>
<version>4.2.9</version>
</dependency>
I noticed that if I downgrade to a much earlier version of Metrics, the problem goes away:
<!-- https://mvnrepository.com/artifact/com.codahale.metrics/metrics-core -->
<dependency>
<groupId>com.codahale.metrics</groupId>
<artifactId>metrics-core</artifactId>
<version>3.0.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.codahale.metrics/metrics-graphite -->
<dependency>
<groupId>com.codahale.metrics</groupId>
<artifactId>metrics-graphite</artifactId>
<version>3.0.0</version>
</dependency>
Does ScyllaDB not support the latest version of Metrics? What is the latest version supported?
Thanks
The DataStax Java Driver documentation here has a section about the problem you saw:
While the driver depends on Metrics 3.2.x, it also works with Metrics 4, with some caveats.
In Metrics 4, JMX reporting was moved to a separate module, metrics-jmx. Because of this you are likely to encounter the following exception at runtime when initializing a Cluster:
Exception in thread "main" java.lang.NoClassDefFoundError: com/codahale/metrics/JmxReporter
at com.datastax.driver.core.Metrics.<init>(Metrics.java:103)
at com.datastax.driver.core.Cluster$Manager.init(Cluster.java:1402)
at com.datastax.driver.core.Cluster.init(Cluster.java:159)
at com.datastax.driver.core.Cluster.connectAsync(Cluster.java:330)
at com.datastax.driver.core.Cluster.connectAsync(Cluster.java:305)
at com.datastax.durationtest.core.DurationTest.createSessions(DurationTest.java:360)
....
Caused by: java.lang.ClassNotFoundException: com.codahale.metrics.JmxReporter
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:185)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496)
... 8 more
That document also has suggestions what to do in this case.
In any case, this problem has nothing to do with Scylla (the backend server you want to connect to) - and is just a problem with the Java client ("driver") you are using.

java.lang.ClassNotFoundException: org.springframework.orm.hibernate4.LocalSessionFactoryBean on switch to Spring 5.x from 4.1.3

We were previously using Spring 4.1.3 and have switched to Spring 5.x (e.g. 5.2.0).
Our Hibernate was always the same, 4.3.8.
But after the Spring 4->5 switch, we started getting this on startup:
ClassNotFoundException: org.springframework.orm.hibernate4.LocalSessionFactoryBean
Caused by: java.lang.ClassNotFoundException: org.springframework.orm.hibernate4.LocalSessionFactoryBean
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1291)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119)
Hibernate has always been 4.3.8 and hasn't changed, so what could be causing this error?
We are including the new spring-orm (5.x) as part of the Spring version switch. This hasn't changed either, other than the new Spring version.
<properties>
<log4j.version>2.17.2</log4j.version>
<java.version>11</java.version>
<finalName>mrs</finalName>
<spring.version>5.2.0.RELEASE</spring.version>
<hibernate.version>4.3.8.Final</hibernate.version>
</properties>
..
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
</dependency>
It looks like Spring 5 no longer includes this class, necessitating a switch to Hibernate 5.

ClassNotFoundException: DirectoryService with apacheds-all already included

I am implemented LDAP authentication in my Spring Boot Application. The dependencies added are as follows:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-ldap</artifactId>
</dependency>
<dependency>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-all</artifactId>
</dependency>
However I am still getting following ClassNotFoundException:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springSecurityFilterChain'
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.servlet.Filter]
Caused by: java.lang.NoClassDefFoundError: org/apache/directory/server/core/DirectoryService
Caused by: java.lang.ClassNotFoundException: org.apache.directory.server.core.DirectoryService
My maven dependency tree clearly shows apacheds-all is added successfully.
Why am I still getting this error?
Spring Security doesn't support Apache DS 2.0. Instead, you need to use 1.5.5. Also, note that later 1.5.x versions are not supported due to breaking API changes.

ElasticSearch 2.0 Java API: java.lang.ClassNotFoundException: org.elasticsearch.common.settings.ImmutableSettings$Builder

I have updated my Spring Boot project to use the new ElasticSearch 2 API and I get this error at startup:
Caused by: java.lang.NoClassDefFoundError: org/elasticsearch/common/settings/ImmutableSettings$Builder
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.getDeclaredMethods(Class.java:1975)
My relevant Maven dependencies are:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
<version>1.3.0.M5</version>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>2.0.0-rc1</version>
</dependency>
Do you have any hint on what I am doing wrong?
Thanks
In ES 2.0, the ImmutableSettings class was indeed removed. This issue mentions it and the breaking changes documentation for 2.0 also mention it.
Instead you can now use Settings.builder() instead of ImmutableSettings.builder(). The current implementation of the Settings class can be seen here
All the questions that still use ImmutableSettings are questions about pre-2.0 versions of Elasticsearch.

Resources