Hi Jason,
I really appreciate your attention on this issue.
As we have described, the duplicate class error is popped up when we declare
both dependency on dubbo and dubbo-serialization-kryo (as we need third-party
dependencies required by dubbo-serialization-kryo):
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo</artifactId>
<version>${dubbo.version}</version>
<exclusions>
<exclusion>
<groupId>com.apache.dubbo</groupId>
<artifactId>dubbo-common</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-serialization-kryo</artifactId>
<version>${dubbo.version}</version>
<exclusions>
<exclusion>
<groupId>com.apache.dubbo</groupId>
<artifactId>dubbo-common</artifactId>
</exclusion>
</exclusions>
</dependency>
Of course, we can still avoid the "Duplicate class" ERROR by declaring
dependency only on dubbo, plus the kryo library that dubbo-serialization-kryo
uses:
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo</artifactId>
<version>${dubbo.version}</version>
</dependency>
<dependency>
<groupId>com.esotericsoftware</groupId>
<artifactId>kryo</artifactId>
<version>4.0.1</version>
</dependency>
If you really need a project for quicker reproduction, I can make a github
project. The content will most likely just these poms.
Best
Tien Dat
On 2019/10/25 13:13:29, Jason Joo <[email protected]> wrote:
> Hi, tien,
>
> Err, I don't think the error message of duplicated class is a normal thing,
> could you upload a sample to reproduce it?
>
> best regards,
>
> Jason
>
> > On Oct 25, 2019, at 19:15, Tien Dat PHAN <[email protected]> wrote:
> >
> > Hi Jason,
> >
> > Thanks for asking. Everything is working if we add this directly.
> > And we understand your concern about having conflicting dependencies with
> > our application dependencies.
> > And this is at the end a tradeoff between memory footprint optimization vs
> > software project management efficiency.
> >
> > Our application does not need specifically com.esotericsoftware.kryo. This
> > is needed only by org.apache.dubbo:dubbo-serialization-kryo. And we really
> > don't like the fact that we need to repeat the dependency declaration on
> > this library, which is already defined by
> > org.apache.dubbo:dubbo-serialization-kryo, but got ignored. Moreover, if we
> > upgrade Dubbo version, we have to go check the new version of
> > com.esotericsoftware.kryo used by the new Dubbo, and update it accordingly.
> >
> > At the end, I think we will accept the ERROR message on "Duplicate class".
> > As their is no win-win solution for this case.
> >
> > Best regards
> > Dat
> >
> > On 2019/10/25 10:47:32, Jason Joo <[email protected]> wrote:
> >> Tien,
> >>
> >> It makes sense because it (and others like this) is an optional extension
> >> / support / function. We should decide to introduce the extra dependencies
> >> it requires when we enable it in configuration compared to the default.
> >> Another similar thing is that which driver you should introduce among
> >> zookeeper / nacos / redis / others depends which implementation of
> >> registry you want to use and actually config.
> >>
> >> In most cases the version may not matter so much but you'd better to pick
> >> it carefully to match just or newer to the version dubbo uses by default.
> >>
> >> So is everything going well now? After introducing the necessary
> >> dependencies?
> >>
> >> best regards,
> >>
> >> Jason
> >>
> >>> On Oct 25, 2019, at 18:19, Tien Dat PHAN <[email protected]> wrote:
> >>>
> >>> Hi Jason,
> >>>
> >>> The org.apache.dubbo:dubbo-serialization-kryo, for example, needs
> >>> com.esotericsoftware.kryo.Kryo for Kryo serialization.
> >>>
> >>> org.apache.dubbo:dubbo-serialization-kryo itself has it declared in
> >>> pom.xml
> >>>
> >>> But you do "unzip -Z dubbo-2.7.3.jar |awk '{print $9}' |grep kryo", you
> >>> don't see it included.
> >>> And we have to declare it directly in our application pom.xml
> >>> We believe that this is not relevant, since we have to update the version
> >>> of com.esotericsoftware.kryo according to
> >>> org.apache.dubbo:dubbo-serialization-kryo.
> >>>
> >>> Best
> >>> Dat
> >>>
> >>> On 2019/10/25 08:17:18, Jason Joo <[email protected]> wrote:
> >>>> Hi, tien
> >>>>
> >>>> `dubbo` is a "fat" jar which includes all the classes you may possibly
> >>>> use.
> >>>>
> >>>> You can confirm it using "unzip" as shown below:
> >>>>
> >>>>
> >>>> bogon:2.7.3 hblzxsj$ unzip -Z dubbo-2.7.3.jar |awk '{print $9}' |grep
> >>>> kryo
> >>>> org/apache/dubbo/common/serialize/kryo/
> >>>> org/apache/dubbo/common/serialize/kryo/KryoObjectInput.class
> >>>> org/apache/dubbo/common/serialize/kryo/utils/
> >>>> org/apache/dubbo/common/serialize/kryo/utils/AbstractKryoFactory.class
> >>>> org/apache/dubbo/common/serialize/kryo/KryoSerialization.class
> >>>> org/apache/dubbo/common/serialize/kryo/utils/PooledKryoFactory.class
> >>>> META-INF/maven/org.apache.dubbo/dubbo-serialization-kryo/
> >>>> META-INF/maven/org.apache.dubbo/dubbo-serialization-kryo/pom.properties
> >>>> org/apache/dubbo/common/serialize/kryo/CompatibleKryo.class
> >>>> org/apache/dubbo/common/serialize/kryo/utils/ThreadLocalKryoFactory$1.class
> >>>> org/apache/dubbo/common/serialize/kryo/KryoObjectOutput.class
> >>>> org/apache/dubbo/common/serialize/kryo/utils/PrototypeKryoFactory.class
> >>>> org/apache/dubbo/common/serialize/kryo/utils/ReflectionUtils.class
> >>>> org/apache/dubbo/common/serialize/kryo/utils/KryoUtils.class
> >>>> org/apache/dubbo/common/serialize/kryo/utils/ThreadLocalKryoFactory.class
> >>>> META-INF/maven/org.apache.dubbo/dubbo-serialization-kryo/pom.xml
> >>>>
> >>>>
> >>>>
> >>>> best regards,
> >>>>
> >>>> Jason
> >>>>
> >>>>> On Oct 25, 2019, at 16:06, Tien Dat PHAN <[email protected]> wrote:
> >>>>>
> >>>>> Hi Jason,
> >>>>>
> >>>>> We found that is not enough.
> >>>>> As you have pointed out the dependency on
> >>>>> `http://repo1.maven.org/maven2/org/apache/dubbo/`
> >>>>> All dependencies wrapped by org.apache.dubbo:dubbo are marked as
> >>>>> optional.
> >>>>> This means on our application pom.xml, we have to declare the libraries
> >>>>> that we need directly, as they are not brought directly from
> >>>>> org.apache.dubbo:dubbo dependencies (check
> >>>>> `https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html`)
> >>>>>
> >>>>> Best
> >>>>> Dat
> >>>>>
> >>>>> On 2019/10/25 01:48:29, Jason Joo <[email protected]> wrote:
> >>>>>> Hi, tien
> >>>>>>
> >>>>>> There is a problem in your `dependencies` section.
> >>>>>> `dubbo` is a single package including all codes related dubbo core
> >>>>>> like `netty-all` while `dubbo-serialization-kryo` is already included
> >>>>>> in `dubbo`.
> >>>>>>
> >>>>>> If you want to do some customizing like removing some useless support
> >>>>>> in `dubbo` you could use another way to introduce the dependencies
> >>>>>> like: dubbo-common, dubbo-cluster and etc. .
> >>>>>>
> >>>>>> Certainly it will be so complicated because there are so many packages
> >>>>>> to decide which are required to be introduced and you can see the full
> >>>>>> list in `http://repo1.maven.org/maven2/org/apache/dubbo/`
> >>>>>> <http://repo1.maven.org/maven2/org/apache/dubbo/%60>.
> >>>>>>
> >>>>>> So generally we just introduce `dubbo` instead. That's already enough.
> >>>>>>
> >>>>>> best regards,
> >>>>>>
> >>>>>> Jason
> >>>>>>
> >>>>>>> On Oct 25, 2019, at 00:31, Tien Dat PHAN <[email protected]> wrote:
> >>>>>>>
> >>>>>>> the dubbo-common library as the suggestion with the help o
> >>>>>>
> >>>>>>
> >>>>
> >>>>
> >>
> >>
>
>