jqassistant-archive / jqa-core-framework

The core framework of jQAssistant providing the infrastructure for scanners, rules, analysis and reports.
http://jqassistant.org/
GNU General Public License v3.0
23 stars 6 forks source link

Remote graph connection object types and/or cache problems #45

Closed Nulleye closed 4 years ago

Nulleye commented 4 years ago

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.

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!!

DirkMahler commented 4 years ago
  1. This is very specific... Is there any good reason not to use the official distributions (Maven/CLI)? The certificate issue can be solved quite easily on our side. Actually it should already be supported by the Maven plugin (needs test and documentation).
  2. There might be issues with remote connections but it would be good to have something reproducible, can you provide a small demonstrator project?
Nulleye commented 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:

  1. 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");

  2. 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.

  3. Get and build spring-petclinic from git.

  4. 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.

DirkMahler commented 4 years ago

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.