Aerospike JDBC connector is not working


#1

Hello I am using Aerospike version > 3.7 and aerospike-jdbc-0.2.2.jar in a gradle project. I write only the following two lines:

    DriverManager.registerDriver(new AerospikeJDBC());
    Connection connecton = DriverManager.getConnection(
                "jdbc:aerospike://localhost:3000");

and it is giving me this exception:

    java.sql.SQLException: [Aerospike][JDBC](11380) Null pointer exception.
        at java.util.TreeMap.compare(TreeMap.java:1290)
        at java.util.TreeMap.put(TreeMap.java:538)
        at com.aerospike.helper.query.QueryEngine.refreshIndexes(QueryEngine.java:515)
        at com.aerospike.helper.query.QueryEngine.refreshCluster(QueryEngine.java:438)
        at com.aerospike.helper.query.QueryEngine.setClient(QueryEngine.java:117)
        at com.aerospike.helper.query.QueryEngine.<init>(QueryEngine.java:104)
        at com.aerospike.jdbc.ASConnection.connect(ASConnection.java:216)
        at com.simba.jdbc.common.BaseConnectionFactory.doConnect(Unknown Source)
        at com.simba.jdbc.common.AbstractDriver.connect(Unknown Source)
        at java.sql.DriverManager.getConnection(DriverManager.java:664)
        at java.sql.DriverManager.getConnection(DriverManager.java:270)
        at com.matchinguu.analytics.core.service.PushAnalysisService.doSpark3(PushAnalysisService.java:219)
        at com.matchinguu.analytics.weather.service.WeatherAnalyzer.finalize(WeatherAnalyzer.java:49)
        at com.matchinguu.analytics.core.service.AnalyzeService.run(AnalyzeService.java:33)
        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 org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:349)
        at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:300)
        at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:133)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:408)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1564)
        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:303)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:762)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:690)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:322)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:970)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:959)
        at com.matchinguu.analytics.AnalyticalEngineApplication.main(AnalyticalEngineApplication.java:14)

What causes it Null pointer exception.


#2

I’m having the same issue w/ jdbc 0.2.3. The error occurs in the method refreshIndexes of the class QueryEngine, so if your table doesn’t have any indexes you won’t see the issue. I continued debugging but then I found myself in the simba sdk, since it’s not open source I couldn’t debug any further.

Aerospike guys, please have a look at this issue… I prefer to use the JDBC connector other than the Java client since it seems to offer more functionalities, otherwise we need a lot of tweaking the use the java client…


#3

I decided to use aerospike-jdbc because it gives ability to write actual SQL queries. Unfortunately, I also have met with the same bug. When I did not have secondary indexes I was able to connect to Aerospike through jdbc. Now, after I created secondary indexes, the Squirrel SQL is failing with the same exception as people described. Also my app is failing. I really do not want to use pure Java client but looks like people who developed aerospike JDBC do not pay attention to this topic at all. Which is sad, because it could be really good product which simplifies people lives.


#4

Thought I would need to mention that using pure Java Aerospike client is OK. So there is definitely the problem in JDBC driver.


#5

After debugging I found where the issue is. It is in the class Index

method public String getBin() { return values.get(“bins”); }

Should be changed to

public String getBin() { return values.get(“bin”); }

So either aerospike people fix it or you need to get source code for aerospike-jdbc, make changes and the recompile. I do not see any other option to fix this.


#6

I can verify that this fix works. I have updated the aerospike-jdbc-0.2.3.jar with this fix and I am able to connect with existing secondary indexes.

Thanks mishgun1 for the info on this.