tonisojandu-sympower commented on issue #11819:
URL: https://github.com/apache/pulsar/issues/11819#issuecomment-2624528129
We used to use the unshaded Pulsar clients because of this issue but we had
to stop doing so once we upgraded to Spring 3.x because there was a conflict
with the Jersey HTTP client upgrade that came with Spring upgrade. This is when
we forked the Pulsar client and unshaded the Avro from the client.
I tried it again to see if the issue had been resolved. However, it still
seems to be there. The error is a bit obscure and confusing.
```
SpringPulsarOriginalConflictApplicationTests > contextLoads() FAILED
java.lang.LinkageError: ClassCastException: attempting to
castjar:file:/home/runner/.gradle/caches/modules-2/files-2.1/javax.ws.rs/javax.ws.rs-api/2.1.1/d3466bc9321fe84f268a1adb3b90373fc14b0eb5/javax.ws.rs-api-2.1.1.jar!/javax/ws/rs/client/ClientBuilder.class
to
jar:file:/home/runner/.gradle/caches/modules-2/files-2.1/javax.ws.rs/javax.ws.rs-api/2.1.1/d3466bc9321fe84f268a1adb3b90373fc14b0eb5/javax.ws.rs-api-2.1.1.jar!/javax/ws/rs/client/ClientBuilder.class
at javax.ws.rs.client.ClientBuilder.newBuilder(ClientBuilder.java:81)
at
org.apache.pulsar.client.admin.internal.PulsarAdminImpl.<init>(PulsarAdminImpl.java:142)
at
org.apache.pulsar.client.admin.internal.PulsarAdminBuilderImpl.build(PulsarAdminBuilderImpl.java:45)
at
net.sympower.spring_pulsar_original_conflict.SpringPulsarOriginalConflictApplicationTests.contextLoads(SpringPulsarOriginalConflictApplicationTests.kt:19)
```
Based on some googling and seeing that there are javax/jakarta
`.withConfig(httpConfig)` for `ClientBuilder` when I browse `PulsarAdminImpl`
with my IDE, I guess that it is still the same problem.
I created [a repository to demonstrate this
issue](https://github.com/tonisojandu-sympower/spring-pulsar-original-conflict)
and
[here is the error
itself](https://github.com/tonisojandu-sympower/spring-pulsar-original-conflict/actions/runs/13051328059/job/36412066651#step:4:2247).
Something else interesting I discovered when I tried to recreate the Avro
logical type serialization issue in my testbed is that `pulsar-client-admin`
does not shade Avro classes, so due to classpath race between the regular
client and the admin client, this issue did not manifest when admin was
classpath.
Here is what the Pulsar `AvroWriter` references in the shaded Admin client:
```
javap -c
./pulsar-client-admin-4.0.2.jar-out/org/apache/pulsar/client/impl/schema/writer/AvroWriter.class
| grep avro
public
org.apache.pulsar.client.impl.schema.writer.AvroWriter(org.apache.avro.Schema);
3: invokespecial #21 // Method
"<init>":(Lorg/apache/avro/Schema;Z)V
public
org.apache.pulsar.client.impl.schema.writer.AvroWriter(org.apache.avro.Schema,
boolean);
16: invokestatic #40 // Method
org/apache/avro/io/EncoderFactory.get:()Lorg/apache/avro/io/EncoderFactory;
24: invokevirtual #44 // Method
org/apache/avro/io/EncoderFactory.binaryEncoder:(Ljava/io/OutputStream;Lorg/apache/avro/io/BinaryEncoder;)Lorg/apache/avro/io/BinaryEncoder;
27: putfield #46 // Field
encoder:Lorg/apache/avro/io/BinaryEncoder;
30: new #48 // class
org/apache/avro/reflect/ReflectData
34: invokespecial #49 // Method
org/apache/avro/reflect/ReflectData."<init>":()V
40: invokestatic #55 // Method
org/apache/pulsar/client/impl/schema/AvroSchema.addLogicalTypeConversions:(Lorg/apache/avro/reflect/ReflectData;Z)V
44: new #57 // class
org/apache/avro/reflect/ReflectDatumWriter
50: invokespecial #60 // Method
org/apache/avro/reflect/ReflectDatumWriter."<init>":(Lorg/apache/avro/Schema;Lorg/apache/avro/reflect/ReflectData;)V
53: putfield #62 // Field
writer:Lorg/apache/avro/reflect/ReflectDatumWriter;
public org.apache.avro.io.BinaryEncoder getEncoder();
1: getfield #46 // Field
encoder:Lorg/apache/avro/io/BinaryEncoder;
3: getfield #62 // Field
writer:Lorg/apache/avro/reflect/ReflectDatumWriter;
8: getfield #46 // Field
encoder:Lorg/apache/avro/io/BinaryEncoder;
11: invokevirtual #77 // Method
org/apache/avro/reflect/ReflectDatumWriter.write:(Ljava/lang/Object;Lorg/apache/avro/io/Encoder;)V
15: getfield #46 // Field
encoder:Lorg/apache/avro/io/BinaryEncoder;
18: invokevirtual #82 // Method
org/apache/avro/io/BinaryEncoder.flush:()V
65: getfield #46 // Field
encoder:Lorg/apache/avro/io/BinaryEncoder;
68: invokevirtual #82 // Method
org/apache/avro/io/BinaryEncoder.flush:()V
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]