Skip to content

Wrong classpath at runtime when the maven project is in a folder #584

Description

@dmarrazzo

Launching vscode in the maven root folder, the debug is able to manage correctly the classpath.
Whereas when vscode is launched in the parent folder (that contains more maven projects) it fails to execute the project due to a wrong classpath evaluation.
In order to debug, I've added those lines at the beginning of the main:

        try {
            Class.forName("org.drools.compiler.commons.jci.readers.ResourceReader");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        ClassLoader cl = EmbedMain.class.getClassLoader();

        URL[] urls = ((URLClassLoader) cl).getURLs();

        for (URL url : urls) {
            System.out.println(url.getFile());
        }

The output (attached) shows that the classpath is significantly different:

parent.txt

inner.txt

Linked issue:

redhat-developer/vscode-java#925

Environment
  • Operating System: Linux Fedora 30

  • JDK version: penjdk version "1.8.0_212"
    OpenJDK Runtime Environment (build 1.8.0_212-b04)
    OpenJDK 64-Bit Server VM (build 25.212-b04, mixed mode)

  • Visual Studio Code version: 1.34

  • Java extension version: 0.44.0

  • pref
    "java.home": "/usr/lib/jvm/java-1.8.0-openjdk/",
    "java.jdt.ls.vmargs": "-noverify -Xmx3G -Xss128M -XX:+UseG1GC -XX:+UseStringDeduplication",

Steps To Reproduce
  1. import projects:
    https://gitlab.com/ba-demos/dmn-insurance/insurance-decision
    https://gitlab.com/ba-demos/dmn-insurance/kie-client

  2. install decision project

cd insurance-decision
mvn clean install
  1. running the client from maven, it works as expected
mvn clean exec:java
  1. Launch vscode inside kie-client project:
  • execute client.EmbedMain
  • the program runs with no error
  1. Launch vscode in the parent folder of the kie-client project:
  • open and execute the class: client.EmbedMain
Current Result

Loading failed because Cannot create instance of class:

org.kie.pmml.assembler.PMMLAssemblerService
Exception in thread "main"
java.lang.ExceptionInInitializerError
	at org.kie.api.internal.utils.ServiceRegistry.getInstance(ServiceRegistry.java:27)
ServiceRegistry.java:27
	at org.kie.api.KieServices$Factory$LazyHolder.<clinit>(KieServices.java:341)
	at org.kie.api.KieServices$Factory.get(KieServices.java:348)
(...)
Expected Result

it runs with no error and completes with:

(...)
DMNResultImpl{context={
    PreviousIncidents: false
    Age: 28
    CarAge: 3
    Insurance Base Price: 1000
    Car reliability factor: function Car reliability factor( car age )
    FinalPrice: 1100.0
}
, messages=org.kie.dmn.core.util.DefaultDMNMessagesManager@102d92c4}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions