Closed Nulleye closed 4 years ago
Hi, sorry for the delay.
We got an application that already has an integrated Neo4j database and want to add some JQA related functionality into it, we can't use Maven in that scenario. Because it is a Java app, it would be ideal to directly use the jars, and not some cmd system call to use the CLI. This is why we want to use a remote connection. By now, I managed to integrate a modified jqa-backend as our application Noe4j database, and it seems to work. I don't like this solution, but it works by now.
Steps to reproduce the problem:
Disable the encryption requirement for the database connection on the jqassistant-commandline-neo4jv3 install.
Modify and replace the com.buschmais.jqassistant.cli-application jar: edit AbstractStoreTask.java
and add this line to the getStore()
function:
storeConfiguration.setEncryption("false");
Get a Neo4j database instance to work with. Create and run a Neo4j desktop instance. Or duplicate to jqassistant-commandline-neo4jv3 install and run it as a server. I've tested both scenarios and they present the same problem.
Get and build spring-petclinic from git.
Run these commands:
bin\jqassistant.cmd scan -storeUri bolt://localhost:7687 -storeUsername <USER> -storePassword <PASS>-f c:\git\spring-petclinic\target\petclinic.war
Open a browser window to the Neo4j database to run this command to correct some inconsistencies. This generates an error in analyze but this is because some INVOKES have no line number (this may be a bug of spring-clinic?)
MATCH (method:Method)-[invokes:INVOKES]->(invokedMethod:Method)
WHERE invokes.lineNumber IS NULL
SET invokes.lineNumber = toInteger(0);
bin\jqassistant.cmd analyze -storeUri bolt://localhost:7687 -storeUsername <USER> -storePassword <PASS> -groups default -r c:\git\spring-petclinic\jqassistant\
Analyze will fail with a null pointer exception with the reason I describe in my initial post.
Verified with jQA 1.9.0-ALPHA2 using Neo4j 3.5/4.0 (started using Docker container) and Maven-Plugin/CLI, issue no longer reproducible. Closing this issue.
Hi, sorry I know this is quite weird, but I don't know where to ask.
I'm currently integrating JQAssistant into our application, but want to run it as a normal java call, so don't want to use it as a maven plugin, nor as a standalone command line call.
Our application already has a Neo4j 3.4.15 instance with http and bolt enabled, so to run a scan or analyze command and store its results into our database, we use the equivalent command line jar calls (from com.buschmais.jqassistant.cli-jqassistant-commandline-neo4jv3-1.8.0.jar) but passing the parameters to specify a remote connection to the app database. Apart from hacking the tasks a bit, to disable connection certificate (there is no normal way to tell we don't need a certificate for the connection) at least using the cli task call, everything seems to work fine.
I'm currently running the scan and analyze commands over "spring-petclinic\target\petclinic.war", using the rules from "spring-petclinic\jqassistant" to test it, but I run into a very weird type/cache problem that I'm totally unable to solve, I've been working on it for over a week now, but I'm totally lost.
The scan task seems to work fine (but then I get a lineNumber() error on analyze, explained later)
The analyze fails in the constraint "spring-injection:FieldsOfInjectablesMustNotBeManipulated", that throws a null pointer exception, mainly because the "WriteToInjectableField" relationship it returns on the cypher query ends up loosing its attributes after the constraint commit(), so when the analyze builds the final report fails on ReportHelper.getLabel() function because the returned relationships have no attributes. It seems that the cache service clears the attributes after the commit. However, all other cypher result fields (two nodes) have their properties intact. Another weird thing is that these returned relationship objects are typed only as CompositeObject, and only one of them (in the third or forth row) has also the WritesDescriptor type. I suspect that this is because that particular relationship is also returned in a previous query of another constraint and cached correctly, but not the others. That particular relationship also does not loose its attributes after the constraint commit is executed. So it seems that if the object has only the CompositeObject its attributes are cleared. However the problem is that those other relationships should also have the WritesDescriptor type.
If I bypass those getLabel() errors by hand on debug, then the analyzer fails on a class cast exception casting Long to Integer when the report is printing out the lineNumber() of some objects. So it seems that the lineNumber attribute is stored internally as Long in the scan phase when it should be an Integer, maybe because the internal type classes are not currently used.
I don't know much about the jQA internals and its cache, and how types are applied over the Neo4j objects.
After many hours I get a workaround, but is quite ugly, copy all "jqassistant-commandline-neo4jv3-1.8.0\lib" jars from the jQA standalone cli version to my project, and then close the Neo4j connection just before I do both the scan or analyze task call, and pass the database file instead of the database connection (so the EmbeddedGraph class is used instead of the RemoteGraph).
If I run the scan task with remote connection and then the analyze task with the local file, the null pointer of the getLabel() function doesn't happen, but the cast Long to Integer appears. If I run the scan task with local file and then the analyze task with the remote connection, the null pointer of the getLabel() function happens, but not the cast Long to Integer error.
What I'm missing here, is there any jar I have to include in my lib or class path, or I have to setup something specially in the "server" side to use a remote connection correctly.
Thanks!!