null pointer exception when creating spatial index, null value return hard coded in class

35 views
Skip to first unread message

toiletduck

unread,
Feb 20, 2012, 9:08:33 AM2/20/12
to Neo4j
I'm experimenting with neo4j for a project. I'm trying to use the the
spatial features but when trying to create a spatial index a null
pointer exception is thrown. My environment is spring data,
neo4j(embedded), tomcat 7.x.

The exception is:
Exception in thread "Thread-7" java.lang.NullPointerException
at org.neo4j.kernel.IndexManagerImpl
$IndexCreatorThread.run(IndexManagerImpl.java:229)

(no stack trace provided in eclipse)

In my model class I have this:
@Indexed(indexType = IndexType.POINT,
indexName="promotionPointLayer")
private String wkt;

The exception occurs at:

private class IndexCreatorThread extends Thread (in
IndexManagerImpl.java)
...

@Override
public void run()
{
String provider = config.get( PROVIDER );
String dataSourceName =
getIndexProvider( provider ).getDataSourceName();

Stepping through the code I see that getIndexProvider( provider )
( provider == 'spatial' )
returns a SpatialIndexProvider object, however the next method
getDataSourceName() in the
class SpatialIndexProvider looks like this:

@Override
public String getDataSourceName() {
return null;
}

So the following lines in IndexManagerImpl:
...

( dataSourceName == null from previous call )
XaDataSource dataSource =
graphDbImpl.getConfig().getTxModule().getXaDataSourceManager().getXaDataSource( dataSourceName );
IndexXaConnection connection = (IndexXaConnection)
dataSource.getXaConnection();
Transaction tx = graphDbImpl.tx().begin();
...
are definitely going to fail (which they do) and the code to create
the index doesn't get executed

(IndexManagerImpl.java)
try
{
javax.transaction.Transaction javaxTx =
graphDbImpl.getConfig().getTxModule().getTxManager().getTransaction();
javaxTx.enlistResource( connection.getXaResource() );
connection.createIndex( cls, indexName, config );
tx.success();
}

This looks like bug unless I'm doing something wrong. Any assistance
is greatly appreciated. Aside from this issue neo4j looks like an
awesome datastore. If further info or clarification is needed please
let me know.



Peter Neubauer

unread,
Feb 20, 2012, 4:43:39 PM2/20/12
to ne...@googlegroups.com
Hi there,
the NPE is thrown since the transaction framework of Neo4j not (yet) can deal with in-graph indexing structures. This looks alarming, but should give you a spatial index anyway?

Neo4j Spatial is not 1.0 yet, and this is one of the reasons why. Is it breaking your logic or can you load and query the data anyway?

Cheers,

/peter neubauer

G:  neubauer.peter
S:  peter.neubauer
P:  +46 704 106975
L:   http://www.linkedin.com/in/neubauer
T:   @peterneubauer

Neo4j 1.6 released                 - dzone.com/6S4K
The Neo4j Heroku Challenge   - http://neo4j-challenge.herokuapp.com/

toiletduck

unread,
Feb 22, 2012, 3:50:12 PM2/22/12
to Neo4j
Thanks for responding. I used neoclipse to see if the index is
created anyway and it appears it is, however my data doesn't appear in
neoclipse so it looks like my data either got blown away or perhaps
wasn't inserted due to the exception being thrown in the transaction.
Can you advise me on a work around? I was thinking I need to create
the index, or attempt to, when the server starts up and then add my
data. I'm still experimenting but if you already know of a strategy I
would appreciate hearing it rather than spending a lot more time
blindly experimenting.

--seth




On Feb 20, 7:43 pm, Peter Neubauer <peter.neuba...@neotechnology.com>
wrote:
> Hi there,
> the NPE is thrown since the transaction framework of Neo4j not (yet) can
> deal with in-graph indexing structures. This looks alarming, but should
> give you a spatial index anyway?
>
> Neo4j Spatial is not 1.0 yet, and this is one of the reasons why. Is it
> breaking your logic or can you load and query the data anyway?
>
> Cheers,
>
> /peter neubauer
>
> G:  neubauer.peter
> S:  peter.neubauer
> P:  +46 704 106975
> L:  http://www.linkedin.com/in/neubauer
> T:   @peterneubauer
>
> Neo4j 1.6 released                 - dzone.com/6S4K
> The Neo4j Heroku Challenge   -http://neo4j-challenge.herokuapp.com/
>
> On Mon, Feb 20, 2012 at 3:08 PM, toiletduck
> <cigano.cafesilen...@gmail.com>wrote:

Peter Neubauer

unread,
Feb 22, 2012, 3:53:24 PM2/22/12
to ne...@googlegroups.com

Ping me next week and we can work itcout over Skype. I am on holiday this week and not supposed to be online :-)

Send from a device with crappy keyboard and autocorrection.

/peter

toiletduck

unread,
Feb 22, 2012, 5:36:58 PM2/22/12
to Neo4j
Thanks for the offer. I got it working. Neoclipse still doesn't show
my objects but i can perform spatial queries for my data after
inserting it. That's good enough for me to continue. Thanks for your
responsiveness, enjoy your holiday.

--seth

On Feb 22, 6:53 pm, Peter Neubauer <neubauer.pe...@gmail.com> wrote:
> Ping me next week and we can work itcout over Skype. I am on holiday this
> week and not supposed to be online :-)
>
> Send from a device with crappy keyboard and autocorrection.
>
> /peter
Reply all
Reply to author
Forward
0 new messages