Cassandra version: 2.2.5
Hibernate OGM version: 5.0.0.Beta1
JDK: 1.8
Hey folks, so I've been trying out the 5.x.x Beta 1 OGM using Cassandra 2.2.5 since currently this OGM version now supports Cassandra 2.2 series and it seems I am stuck on a peculiar issue to do with an Initial SessionFactory creation failedjava.lang.AbstractMethodError when trying to simply open a session factory and connect to the DB. First-off my Hibernate Utility class is like so:
Code:
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.ogm.OgmSession;
import org.hibernate.ogm.OgmSessionFactory;
import org.hibernate.ogm.boot.OgmSessionFactoryBuilder;
import org.hibernate.ogm.cfg.OgmConfiguration;
import org.hibernate.service.ServiceRegistry;
public class HibernateUtil_v1 {
private static final OgmSessionFactory sessionFactory = buildSessionFactory();
private static OgmSessionFactory buildSessionFactory() {
//v2
try {
OgmConfiguration config = new OgmConfiguration();
config.configure();
System.out.println("Config Loaded");
ServiceRegistry servReg = new StandardServiceRegistryBuilder().applySettings(config.getProperties()).build();
System.out.println("Service registry created");
OgmSessionFactory ogmSessionF = new MetadataSources(servReg).buildMetadata().getSessionFactoryBuilder().unwrap(OgmSessionFactoryBuilder.class).build();
System.out.println("OGM SessionFactory built");
return ogmSessionF;
} catch (Throwable ex) {
System.err.println("Initial SessionFactory creation failed" + ex);
throw new ExceptionInInitializerError(ex);
}
}
public static OgmSession openSession() {
return sessionFactory.openSession();
}
}
The main class I am using to simply get connected and get a session factory going:
Code:
public class Main_v2 {
public static void main(String[] args) {
//v1
OgmSession ss = HibernateUtil_v1.openSession();
//v1
ss.close();
}
}
My dependencies I handle using Maven of course so I have the following:
Code:
<dependencies>
<!-- REQUIRED: Hibernate OGM backend identification, providing the necessary Cassandra drivers-->
<dependency>
<groupId>org.hibernate.ogm</groupId>
<artifactId>hibernate-ogm-core</artifactId>
<version>5.0.0.Beta1</version>
</dependency>
<dependency>
<groupId>org.hibernate.ogm</groupId>
<artifactId>hibernate-ogm-cassandra</artifactId>
<version>5.0.0.Beta1</version>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<version>1.1</version>
</dependency>
<!-- Required to be added to accompany the same version of slf4j 1.7.5-->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.5</version>
</dependency>
<!-- Required to be included due to a dependency issue that OGM does not provide-->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search-orm</artifactId>
<version>5.3.0.Beta2</version>
</dependency>
</dependencies>
And lastly we have the hibernate.cfg.xml:
Code:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.ogm.datastore.provider" >org.hibernate.ogm.datastore.cassandra.impl.CassandraDatastoreProvider</property>
<property name="hibernate.ogm.datastore.database" >Test Cluster</property>
<property name="hibernate.ogm.datastore.host" >127.0.0.1:9042</property>
<property name="hibernate.ogm.datastore.grid_dialect">org.hibernate.ogm.datastore.cassandra.CassandraDialect</property>
</session-factory>
</hibernate-configuration>
Now the the problem, upon running I am getting the error:
Apr 07, 2016 3:40:27 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {5.0.5.Final}
Apr 07, 2016 3:40:27 PM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
Apr 07, 2016 3:40:27 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
Config Loaded
Service registry created
Apr 07, 2016 3:40:28 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
Apr 07, 2016 3:40:28 PM org.hibernate.ogm.datastore.impl.DatastoreProviderInitiator initiateService
INFO: OGM000016: NoSQL Datastore provider: org.hibernate.ogm.datastore.cassandra.impl.CassandraDatastoreProvider
Apr 07, 2016 3:40:28 PM org.hibernate.ogm.datastore.cassandra.impl.CassandraDatastoreProvider start
INFO: OGM001601: Connecting to Cassandra at 127.0.0.1:9042
[main] INFO com.datastax.driver.core.NettyUtil - Did not find Netty's native epoll transport in the classpath, defaulting to NIO.
[main] INFO com.datastax.driver.core.policies.DCAwareRoundRobinPolicy - Using data-center name 'datacenter1' for DCAwareRoundRobinPolicy (if this is incorrect, please provide the correct datacenter name with DCAwareRoundRobinPolicy constructor)
[main] INFO com.datastax.driver.core.Cluster - New Cassandra host /127.0.0.1:9042 added
Apr 07, 2016 3:40:29 PM org.hibernate.ogm.dialect.impl.GridDialectInitiator$GridDialectInstantiator newInstance
INFO: OGM000017: Grid Dialect: org.hibernate.ogm.datastore.cassandra.CassandraDialect
Apr 07, 2016 3:40:29 PM org.hibernate.ogm.dialect.impl.GridDialectInitiator$GridDialectInstantiator newInstance
INFO: Grid dialect logs are disabled
Apr 07, 2016 3:40:29 PM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.ogm.dialect.impl.OgmDialect
Apr 07, 2016 3:40:29 PM org.hibernate.engine.jdbc.env.internal.LobCreatorBuilderImpl makeLobCreatorBuilder
INFO: HHH000422: Disabling contextual LOB creation as connection was null
Apr 07, 2016 3:40:29 PM org.hibernate.ogm.cfg.impl.Version <clinit>
INFO: OGM000001: Hibernate OGM 5.0.0.Beta1
Initial SessionFactory creation failedjava.lang.AbstractMethodErrorException in thread "main" java.lang.ExceptionInInitializerError at HibernateUtil_v1.buildSessionFactory(HibernateUtil_v1.java:46)
at HibernateUtil_v1.<clinit>(HibernateUtil_v1.java:16)
at Main_v2.main(Main_v2.java:10)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: java.lang.AbstractMethodError at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:278)
at org.hibernate.ogm.boot.impl.OgmSessionFactoryBuilderImpl.build(OgmSessionFactoryBuilderImpl.java:54)
at HibernateUtil_v1.buildSessionFactory(HibernateUtil_v1.java:40)
... 7 more
The problem seems to emit from the OgmSessionFactory initialiser to which I have tried playing around with the code for the past 3 hours and seem to be stuck on this problem which has been incredibly frustrating. Any ideas folks?
Cheers :>