I'm working on Neo4j Spring Data project and wants to perform some spatial related operation on nodes.
Entity Class
@NodeEntity
public class User {
@GraphId
Long id;
private String fname;
private String lname;
private String uname;
private String pwd;
private Double latitude, longitude;
@Indexed(indexType = IndexType.POINT, indexName = "geom")
private String wkt;
public void setLocation(Double lon, Double lat) {
this.wkt = String.format("POINT( %.2f %.2f )", lon, lat);
}
@RelatedTo(type = "KNOWS", direction = Direction.OUTGOING)
public Set<User> knows;
//getter and setter methods
Controller
@RequestMapping(path = URI_SAVE, method = RequestMethod.POST)
public String handleUriSave(@ModelAttribute(value = "insuser") User user) {
System.out.println("save method called");
System.out.println("User : " + user);
try {
User retrivedUser = userService.findUser(user);
if (retrivedUser != null) {
if (retrivedUser.getUname().equals(user.getUname())) {
throw new Exception("User Already Exist !!");
}
}
user.setLocation(user.getLongitude(), user.getLatitude());
userService.create(user);
UserServiceImpl
@Service
public class UserServiceImpl implements IUserService {
@Autowired
private UserEntityRepository userrepository;
@Override
public User create(User user) {
return userrepository.save(user);
}
UserEntityRepository
import org.springframework.data.neo4j.repository.GraphRepository;
import org.springframework.data.neo4j.repository.SpatialRepository;
import org.springframework.stereotype.Repository;
import com.ga.data.entity.User;
@Repository
public interface UserEntityRepository extends GraphRepository<User>, SpatialRepository<User> {
User findByUname(String uname);
}
At the time of saving the user it gives exception,
EXCEPTION
java.lang.RuntimeException: Erroraddingelement0wktPOINT(85.4225.02)toindexgeomstatus500{
"message": "No such property, 'wkt'.",
"exception": "NotFoundException",
"fullname": "org.neo4j.graphdb.NotFoundException",
"stackTrace": [
"org.neo4j.kernel.impl.core.NodeProxy.getProperty(NodeProxy.java:469)",
"org.n
xNodeWrapper.addNode(LegacyIndexNodeWrapper.java:52)",
"org.neo4j.kernel.impl.api.StateHandlingStatementOperations.nodeAddToLegacyIndex(StateHandlingStatementOperations.java:1420)",
"org.neo4j.kernel.impl.api.Ope
LegacyIndexProxy.java:390)",
"org.neo4j.server.rest.web.DatabaseActions.addToNodeIndex(DatabaseActions.java:699)",
"org.neo4j.server.rest.web.RestfulGraphDatabase.addToNodeIndex(RestfulGraphDatabase.java:1059)",
"
java:745)"
],
"errors": [
{
"code": "Neo.DatabaseError.General.UnknownFailure",
"message": "No such property, 'wkt'.",
"stackTrace": "org.neo4j.graphdb.NotFoundException: No such property, 'wkt'.\r\n\tat org.neo4j.kernel
x.add(LayerNodeIndex.java:41)\r\n\tat org.neo4j.gis.spatial.indexprovider.LegacyIndexNodeWrapper.addNode(LegacyIndexNodeWrapper.java:52)\r\n\tat org.neo4j.kernel.impl.api.StateHandlingStatementOperations.nodeAd
egacyIndexProxy.internalAdd(LegacyIndexProxy.java:536)\r\n\tat org.neo4j.kernel.impl.coreapi.LegacyIndexProxy.add(LegacyIndexProxy.java:390)\r\n\tat org.neo4j.server.rest.web.DatabaseActions.addToNodeIndex(Data
reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n\tat java.lang.reflect.Method.invoke(Method.java:606)\r\n\tat com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(
her.dispatch(ResourceJavaMethodDispatcher.java:75)\r\n\tat org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:139)\r\n\tat com.sun.jersey.server.impl
ri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)\r\n\tat com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)\r\n\tat com.sun.jersey.server.impl.appl
9)\r\n\tat com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409)\r\n\tat com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:409)\r\n\tat
ervletHolder.handle(ServletHolder.java:800)\r\n\tat org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669)\r\n\tat org.neo4j.server.rest.web.CollectUserAgentFilter.doFilter(Coll
a:221)\r\n\tat org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1125)\r\n\tat org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)\r\n\tat org.eclipse.jetty.serv
ndle(HandlerList.java:52)\r\n\tat org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)\r\n\tat org.eclipse.jetty.server.Server.handle(Server.java:497)\r\n\tat org.eclipse.jetty.server.
a:620)\r\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:540)\r\n\tat java.lang.Thread.run(Thread.java:745)\r\n"
}
]
}
I am new to neo4j DB. I have read some articles and created index via REST API in neo4j but creating with spring data neo4j gives this type of exception. I'm using neo4j-community-2.3.1-windows version and spring-data-neo4j 3.4.0 RELEASE version.
Any Suggestion Please.
Which version of spring-data-neo4j are you using? Are you using spring-data-neo4j-rest? Or embedded within the server?
Was this a user which existed before?
In the exception there seems to be a bit of stacktrace missing.
Can you repoduce it with a unit test?