javamavenneo4jcode-analysisjqassistant

Neo4J database shuts down while using jqassistant 2.4.0 [target store format 'AF4.3.0']


I'm experiencing an unexpected shut down with jqassistant 2.4.0. Neo4J is provoking a fatal exception. Interestingly with jqassistant 2.0.10 I'm not experiencing this problem.

I have an application where I'm trying to implement jqassistant checks. This is the error I'm getting:

[ERROR] Failed to execute goal com.buschmais.jqassistant:jqassistant-maven-plugin:2.4.0:analyze (default-cli) on project myapp-backend: Execution def ault-cli of goal com.buschmais.jqassistant:jqassistant-maven-plugin:2.4.0:analyze failed: Error starting Neo4j database server at C:\devsbb\ws\myapp
target\jqassistant\store\data\databases: Component 'org.neo4j.dbms.database.DefaultSystemGraphInitializer@2e8417ea' was successfully initialized, but failed to s tart. Please see the attached cause exception "The selected target store format 'AF4.3.0' (introduced in 4.3.0) is no longer supported". This database is shutdown. -> [Help 1]

This is what my parent pom looks like:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>3.1.3</version>
    <relativePath />
</parent>

<groupId>com.mycompany</groupId>
<artifactId>parent</artifactId>
<version>${revision}</version>
<packaging>pom</packaging>

<properties>
    <revision>8.0.2-SNAPSHOT</revision>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>17</java.version>
    <maven.build.timestamp.format>yyyy-MM-dd HH:mm</maven.build.timestamp.format>
    <timestamp>${maven.build.timestamp}</timestamp>

    <springdoc-openapi.version>2.2.0</springdoc-openapi.version>
    <spring-cloud-dependencies.version>2022.0.4</spring-cloud-dependencies.version>
    <spring-cloud-starter-stream-solace.version>4.0.0</spring-cloud-starter-stream-solace.version>
    <azure-identity.version>1.10.1</azure-identity.version>
    <microsoft-graph.version>5.70.0</microsoft-graph.version>
    <org-json.version>20230227</org-json.version>
    <commons-validatior.version>1.7</commons-validatior.version>
    <jacoco-maven-plugin.version>0.8.8</jacoco-maven-plugin.version>

    <sonar.coverage.jacoco.xmlReportPaths>../target/site/jacoco/jacoco.xml
    </sonar.coverage.jacoco.xmlReportPaths>
    <flatten-maven-plugin.version>1.6.0</flatten-maven-plugin.version>
    <fmt-maven-plugin.version>2.19</fmt-maven-plugin.version>
    <maven-scm-plugin.version>2.0.1</maven-scm-plugin.version>
    <jsonschema2pojo-maven-plugin.version>1.2.1</jsonschema2pojo-maven-plugin.version>

    <!-- jqassistant -->
    <jqassistant-maven-plugin.version>2.4.0</jqassistant-maven-plugin.version>
</properties>

<modules>
    <module>myapp-backend</module>
</modules>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>${spring-cloud-dependencies.version}</version>
            <scope>import</scope>
            <type>pom</type>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-log4j2</artifactId>
        <version>3.1.3</version>
    </dependency>
    <dependency>
        <groupId>jakarta.validation</groupId>
        <artifactId>jakarta.validation-api</artifactId>
    </dependency>
    <dependency>
        <groupId>jakarta.persistence</groupId>
        <artifactId>jakarta.persistence-api</artifactId>
    </dependency>
    <dependency>
        <groupId>jakarta.servlet</groupId>
        <artifactId>jakarta.servlet-api</artifactId>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-annotations</artifactId>
    </dependency>
</dependencies>

<profiles>
    <profile>
        <id>jqassistant</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>com.buschmais.jqassistant</groupId>
                    <artifactId>jqassistant-maven-plugin</artifactId>
                    <version>${jqassistant-maven-plugin.version}</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>scan</goal>
                                <goal>analyze</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>flatten-maven-plugin</artifactId>
            <version>${flatten-maven-plugin.version}</version>
            <configuration>
                <updatePomFile>true</updatePomFile>
                <flattenMode>resolveCiFriendliesOnly</flattenMode>
            </configuration>
            <executions>
                <execution>
                    <id>flatten</id>
                    <phase>process-resources</phase>
                    <goals>
                        <goal>flatten</goal>
                    </goals>
                </execution>
                <execution>
                    <id>flatten.clean</id>
                    <phase>clean</phase>
                    <goals>
                        <goal>clean</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>com.spotify.fmt</groupId>
            <artifactId>fmt-maven-plugin</artifactId>
            <version>${fmt-maven-plugin.version}</version>
            <configuration>
                <style>google</style>
            </configuration>
            <executions>
                <execution>
                    <id>format-check</id>
                    <goals>
                        <goal>check</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>com.buschmais.jqassistant</groupId>
            <artifactId>jqassistant-maven-plugin</artifactId>
            <version>${jqassistant-maven-plugin.version}</version>
        </plugin>
    </plugins>
</build>

In the root folder I have the .jqassistant.yml

jqassistant:
  scan:
    reset: false
  analyze:
    report:
      warn-on-severity: MINOR
      fail-on-severity: MAJOR
      properties:
        junit.report.failureSeverity: MAJOR
        junit.report.errorSeverity: MINOR
  maven:
    use-execution-root-as-project-root: true

A .mvn/jvm.config

--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.nio=ALL-UNNAMED

and jqassistant/rules.xml (This file "compiles" with jqassistant 2.0.10 but I think it's syntactically incorrect for 2.4.0. I'm going to post another question related to this)

<jqa:jqassistant-rules xmlns:jqa="http://www.buschmais.com/jqassistant/core/rule/schema/v1.3">

<constraint id="logging:use-logback">
    <description>Ensures that Logback is used for logging.</description>
    <cypher><![CDATA[
          MATCH
            (app:Application)-[:CONTAINS]->(type:Type)
          WHERE NOT (
            (type)-[:DECLARES]->()-[:OF_TYPE]->(:Type {fqn:"ch.qos.logback.classic.Logger"})
            OR
            (type)-[:DECLARES]->()-[:INVOKES]->()<-[:DECLARES]-(:Type {fqn:"org.slf4j.LoggerFactory"})
          )
          RETURN type.fqn AS InvalidType
        ]]>
    </cypher>
</constraint>

<constraint id="logging:only-logback">
    <description>Ensure only Logback is used as the logging framework.</description>
    <cypher><![CDATA[
    MATCH (dep:Dependency)-[:DEPENDS_ON]->(artifact:Artifact)
    WHERE artifact.groupId IN ['org.slf4j', 'log4j', 'commons-logging', 'java.util.logging']
      AND NOT (artifact.groupId = 'org.slf4j' AND artifact.artifactId IN ['slf4j-api', 'jul-to-slf4j'])
      AND artifact.artifactId <> 'logback-classic'
    RETURN dep.fqn AS InvalidDependency, artifact.groupId AS GroupId, artifact.artifactId AS ArtifactId
    ]]></cypher>
</constraint>

<constraint id="logging:deny-spring-boot-starter-log4j2">
    <description>Deny usage of spring-boot-starter-log4j2</description>
    <cypher><![CDATA[
    MATCH (dep:Dependency)-[:DEPENDS_ON]->(artifact:Artifact)
    WHERE artifact.groupId = 'org.springframework.boot'
    AND artifact.artifactId = 'spring-boot-starter-log4j2'
    AND artifact.version = '3.1.3'
    RETURN dep.fqn AS InvalidDependency, artifact.groupId AS GroupId, artifact.artifactId AS ArtifactId, artifact.version AS Version
]]></cypher>
</constraint>


<group id="default">
    <includeConstraint refId="logging:use-logback"/>
    <includeConstraint refId="logging:only-logback"/>
    <includeConstraint refId="logging:deny-spring-boot-starter-log4j2"/>
</group>

I do not think I need Neo4J unless it's something needed for jqassistant to work. Is there a way to remove this dependency?

How can I make jqassistant run with version 2.4.0 and avoid the Neo4J DB shutdown related to target store format 'AF4.3.0'?


Solution

  • This means that the underlying Neo4j version has changed from 4.x to 5.x and the database cannot be migrated automatically.

    The easiest solution is to delete the store directory target\jqassistant\store (e.g. by using mvn clean).