Using Panache with embedded documents: Can't find codec (JVM mode)

466 views
Skip to first unread message

Jonathan Roques

unread,
May 11, 2021, 5:37:52 AM5/11/21
to Quarkus Development mailing list
Hey,

I've encountered an issue using panache. I have a lib (commons.jar) which contains a class names Workflow. This class has an attribute called 'steps' which a list of step.

@MongoEntity(collection = "Workflow")
@RegisterForReflection
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Workflow {
      public List<Step> steps = new LinkedList<>();
}

// No annotations here but I tried with @RegisterForReflection also
public class Step {
  public int durationDays;
  public String name;
  public ObjectId id = new ObjectId();

  public Step() {}
}

This lib is used in another quarkus project.
But as soon as I wan't to read/write a Workflow I have this error :

org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class com.clozzle.commons.model.workflows.Step.
...

I know I could just use a stepId and have a separate collection, but I wan't to understand the issue here.

Thanks for you help :)

Loïc MATHIEU

unread,
May 11, 2021, 6:01:52 AM5/11/21
to jonatha...@clozzle.com, Quarkus Development mailing list
Hi,

Better use stackoverflow for this type of questions and provides the stacktrace.
But I guess the issue is that your common jar is not indexed by Jandex.

Quarkus uses Jandex to discover at build time the classes of your application, when using a separate jar for some classes, some extensions (and MongoDB with Panache is one of them), will need a Jandex index to be created for this external jar.

You can read this section for how to create a Jandex index for an external jar: https://quarkus.io/guides/cdi-reference#how-to-generate-a-jandex-index

--
You received this message because you are subscribed to the Google Groups "Quarkus Development mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to quarkus-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/quarkus-dev/c98a948f-c963-4fcf-869e-b334e3b4e3fan%40googlegroups.com.

Jonathan Roques

unread,
May 11, 2021, 9:11:49 AM5/11/21
to Quarkus Development mailing list
Hi,

Sorry for posting here and thanks for your reply. 
I know jandex, and I have a very strange behaviour. Everything works well when I : 

1. gradle clean my project
2. quarkusBuild my project
3. quarkusDev my project 

But then, when I stop quarkusDev (via IntelliJ) and restart it I always have the Codec error. It's like some file is deleted when the app is run the first time with quarkusDev ... Am I missing something ?

Loïc MATHIEU

unread,
May 11, 2021, 9:37:12 AM5/11/21
to jonatha...@clozzle.com, Quarkus Development mailing list
Strange, definitely need a reproducer.
If you can reproduce it, open an issue.

Jonathan Roques

unread,
May 11, 2021, 9:43:26 AM5/11/21
to Quarkus Development mailing list
It's ok, I think I'll switch back to Spring boot. I lost a few weeks on multiple issues (some with aws libs, some with quarkus), and I can't afford more.

I'll try to make a post on this dev list explaining why I switched back, so that you can identify how users struggle with Quarkus. So that my experience could be useful to someone. 

Thanks again

Reply all
Reply to author
Forward
0 new messages