apache / incubator-kie-kogito-examples

Kogito examples - Kogito is a cloud-native business automation technology for building cloud-ready business applications.
http://kogito.kie.org
255 stars 380 forks source link

Cannot find class info in jandex index for short #1100

Closed Dantes-Damir closed 2 years ago

Dantes-Damir commented 2 years ago

In project process-postgresql-persistence-quarkus, i added variable: private short number; in Traveller class: public class Traveller {

private String firstName;
private String lastName;
private String email;
private String nationality;

private Address address;
private short number;

public Traveller() {

}

...

And i got this exception: Caused by: java.lang.IllegalStateException: Cannot find class info in jandex index for short and 2022-01-21 16:30:00,460 WARN [io.qua.dep.ste.CombinedIndexBuildStep] (build-13) Failed to index short: Class does not exist in ClassLoader QuarkusClassLoader:Deployment Class Loader: DEV@e19bb76

Full log from maven: fullLog.txt

fjtirado commented 2 years ago

@evacchi Looks like short is not supported in jandex?

evacchi commented 2 years ago

looks like a classloader-related issue. Which version of Quarkus? /cc @aloubyansky

Dantes-Damir commented 2 years ago

@evacchi you can download this project from https://github.com/kiegroup/kogito-examples/tree/stable/kogito-quarkus-examples/process-postgresql-persistence-quarkus stable version and try to add private short number in Traveler class. Here is the pom: pom.txt

Dantes-Damir commented 2 years ago

And i got the same error in our project: 2022-01-24 10:38:46,590 DEBUG [io.qua.dep.ste.CombinedIndexBuildStep] (build-4) Index: [I 2022-01-24 10:38:46,591 WARN [io.qua.dep.ste.CombinedIndexBuildStep] (build-4) Failed to index [I: Class does not exist in ClassLoader QuarkusClassLoader:Deployment Class Loader: DEV@7d9e8ef7

I can't share this business model, but it's valid model, it's used in production. So i can't understand what is "[I".

aloubyansky commented 2 years ago

I'll look into this.

Dantes-Damir commented 2 years ago

I understood than this error appears when we use java.math.BigDecimal. @evacchi In our project we tried to use diffrent versions of quarkus, from 2.6.0 to 2.6.3.Final

2.6.3.Final
aloubyansky commented 2 years ago

@Dantes-Damir should there be anything more than changing the Traveller class and launch dev mode? I did the following

[aloubyansky@localhost process-postgresql-persistence-quarkus]$ git diff
diff --git a/kogito-quarkus-examples/process-postgresql-persistence-quarkus/src/main/java/org/acme/deals/Traveller.java b/kogito-quarkus-examples/process-postgresql-persistence-quarkus/src/main/java/org/acme/deals/Traveller.java
index 02e90894..f980087a 100644
--- a/kogito-quarkus-examples/process-postgresql-persistence-quarkus/src/main/java/org/acme/deals/Traveller.java
+++ b/kogito-quarkus-examples/process-postgresql-persistence-quarkus/src/main/java/org/acme/deals/Traveller.java
@@ -22,6 +22,7 @@ public class Traveller {
     private String email;
     private String nationality;
     private Address address;
+    private java.math.BigDecimal number;

     public Traveller() {

@@ -75,6 +76,14 @@ public class Traveller {
         this.address = address;
     }

+    public java.math.BigDecimal getNumber() {
+        return number;
+    }
+
+    public void setNumber(java.math.BigDecimal number) {
+        this.number = number;
+    }
+

Also tried short. Haven't seen any error yet. Quarkus 2.6.2.Final. Thanks.

Dantes-Damir commented 2 years ago

@aloubyansky Did you start project with -Ppersistence?

aloubyansky commented 2 years ago

No, that's what I was missing. Thanks.

Dantes-Damir commented 2 years ago

Hi @aloubyansky! Is there any solution for my problem? Maybe any walkaround? Thanks.

aloubyansky commented 2 years ago

Sorry, haven't figured it out yet.

debu999 commented 2 years ago

We too get the same road block. Had zonedatetime or localdate in the process variable. Getting error for short not in jandex. Google protobuf have timestamp and date. Is there anything by which we can specify which datatype to convert. Currently only String, Integer, Long, Double, Boolean, Date works. We can't add any other data type on kogito Using 1.16.0.Final and 2.7.0.Final quarkus. Something in kogito code gen causing the issue.

Also quarkus-kogito-bom is missing 2.7.0.Final build last bild is 2.7.0.CR1.

Please opine on the fix if we need to do any change to fix

aloubyansky commented 2 years ago

@evacchi it doesn't look like a classloading issue to me but something that should be fixed in the proto generator, e.g.

diff --git a/quarkus/extensions/kogito-quarkus-processes-extension/kogito-quarkus-processes-deployment/src/main/java/org/kie/kogito/quarkus/processes/deployment/JandexProtoGenerator.java b/quarkus/extensions/kogito-quarkus-processes-extension/kogito-quarkus-processes-deployment/src/main/java/org/kie/kogito/quarkus/processes/deployment/JandexProtoGenerator.java
index d1d3bdd70e..65c60692a7 100644
--- a/quarkus/extensions/kogito-quarkus-processes-extension/kogito-quarkus-processes-deployment/src/main/java/org/kie/kogito/quarkus/processes/deployment/JandexProtoGenerator.java
+++ b/quarkus/extensions/kogito-quarkus-processes-extension/kogito-quarkus-processes-deployment/src/main/java/org/kie/kogito/quarkus/processes/deployment/JandexProtoGenerator.java
@@ -149,6 +149,9 @@ public class JandexProtoGenerator extends AbstractProtoGenerator<ClassInfo> {
                 }
                 fieldType = typeParameters.get(0).name();
                 protoType = protoType(fieldType.toString());
+            } else if(pd.type().kind() == Kind.ARRAY) {
+                fieldTypeString = "Collection";
+                protoType = protoType(pd.type().asArrayType().component().toString());
             } else {

With that I get passed that error but then it fails with

2022-02-08 18:47:41,649 DEBUG [org.kie.kog.cod.cor.ApplicationGenerator] (build-39) =====
2022-02-08 18:47:42,347 ERROR [org.kie.kog.qua.com.dep.InMemoryCompiler] (build-5) src/main/java/org/kie/kogito/persistence/KogitoProcessInstancesFactoryImpl.java (11:609) : The constructor KogitoProcessInstancesFactory(DataSource, Boolean) is undefined
2022-02-08 18:47:42,347 ERROR [org.kie.kog.qua.com.dep.InMemoryCompiler] (build-5) src/main/java/org/kie/kogito/app/BigDecimalMessageMarshaller.java (32:1158) : The constructor BigDecimal() is undefined
2022-02-08 18:47:42,348 ERROR [org.kie.kog.qua.com.dep.InMemoryCompiler] (build-5) src/main/java/org/kie/kogito/app/BigDecimalMessageMarshaller.java (33:1200) : The method setIntVal(reader.readObject("intVal", java.math.BigInteger.class)) is undefined for the type BigDecimal
2022-02-08 18:47:42,348 ERROR [org.kie.kog.qua.com.dep.InMemoryCompiler] (build-5) src/main/java/org/kie/kogito/app/BigDecimalMessageMarshaller.java (39:1480) : The method getIntVal() is undefined for the type BigDecimal
2022-02-08 18:47:42,348 ERROR [org.kie.kog.qua.com.dep.InMemoryCompiler] (build-5) src/main/java/org/kie/kogito/app/BigDecimalMessageMarshaller.java (40:1557) : The method getScale() is undefined for the type BigDecimal
2022-02-08 18:47:42,349 ERROR [org.kie.kog.qua.com.dep.InMemoryCompiler] (build-5) src/main/java/org/kie/kogito/app/BigIntegerMessageMarshaller.java (32:1158) : The constructor BigInteger() is undefined
2022-02-08 18:47:42,349 ERROR [org.kie.kog.qua.com.dep.InMemoryCompiler] (build-5) src/main/java/org/kie/kogito/app/BigIntegerMessageMarshaller.java (33:1200) : The method setBitCountPlusOne(Integer) is undefined for the type BigInteger
2022-02-08 18:47:42,349 ERROR [org.kie.kog.qua.com.dep.InMemoryCompiler] (build-5) src/main/java/org/kie/kogito/app/BigIntegerMessageMarshaller.java (34:1269) : The method setBitLengthPlusOne(Integer) is undefined for the type BigInteger
2022-02-08 18:47:42,350 ERROR [org.kie.kog.qua.com.dep.InMemoryCompiler] (build-5) src/main/java/org/kie/kogito/app/BigIntegerMessageMarshaller.java (35:1340) : The method setFirstNonzeroIntNumPlusTwo(Integer) is undefined for the type BigInteger
2022-02-08 18:47:42,350 ERROR [org.kie.kog.qua.com.dep.InMemoryCompiler] (build-5) src/main/java/org/kie/kogito/app/BigIntegerMessageMarshaller.java (36:1429) : The method setLowestSetBitPlusTwo(Integer) is undefined for the type BigInteger
2022-02-08 18:47:42,351 ERROR [org.kie.kog.qua.com.dep.InMemoryCompiler] (build-5) src/main/java/org/kie/kogito/app/BigIntegerMessageMarshaller.java (37:1506) : The method setMag(reader.readCollection("mag", new java.util.ArrayList(), Integer.class)) is undefined for the type BigInteger
2022-02-08 18:47:42,351 ERROR [org.kie.kog.qua.com.dep.InMemoryCompiler] (build-5) src/main/java/org/kie/kogito/app/BigIntegerMessageMarshaller.java (38:1600) : The method setSignum(Integer) is undefined for the type BigInteger
2022-02-08 18:47:42,352 ERROR [org.kie.kog.qua.com.dep.InMemoryCompiler] (build-5) src/main/java/org/kie/kogito/app/BigIntegerMessageMarshaller.java (43:1806) : The method getBitCountPlusOne() is undefined for the type BigInteger
2022-02-08 18:47:42,352 ERROR [org.kie.kog.qua.com.dep.InMemoryCompiler] (build-5) src/main/java/org/kie/kogito/app/BigIntegerMessageMarshaller.java (44:1875) : The method getBitLengthPlusOne() is undefined for the type BigInteger
2022-02-08 18:47:42,353 ERROR [org.kie.kog.qua.com.dep.InMemoryCompiler] (build-5) src/main/java/org/kie/kogito/app/BigIntegerMessageMarshaller.java (45:1954) : The method getFirstNonzeroIntNumPlusTwo() is undefined for the type BigInteger
2022-02-08 18:47:42,353 ERROR [org.kie.kog.qua.com.dep.InMemoryCompiler] (build-5) src/main/java/org/kie/kogito/app/BigIntegerMessageMarshaller.java (46:2036) : The method getLowestSetBitPlusTwo() is undefined for the type BigInteger
2022-02-08 18:47:42,354 ERROR [org.kie.kog.qua.com.dep.InMemoryCompiler] (build-5) src/main/java/org/kie/kogito/app/BigIntegerMessageMarshaller.java (47:2103) : The method getMag() is undefined for the type BigInteger
2022-02-08 18:47:42,354 ERROR [org.kie.kog.qua.com.dep.InMemoryCompiler] (build-5) src/main/java/org/kie/kogito/app/BigIntegerMessageMarshaller.java (48:2165) : The method getSignum() is undefined for the type BigInteger
aloubyansky commented 2 years ago

Or possibly org.kie.kogito.codegen.process.persistence.proto.ProtoGenerator.protoType(type) should recognize BigDecimal in similar way it recognizes Date?

aloubyansky commented 2 years ago

@debu999 fyi, 2.7.1.Final has been released today which includes Kogito.

debu999 commented 2 years ago

Thanks @aloubyansky on the info. A new feature request is added to kogito for including other date formats for marshalling.

https://issues.redhat.com/browse/KOGITO-6756 Hope to use few additional data types soon. Will definitely try out kogito with quarkus inn2.7.1.Final today and share update

cristianonicolai commented 2 years ago

Fixed on Kogito 1.18, feel free to reopen if issue is not resolved completely.