Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kogito MapMessageMarshaller throws an error java.util.Map is abstract; cannot be instantiated for Map Property in class #3176

Open
a-kshesh opened this issue Aug 15, 2023 · 4 comments

Comments

@a-kshesh
Copy link

Describe the bug

I am using the process-postgresql-persistence-quarkus example on my MAC to showcase my problem and in there for Address.java class, I changed String city; to private Map<String, String> city; which leads to an error as

java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
        [error]: Build step org.kie.kogito.quarkus.processes.deployment.ProcessesAssetsProcessor#postGenerationProcessing threw an exception: org.kie.memorycompiler.KieMemoryCompilerException: [org/kie/kogito/app/MapMessageMarshaller.java (32:31) : java.util.Map is abstract; cannot be instantiated]
        at org.kie.memorycompiler.KieMemoryCompiler.compileNoLoad(KieMemoryCompiler.java:137)
        at org.kie.memorycompiler.KieMemoryCompiler.compileNoLoad(KieMemoryCompiler.java:105)
        at org.drools.drl.quarkus.util.deployment.DroolsQuarkusResourceUtils.compileGeneratedSources(DroolsQuarkusResourceUtils.java:155)
        at org.kie.kogito.quarkus.workflow.deployment.WorkflowProcessor.generatePersistenceInfo(WorkflowProcessor.java:216)
        at org.kie.kogito.quarkus.workflow.deployment.WorkflowProcessor.postGenerationProcessing(WorkflowProcessor.java:181)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:909)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:281)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
        at java.base/java.lang.Thread.run(Thread.java:833)
        at org.jboss.threads.JBossThread.run(JBossThread.java:501)

        at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:335)
        at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:252)
        at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:60)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.firstStart(IsolatedDevModeMain.java:86)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:447)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:59)
        at io.quarkus.bootstrap.app.CuratedApplication.runInCl(CuratedApplication.java:149)
        at io.quarkus.bootstrap.app.CuratedApplication.runInAugmentClassLoader(CuratedApplication.java:104)
        at io.quarkus.deployment.dev.DevModeMain.start(DevModeMain.java:131)
        at io.quarkus.deployment.dev.DevModeMain.main(DevModeMain.java:62)
Caused by: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
        [error]: Build step org.kie.kogito.quarkus.processes.deployment.ProcessesAssetsProcessor#postGenerationProcessing threw an exception: org.kie.memorycompiler.KieMemoryCompilerException: [org/kie/kogito/app/MapMessageMarshaller.java (32:31) : java.util.Map is abstract; cannot be instantiated]
        at org.kie.memorycompiler.KieMemoryCompiler.compileNoLoad(KieMemoryCompiler.java:137)
        at org.kie.memorycompiler.KieMemoryCompiler.compileNoLoad(KieMemoryCompiler.java:105)
        at org.drools.drl.quarkus.util.deployment.DroolsQuarkusResourceUtils.compileGeneratedSources(DroolsQuarkusResourceUtils.java:155)
        at org.kie.kogito.quarkus.workflow.deployment.WorkflowProcessor.generatePersistenceInfo(WorkflowProcessor.java:216)
        at org.kie.kogito.quarkus.workflow.deployment.WorkflowProcessor.postGenerationProcessing(WorkflowProcessor.java:181)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:909)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:281)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
        at java.base/java.lang.Thread.run(Thread.java:833)
        at org.jboss.threads.JBossThread.run(JBossThread.java:501)

        at io.quarkus.builder.Execution.run(Execution.java:123)
        at io.quarkus.builder.BuildExecutionBuilder.execute(BuildExecutionBuilder.java:79)
        at io.quarkus.deployment.QuarkusAugmentor.run(QuarkusAugmentor.java:160)
        at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:331)
        ... 9 more
Caused by: org.kie.memorycompiler.KieMemoryCompilerException: [org/kie/kogito/app/MapMessageMarshaller.java (32:31) : java.util.Map is abstract; cannot be instantiated]
        at org.kie.memorycompiler.KieMemoryCompiler.compileNoLoad(KieMemoryCompiler.java:137)
        at org.kie.memorycompiler.KieMemoryCompiler.compileNoLoad(KieMemoryCompiler.java:105)
        at org.drools.drl.quarkus.util.deployment.DroolsQuarkusResourceUtils.compileGeneratedSources(DroolsQuarkusResourceUtils.java:155)
        at org.kie.kogito.quarkus.workflow.deployment.WorkflowProcessor.generatePersistenceInfo(WorkflowProcessor.java:216)
        at org.kie.kogito.quarkus.workflow.deployment.WorkflowProcessor.postGenerationProcessing(WorkflowProcessor.java:181)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:909)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:281)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
        at java.base/java.lang.Thread.run(Thread.java:833)
        at org.jboss.threads.JBossThread.run(JBossThread.java:501)

Expected behavior

Mapmarshller throws that java.util.Map is abstract; cannot be instantiated. I tried to instantiate it private Map<String, String> city; = new HashMap<String,String>(); but it throws the same error. Kindly please advise on what needs to be done.

Thanks.

Actual behavior

I expect it to accept the Map abstract data type.

How to Reproduce?

Reproducer:

process-postgresql-persistence-quarkus example to showcase my problem and in there for Address.java class, I changed private String city; to private Map<String, String> city;
If I remove the kogito-addons-quarkus-persistence-jdbc dependency from the project then it works as expected.

Output of uname -a or ver

No response

Output of java -version

openjdk version "17.0.7" 2023-04-18

GraalVM version (if different from Java)

No response

Kogito version or git rev (or at least Quarkus version if you are using Kogito via Quarkus platform BOM)

quarkus platform version 2.16.8.Final

Build tool (ie. output of mvnw --version or gradlew --version)

maven- 17

Additional information

I am not specifying the version of kogito-addons-quarkus-persistence-jdbc so I am assuming that it uses a current stable version of that.

@radtriste
Copy link
Contributor

@a-kshesh Could you try this ?

private HashMap<String, String> city;

cc @baldimir @fjtirado @cristianonicolai

@a-kshesh
Copy link
Author

@radtriste Thanks. I tried HashMap and it is working.
May I know why it is not able to instantiates the Map interface or do I have to explicitly do that?

@radtriste
Copy link
Contributor

@radtriste Thanks. I tried HashMap and it is working. May I know why it is not able to instantiates the Map interface or do I have to explicitly do that?

This was just a guess.

@mariofusco @danielezonca @tarilabs @tkobayas may help more on that

@tkobayas
Copy link
Contributor

I tested the same and found this Java code generated internally.

package org.kie.kogito.app;

import java.io.IOException;
import org.infinispan.protostream.MessageMarshaller;

public class MapMessageMarshaller implements MessageMarshaller<java.util.Map> {

    public java.lang.Class<java.util.Map> getJavaClass() {
        return java.util.Map.class;
    }

    public String getTypeName() {
        return "org.kie.kogito.app.Map";
    }

    public java.util.Map readFrom(ProtoStreamReader reader) throws IOException {
        java.util.Map value = new java.util.Map();
        return value;
    }

    public void writeTo(ProtoStreamWriter writer, java.util.Map t) throws IOException {
    }
}

The readFrom method is generated here: https://github.com/kiegroup/kogito-runtimes/blob/1.42.0.Final/kogito-codegen-modules/kogito-codegen-processes/src/main/java/org/kie/kogito/codegen/process/persistence/marshaller/AbstractMarshallerGenerator.java#L172-L173

I think the process team can look at this whether it should be fixed or is an expected behaviour. @cristianonicolai

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 📋 Backlog
Development

No branches or pull requests

3 participants