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

Neo4j-ogm-Wildfly Scalar response queries #259

Closed
sachin2411 opened this issue Oct 15, 2016 · 10 comments
Closed

Neo4j-ogm-Wildfly Scalar response queries #259

sachin2411 opened this issue Oct 15, 2016 · 10 comments

Comments

@sachin2411
Copy link

sachin2411 commented Oct 15, 2016

hello I was facing similar issue to #223 while deploying on wildfly wrote a workaround by seeing the above
But I am facing one peculiar issue on wildfly I am facing below exception on query given below:

11:08:29,088 INFO org.neo4j.ogm.drivers.bolt.request.BoltRequest Request: match( root:EntityNode {modelId :'7b18b9b0-f77f-4957-b973-957ee421bead' , workspaceId : '8a08ecfc562102390156214405360000'}) OPTIONAL MATCH(root)-[r:HAS_ASSOCIATION]->(m) return root,r,m with params {}
11:08:32,146 ERROR org.springframework.boot.context.web.ErrorPageFilter Forwarding to error page from request [/resource/erDiagramXML/7b18b9b0-f77f-4957-b973-957ee421bead] due to exception [Scalar response queries must only return one column. Make sure your cypher query only returns one item.]: java.lang.RuntimeException: Scalar response queries must only return one column. Make sure your cypher query only returns one item.
at org.neo4j.ogm.context.EntityRowModelMapper.map(EntityRowModelMapper.java:38) [neo4j-ogm-core-2.0.4.jar:]
at org.neo4j.ogm.session.delegates.ExecuteQueriesDelegate.executeAndMap(ExecuteQueriesDelegate.java:116) [neo4j-ogm-core-2.0.4.jar:]
at org.neo4j.ogm.session.delegates.ExecuteQueriesDelegate.query(ExecuteQueriesDelegate.java:83) [neo4j-ogm-core-2.0.4.jar:]
at org.neo4j.ogm.session.Neo4jSession.query(Neo4jSession.java:384) [neo4j-ogm-core-2.0.4.jar:]
at com.digitate.ignio.studio.neo4j.services.EntityNodeService.getRootEntityWithAssociations(EntityNodeService.java:521) [studio-data-neo4j-1.0.jar:]
at com.digitate.ignio.studio.neo4j.services.EntityNodeService.getEffectiveEntities(EntityNodeService.java:153) [studio-data-neo4j-1.0.jar:]
at com.digitate.ignio.studio.service.model.ERModelService.getERModelForResource(ERModelService.java:217) [studio-service-1.0.jar:]
at com.digitate.ignio.studio.rest.ResourceRestService.getErDiagramXML(ResourceRestService.java:255) [studio-webservice-1.0.jar:]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.8.0_31]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [rt.jar:1.8.0_31]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.8.0_31]
at java.lang.reflect.Method.invoke(Method.java:483) [rt.jar:1.8.0_31]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) [spring-web-4.2.7.RELEASE.jar:4.2.7.RELEASE]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136) [spring-web-4.2.7.RELEASE.jar:4.2.7.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110) [spring-webmvc-4.2.7.RELEASE.jar:4.2.7.RELEASE]

But the same query works on embedded tomcat server (spring boot application)

org.neo4j.ogm.drivers.bolt.request.BoltRequest Request: match( root:EntityNode {modelId :'7b18b9b0-f77f-4957-b973-957ee421bead' , workspaceId : '8a08ecfc562102390156214405360000'}) OPTIONAL MATCH(root)-[r:HAS_ASSOCIATION]->(m) return root,r,m with params {}

Am I missing something?
Furthur I did some debugging and found out tht in wildfly it always goes in else condition below
in ExecuteQueries class in ogm-core jar

if (type != null && session.metaData().classInfo(type.getSimpleName()) != null) {
    GraphModelRequest request = new DefaultGraphModelRequest(cypher, parameters);
    try (Response response = session.requestHandler().execute(request)) {
        return new GraphEntityMapper(session.metaData(), session.context()).map(type, response);
    }
} else {
    RowModelRequest request = new DefaultRowModelRequest(cypher, parameters);
    try (Response response = session.requestHandler().execute(request)) {
        return mapper.map(type, response);
    }
}

Can anyone help?

@mangrish
Copy link
Contributor

mangrish commented Oct 19, 2016

Is this the same issue on SO: http://stackoverflow.com/questions/40055528/neo4j-ogm-wildfly-cipher-query-not-working ?

It seems you should only return one item rather than 3. My guess is that perhaps the other driver is ignoring your other 2 params.

@mangrish
Copy link
Contributor

@sachin2411: Is this fixed?

@sachin2411
Copy link
Author

@mangrish nopes session.metaData().classInfo(type.getSimpleName()) is coming as null in case of wildfly container hence always going to this condition
RowModelRequest request = new DefaultRowModelRequest(cypher, parameters);
try (Response response = session.requestHandler().execute(request)) {
return mapper.map(type, response);
}
Not sure why

String entityQuery = "match (n:EntityNode { modelId :'" + rootEntityId + "' , workspaceId : '" + containerId
+ "' }) OPTIONAL MATCH(n)-[r:IS_A]->(m) return n,r,m";

    Iterable<RootEntityNode> resultSet = session.query(RootEntityNode.class, entityQuery, Collections.emptyMap());

Above code works on tomcat not on wildfly .I am using following jars

org.neo4j
neo4j-ogm-core
2.0.4

    <dependency>
        <groupId>org.neo4j</groupId>
        <artifactId>neo4j-ogm-bolt-driver</artifactId>
        <version>2.0.4</version>
    </dependency>

@mangrish
Copy link
Contributor

mangrish commented Nov 2, 2016

OK. I'm not sure how it works exactly but can you please try with org.neo4j:neo4j-ogm-core:2.1.0-SHAPSHOT and see if this works? We have made some changes regarding classloading on wildfly that may affect you.

@sachin2411
Copy link
Author

neo4j-ogm-core:2.1.0-SHAPSHOT not able to download it from maven repository.can you pls help

@mangrish
Copy link
Contributor

mangrish commented Nov 4, 2016

You need to add:

        <repository>
            <id>neo4j-snapshots</id>
            <url>http://m2.neo4j.org/content/repositories/snapshots</url>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
            </snapshots>
        </repository>

to your pom.

@sachin2411
Copy link
Author

sachin2411 commented Nov 4, 2016

@mangrish No luck mate, still facing the same issue. Can anyone add VFS support in ClassUtils class like mentioned in issue #48 and provide a jar?

else if (resource.getProtocol().equals("vfs")) {
    Object content = resource.getContent();
    File vfs = (File) content.getClass().getMethod("getPhysicalFile").invoke(content);
    pathFiles.add(vfs);
}

I think this code is missing in ClassUtils.class file. It is becoming a blocker for us to use Neo4j in our project.

@mangrish
Copy link
Contributor

@vince-bickers Are you able to look into this one?

@vince-bickers
Copy link

vince-bickers commented Nov 15, 2016

@sachin2411 I'm not sure what the issue is, but let's take it a step at a time.

You said:

if (type != null && session.metaData().classInfo(type.getSimpleName()) != null) {

is true when running in Tomcat, and false in Wildfly. This would indicate ClassInfos aren't being loaded in Wildfly. I assume you've added a VFS resource resolver as described in #48 and that it is available via the service loader mechanism. If not, VFS resources will not be scanned at startup.

Please turn on debug logging to confirm which domain classes are being scanned.

@mangrish
Copy link
Contributor

mangrish commented Dec 9, 2016

@sachin2411 If you would like us to keep looking at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

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

No branches or pull requests

3 participants