Description of problem: User had a JAR file with some classes in it and uploaded this into their M2 repository. They then added this as a dependency to their project, but the classes in this jar were not available anywhere within the project for use. Version-Release number of selected component (if applicable): 6.0.0.ER2 How reproducible: Steps to Reproduce: 1. 2. 3. Actual results: Expected results: Additional info:
Created attachment 796669 [details] The added JAR Added the cigna.jar that was trying to be added as a dependency. Please note this .jar is missing dependencies, since the underlying error is a ClassNotFound exception for a class not present in the .jar file. However, this error should be captured and displayed to inform the user that the jar is invalid either at the project import level and/or data modeler level.
The provided cigna.jar file, has a class "Claim" (see below) with a member "private com.cigna.healthcare.claim.Member member;" but the class com.cigna.healthcare.claim.Member is not defined in the jar file. When the build system tries to build the project a class not found exception is thrown. And the user gets an error popup with the following message: Error: "An error occurred when the requested data model was loaded from server". The server error is: "java.lang.ClassNotFoundException:com.cigna.healthcare.claim.Member" public class Claim implements java.io.Serializable{ private static final long serialVersionUID = 1L; private java.util.Date dateOfService; private java.lang.String claimId; private java.math.BigDecimal copay; private java.math.BigDecimal amountNotCovered; private java.math.BigDecimal allowableAmount; private java.lang.String description; private java.math.BigDecimal deductible; private java.math.BigDecimal amountBilled; private java.lang.String code; private java.lang.String patientName; private int age; private java.util.List<com.cigna.healthcare.claim.Service> listOfService; private com.cigna.healthcare.claim.Member member;
When the test was done with a well formed .jar file (see the attached file external-pojos.jar) the following issue was found. 1) go to the "Guvnor M2 Repository Explorer" and upload the "external-pojos.jar" file. 2) Create an empty project 3) Go to the project dependencies and add a dependency to the "external-pojos" maven artifact loaded in step 1) 4) save the project. 5) Open the datamodeler and create a data object X. 6) Add a field Y to the data object X, of type "org.kie.external.ExternalClientBean". (when you click on the field type combobox you will see an option " - ext - org.kie.external.ExternalClientBean". This means that you have a type to select that is form an external dependency). 7) Save the project. 8) When the project is saved you will see the following error in the "Problems window" " org.kie.external.ExternalClientBean cannot be resolved to a type - 240 10 "
Created attachment 798326 [details] external-pojos.jar
The kproject classloader (the one also referring to the classes contained in external jars) was used to compile drl, but not java classes. I fixed this here https://github.com/droolsjbpm/drools/commit/12724f6c5
Using external-pojos.jar as a dependency works just fine - I am able to see packages and class from this jar in Data Modeler, Guided Decision Table Wizard, etc. However, using the cigna.jar results in buggy behaviour of all editors I tried with: Guided Rule editor: Opens with white screen, no ability to edit, error message appears - see the attached screenshots. Guided Decision Table: the same behaviour as Guided Rule editor. I case GDT with wizard has been chosen, the table cannot be even created - clicking on "OK" on "Create new" screen is without any response. Data Modeler: Error message appears, after that there are no classes and no packages available. I expected to see classes and packages from the project and from other JAR files, but there is simply nothing. I wonder if the JAR with unsatisfied dependencies could be somehow isolated and user informed about this JAR won't be included in the project? Using such a JAR as project's dependency should not break Business Central in this way.
Created attachment 813710 [details] error message - Data Modeler
Created attachment 813711 [details] error message - Guided Rule editor
Walter, can you clarify what you mean by well formed jar ? Are there steps user should take defining the dependencies and/or create some definition file before uploading it ? If so, it needs to be documented clearly. Also, there should be appropriate error shown to the user if uploaded file does not meet the definition.
There's no much I can do on the core side about this. I am reassigning this ticket to Walter who will trigger the project building in a try/catch block in order to try to report the problems encountered during the compilation phase in a more graceful way.
Additional verification was added in order to detect mal formed .jars like the cigna.jar as earlier as possible. Typically when we manage the dependencies for a given project. When we set the dependencies for a project and save it, the project is compiled. At this moment we will try to detect also errors in the dependencies .jar files. Obviously an external .jar file can have whatever thing, and eventually can come from whatever origin. So it can always have errors that we cant detect, etc. With the verification added we can at least detect some mal formed cases like the cigna.jar and give some feedback to the user in the "Problems" widget. When the user saves the project, If we detect an error in the dependencies jars It will be informed in the "Problems" widget. In the attached screen I show the error message that the user will get when he updates de dependencies for a proyect using the cigna.jar file. (You must save the project in order to materialize the changes and do the internal verification) Responding the previous query, a "well formed .jar file" in this context is a .jar file that don't have missing clases like the cignar.jar. The cigna.jar file isn't well formed, because it have the following scenario. A class X uses a class Y, but the class Y is not in the .jar file, and that's why this cigna.jar file generates the error.
Created attachment 815438 [details] Dependencies check
The described improvement was implemented in the following commits. master: http://github.com/droolsjbpm/guvnor/commit/b8eefe4bd 6.0.x: http://github.com/droolsjbpm/guvnor/commit/2349445b
Verified on BRMS-6.0.0.ER5