-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: AbstractMethodError, Cassandra 2.2.5
PostPosted: Thu Apr 07, 2016 10:59 am 
Newbie

Joined: Thu Apr 07, 2016 8:39 am
Posts: 3
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.AbstractMethodError
Exception 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 :>


Top
 Profile  
 
 Post subject: Re: AbstractMethodError, Cassandra 2.2.5
PostPosted: Fri Apr 08, 2016 10:29 am 
Newbie

Joined: Thu Apr 07, 2016 8:39 am
Posts: 3
Hey folks, just wanted to update that I solved the problem, turns out that the required hibernate-search-orm version I was using (5.3.0.Beta2) isn't supported by Hibernate OGM 5.0.0.Beta1 having had a look on the Maven page and found that version 5.5.1.Final is required so I switched them over and it compiled correctly and connected as required. One issue I am confused about though is why hibernate-search-orm is required in the first place since without this you get the compile error due to this class missing in the org.hibernate.search package supplied with the OGM :

Initial SessionFactory creation failedjava.lang.NoClassDefFoundError: org/hibernate/search/batchindexing/spi/MassIndexerFactory

The thing is this dependency is displayed as optional on Maven but without this it doesn't seem to compile and you get this error, anyway should help folks in case this happens to them.

Cheers now folks :>


Top
 Profile  
 
 Post subject: Re: AbstractMethodError, Cassandra 2.2.5
PostPosted: Mon Apr 11, 2016 7:16 am 
Hibernate Team
Hibernate Team

Joined: Fri Sep 09, 2011 3:18 am
Posts: 295
Hibernate OGM checks if Hibernate Search is on the classpath by looking for the class
Code:
org.hibernate.search.cfg.Environment
, if it can find it it will try to register the OGM massindexer with search.
So, this dependency is optional unless you have Hbernate Search on the class path.

I guess we need to update the documentation about the dependency to Hibernate Search.

Thanks for your feedback


Top
 Profile  
 
 Post subject: Re: AbstractMethodError, Cassandra 2.2.5
PostPosted: Mon Apr 11, 2016 8:44 am 
Hibernate Team
Hibernate Team

Joined: Fri Sep 09, 2011 3:18 am
Posts: 295
I was wondering why you would have Hibernate Search on the classpath if you are not planning on using it with OGM. Could you add some details about your use-case. please?

Thanks,
Davide


Top
 Profile  
 
 Post subject: Re: AbstractMethodError, Cassandra 2.2.5
PostPosted: Wed Apr 13, 2016 6:19 am 
Hibernate Team
Hibernate Team

Joined: Sat Jan 24, 2009 12:46 pm
Posts: 388
Hi Iranicus,

Glad you solved that first problem. We provide a BOM POM (see https://docs.jboss.org/hibernate/ogm/5. ... ingstarted) which you can import into the dependencyManagement block of your (parent) POM and you'll get the right versions of all dependencies needed.

Regarding that second issue, Hibernate Search should indeed be optional and you should see no error when not having it on your classpath if you don't want to use it. Can you share the full stack trace or, better yet, a small project exposing this issue? I quickly tried but could not reproduce it, i.e. I could run a test of our test suite without Hibernate Search being on the classpath.

Thanks,

--Gunnar

_________________
Visit my blog at http://musingsofaprogrammingaddict.blogspot.com/


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.