Custom serialize on remote ejb invoke

I have class

@javax.json.bind.annotation.JsonbTypeSerializer(Serializer.class)
@jakarta.json.bind.annotation.JsonbTypeSerializer(JakartaSerializer.class)
public final class DataModel implements Comparable<DataModel>, Serializable {

}

and Serializer’s
public class JakartaSerializer implements JsonbSerializer<DataModel> {

}
public class Serializer implements JsonbSerializer<DataModel> {

}

When i invoke remote ejb with
<dependency>
<groupId>fish.payara.extras</groupId>
<artifactId>ejb-http-client</artifactId>
<version>5.2022.5</version>
</dependency>
custom serializer work perfect

When i use
<dependency>
<groupId>fish.payara.extras</groupId>
<artifactId>ejb-http-client</artifactId>
<version>6.2023.10</version>
</dependency>
custom serializer don’t work.
What am I doing wrong?

Hi Max,
let me double-check:
Do you have 2 sources, 1 for Jakarta 8/javax and one for Jakarta 10/jakarta or just one source with both dependencies and annotations?

If you have both, I suppose you use JsonbSerializer from the javax package. This would result in Jakarta 10 not finding this serializer.

Regards,
Petr

Hi Petr,

I simplified the example.
I use only jakarta10.

@jakarta.json.bind.annotation.JsonbTypeSerializer(JakartaSerializer.class)
@jakarta.json.bind.annotation.JsonbTypeDeserializer(JakartaDeserializer.class)
public final class DataModel implements Comparable<DataModel>, Serializable {

}

and Serializer/Deserializer

import jakarta.json.bind.serializer.JsonbSerializer;
import jakarta.json.bind.serializer.SerializationContext;
import jakarta.json.stream.JsonGenerator;

public class JakartaSerializer implements JsonbSerializer<DataModel> {
@Override
public void serialize(DataModel dataModel, JsonGenerator jsonGenerator, SerializationContext serializationContext) {
System.out.println(“Jakarta serialize”);
}
}

import jakarta.json.bind.serializer.DeserializationContext;
import jakarta.json.bind.serializer.JsonbDeserializer;
import jakarta.json.stream.JsonParser;

import java.lang.reflect.Type;

public class JakartaDeserializer implements JsonbDeserializer<DataModel> {
@Override
public DataModel deserialize(JsonParser jsonParser, DeserializationContext deserializationContext, Type type) {
System.out.println(“Jakarta deserializer”);
return null;
}
}

When i use
Jsonb jsonb = JsonbBuilder.create();
jsonb.toJson(model);
custom serializer run perfectly.

When i run
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, RemoteEJBContextFactory.FACTORY_CLASS);
properties.put(Context.PROVIDER_URL, “http://localhost:8080/ejb-invoker”);
Context context = new InitialContext(properties);
TestRemote lookup = (TestRemote) context.lookup(“java:global/MyApp/Test!” + TestRemote.class.getName());
lookup.test(model);

Custom serializer don’t run. (Custom deserializer run perfectly)

Hi Max,
sorry of late response – holidays…

Summary, what I understand so far:

  • remote HTTP EJB from an application client
  • custom serializer and deserializer for a DataModel class
  • Interface TestRemote has method test with DataModel parameter
  • Payara version 5 worked
  • Payara version 6 – deserializer works, serializer doesn’t

What “Custom serializer don’t run.” exactly means? Does it throw any error? I suppose it doesn’t stop in debugger in the serialize method.

It seems to me as a potential bug. Do you have/can you prepare some simple reproducer and report the problem via GitHub?