Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoClassDefFoundError and NoSuchMethodError #293

Closed
m007 opened this issue Jan 24, 2017 · 12 comments
Closed

NoClassDefFoundError and NoSuchMethodError #293

m007 opened this issue Jan 24, 2017 · 12 comments

Comments

@m007
Copy link

m007 commented Jan 24, 2017

I'm currently running the official Neo4j 3.1.0 from dockerhub.com as base for a docker image where I use the latest version of this repository to build the *server-plugin.jar to the plugins directory.

Running the new importOSM procedure

CALL spatial.importOSM('/opt/spatial/minimal-indoor-model.osm');

results in

Failed to invoke procedure `spatial.importOSM`: Caused by: java.lang.NoClassDefFoundError: org/geotools/filter/text/cql2/CQLException

And just plainly

CALL spatial.procedures;

results in

Failed to invoke procedure `spatial.procedures`: Caused by: java.lang.NoSuchMethodError: org.neo4j.kernel.impl.proc.Procedures.getAll()Ljava/util/Set;

Can anybody reproduce this issue?

Note: this may be related to #290.

@jexp
Copy link
Member

jexp commented Jan 25, 2017

We just pushed a branch of spatial for 3.1 either you can build it locally or we'll provide a temporary jar to test here https://dl.dropboxusercontent.com/u/14493611/neo4j-spatial-0.24-neo4j-3.1.0-server-plugin.jar

@m007
Copy link
Author

m007 commented Jan 27, 2017

I worked on these issues together with @schrieveslaach and we found out the following:

On the NoSuchMethodError

CALL spatial.procedures; resulting in java.lang.NoSuchMethodError: org.neo4j.kernel.impl.proc.Procedures.getAll()Ljava/util/Set; was due to a version mismatch. The method was renamed (see this line in 66a6504). We initially fixed that ourself because we weren't aware of the above mentioned commit/3.1 branch. So this is no issue anymore, nice 👍

On the NoClassDefFoundError

CALL spatial.importOSM('/opt/spatial/minimal-indoor-model.osm'); resulting in java.lang.NoClassDefFoundError: org/geotools/filter/text/cql2/CQLException is still not fixed. I tried building the server-plugin.jar myself in the 3.1 branch and one more time with the jar from your dropbox. However, we were able to fix that issue manually: We did find that, in fact, org/geotools/filter/text/cql2/CQLException.class is not included in the server-plugin.jar, so the manual solution was to just add that .class file. Afterwards we were good to go.

As the three of us know, NoClassDefFoundError just states that a class was available during compiling, but isn't anymore when used during runtime, so manually adding the .class file if it's in fact missing seemed straightforward.

What currently bothers me is, why is the class missing in the jar?

--

Note 1: I assume that org/geotools/filter/text/cql2/CQLException.class isn't the only missing class, since the server-plugin.jar doesn't even contain the folder structure of /text/cql2/ below org/geotools/filter/.
Note 2: @schrieveslaach feel free to add or correct me.

@schrieveslaach
Copy link

@m007, that's correct. In fact, we added all .class files of org.geotool:gt-cql jar file to the server plugin jar.

@wadael
Copy link

wadael commented Aug 12, 2017

on 20170812, using the latest sources (v3.1.4 I presume with a 3.1.3 server), built JARs (skipping tests, 2 are failing), I get a NoClassDefFoundError: org/geotools/filter/text/cql2/CQLException
on a
call spatial.importOSM('/home/jerome/Tools/neo/neo4j-community-3.1.3/import/map.osm')

call spatial.procedures() works

BTW, I get a FileNotFoundException if I use file:// protocol
Would be even better if all plugins could interact with files coherently or allow both (with/without protocol), also using import folder as root.

@wadael
Copy link

wadael commented Aug 14, 2017

I tried to add

org.geotools
gt-cql
${geotools.version}
compile

without luck. I'm going to bed with even more impostor syndrom

v14.4 is not latest but has the CQLException class

@m007
Copy link
Author

m007 commented Aug 15, 2017

@wadael are you familiar with docker? If so, you could use this Dockerfile (which solved the issue for me):

FROM neo4j:3.1.1
RUN apk add --update zip unzip && rm -rf /var/cache/apk/*

RUN curl -s -L -o /var/lib/neo4j/plugins/neo4j-spatial-server-plugin.jar https://github.com/neo4j-contrib/m2/blob/master/releases/org/neo4j/neo4j-spatial/0.24-neo4j-3.1.1/neo4j-spatial-0.24-neo4j-3.1.1-server-plugin.jar?raw=true

# Patch the server-plugin.jar file with missing .class files
# The issue and patching were both documented here https://github.com/neo4j-contrib/spatial/issues/293
RUN curl -s -L -o /tmp/gt-cql.jar http://repo.boundlessgeo.com/main/org/geotools/gt-cql/14.4/gt-cql-14.4.jar && \
    unzip -q /tmp/gt-cql.jar -d /tmp && \
    cd /tmp && \
    zip -q -ur /var/lib/neo4j/plugins/neo4j-spatial-server-plugin.jar ./org/ && \
    rm -r /tmp/org /tmp/gt-cql.jar

EXPOSE 7474
CMD ["neo4j"]

This completely fixes the issues for server version 3.1.1 with plugin version 0.24.

@wadael
Copy link

wadael commented Aug 15, 2017

@m007 Thank you, the dockerfile put me on tracks.
I rage-copied all the dependencies of the project in $NEO_HOME/lib, with gt-cql amongst the jars.
CALL spatial.importOSM('/home/jerome/Tools/neo/map.osm') worked.
However, why adding the dep in the pom failed leaves me puzzled ... as it appears with mvn dependency:tree |grep cql
and scope is compile

@m007
Copy link
Author

m007 commented Aug 16, 2017

@wadael glad to be able to help. As far as why the dependencies are missing question is concerned I have no idea either.

@schrieveslaach
Copy link

@m007 and @wadael, can you try the provided version, provided in #318? Remember to change the extension from .zip to .jar

@schrieveslaach
Copy link

Here is a Dockerfile

FROM neo4j:3.1.1
RUN apk add --update zip unzip && rm -rf /var/cache/apk/*

RUN curl -s -L -o /var/lib/neo4j/plugins/neo4j-spatial-server-plugin.jar https://github.com/neo4j-contrib/spatial/files/1227950/neo4j-spatial-0.24-neo4j-3.1.4-server-plugin.zip

EXPOSE 7474
CMD ["neo4j"]

@m007
Copy link
Author

m007 commented Aug 16, 2017

After executing

CALL spatial.importOSM('/mnt/map.osm');

for a manually added map.osm file I can confirm that your proposed server-plugin.jar version works 👍 (i.e. does not throw the NoClassDefFoundError). I tested that using the above listed Dockerfile with one minor change:

FROM neo4j:3.1.4

matching the server version name in the .zip file.

@craigtaverner
Copy link
Contributor

This issue due to the OSMLayer extending DynamicLayer which depended on CQL for specifying virtual layers. While OSMLayer itself does not need the CQL capability, this dependency caused the problem. I've added gt-cql to the server-plugin jar now, and released 0.24.1 with this change. See https://github.com/neo4j-contrib/spatial/releases/tag/0.24.1-neo4j-3.1.1

ruliana added a commit to ruliana/docker-neo4j-spatial that referenced this issue Aug 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants