LinkageError: duplicate class definition

4,685 views
Skip to first unread message

Fernando Jordán Silva

unread,
Dec 1, 2013, 4:05:34 PM12/1/13
to ve...@googlegroups.com
Hi

In my project with Vert.x 2.1M1 I have this layout:

/conf -> configuration of the project
/lib -> Shared libs for all verticals and modules
/com -> code for the main vertical called ( as example) " A "
/mods -> Includes a submodule called (as example) " B "

The submodule B deploys 2 verticals (using deployWorkerVertical( ... ) ). Tthe code of the verticals is inside "B" and uses the same libraries as " A " (libraries shared in the /lib folder).

The first vertical is deployed right, but the second one always fails with this error:

java.lang.LinkageError: loader (instance of  org/vertx/java/platform/impl/ModuleClassLoader): attempted  duplicate class definition for
 name: "com/cloudhopper/smpp/impl/DefaultSmppClient"
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:792)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at org.vertx.java.platform.impl.ModuleClassLoader.doLoadClass(ModuleClassLoader.java:90)
        at org.vertx.java.platform.impl.ModuleClassLoader.loadClass(ModuleClassLoader.java:70)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at es.fjordan.BaseCloudhopperVerticle.createDefaultSmppClient(BaseCloudhopperVerticle.java:332)
        at es.fjordan.BaseCloudhopperVerticle.start(BaseCloudhopperVerticle.java:207)
        at org.vertx.java.platform.Verticle.start(Verticle.java:82)
        at org.vertx.java.platform.impl.DefaultPlatformManager$19.run(DefaultPlatformManager.java:1551)
        at org.vertx.java.core.impl.DefaultContext$3.run(DefaultContext.java:176)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:724)

I don't understand why I have this error... How can I run my project ?

Tim Fox

unread,
Dec 1, 2013, 4:09:39 PM12/1/13
to ve...@googlegroups.com
Very hard to know without seeing your project -maybe you can zip up an example which demonstrates the issue?

Also... I'd recommend using the standard project layout (see docs) to structure your projects instead of maintaining them in a nested structure.
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Fernando Jordán Silva

unread,
Dec 1, 2013, 4:19:45 PM12/1/13
to ve...@googlegroups.com
Hi Tim

I'd like to share my project with you, but I cannot make it public (is for my enterprise). How can I send it to you ?

Thanks for your help

Tim Fox

unread,
Dec 1, 2013, 4:25:38 PM12/1/13
to ve...@googlegroups.com
No need to zip up your actual project, just create a simple project which demonstrates the issue, but doesn't contain any of your secret stuff :)

Fernando Jordán Silva

unread,
Dec 2, 2013, 4:40:41 PM12/2/13
to ve...@googlegroups.com
Hi Tim

I have rebuilt my project using the maven archetype from Vert.x but the problem is still there.... At this moment, I'm not always getting the error that I pasted in my first post ( java.lang.LinkageError: loader (instance of  org/vertx/java/platform/impl/ModuleClassLoader): attempted  duplicate class definition for name: "com/cloudhopper/smpp/impl/DefaultSmppClient" )

Sometimes the system starts right, but others fails, it seems like a race condition when I'm deploying the verticals inside my module :(

Log when the system starts right:

corr=NA | trans=NA | op=STARTING | msg=Adapter SMS SMPP is starting...
corr=NA | trans=NA | op=CONFIGURATION | msg=Config: {Configuration removed to make the log clearer}}
corr=NA | trans=NA | op=STARTING | msg=Adapter Mode: mixed
corr=NA | trans=NA | op=STARTING | msg=Module to load: com.tdigital.tdaf.api.adapter~sms-smpp-ch~1.2.0-SNAPSHOT
corr=NA | trans=NA | op=STARTING | msg=Adapter SMS SMPP is started and waiting for requests.
Succeeded in deploying module from zip
corr=NA | trans=NA | op=STARTING_MODULE | msg=SMS SMPP Cloudhopper Module is starting...
corr=NA | trans=NA | op=STARTING_MODULE | msg=SMS SMPP Cloudhopper Module is started.
corr=NA | trans=NA | op=STARTING | msg=Module deployed: com.tdigital.tdaf.api.adapter~sms-smpp-ch~1.2.0-SNAPSHOT successfully
corr=NA | trans=NA | op=STARTING_MODULE | msg=SMS SMPP Receiver Module is starting...
corr=NA | trans=NA | op=STARTING_MODULE | msg=SMS SMPP Transmitter Module is starting...
corr=NA | trans=NA | op=STARTING_MODULE | msg=SMS SMPP Receiver Module is started.
corr=NA | trans=NA | op=STARTING_MODULE | msg=SMS SMPP Mode Verticle deployed: com.tdigital.tdaf.api.adapter.sms.smpp.ch.ReceiverVertic
le successfully
corr=NA | trans=NA | op=STARTING_MODULE | msg=SMS SMPP Transmitter Module is started.
corr=NA | trans=NA | op=STARTING_MODULE | msg=SMS SMPP Mode Verticle deployed: com.tdigital.tdaf.api.adapter.sms.smpp.ch.TransmitterVer
ticle successfully

This is the log when it fails:
corr=NA | trans=NA | op=STARTING | msg=Adapter SMS SMPP is starting...
corr=NA | trans=NA | op=CONFIGURATION | msg=Config: {Configuration removed to make the log clearer} }
corr=NA | trans=NA | op=STARTING | msg=Management Verticle is starting...
corr=NA | trans=NA | op=STARTING | msg=Management Verticle is started and waiting for requests.
corr=NA | trans=NA | op=STARTING | msg=Adapter Mode: mixed
corr=NA | trans=NA | op=STARTING | msg=Module to load: com.tdigital.tdaf.api.adapter~sms-smpp-ch~1.2.0-SNAPSHOT
corr=NA | trans=NA | op=STARTING | msg=Adapter SMS SMPP is started and waiting for requests.
Succeeded in deploying module from zip
corr=NA | trans=NA | op=STARTING_MODULE | msg=SMS SMPP Cloudhopper Module is starting...
corr=NA | trans=NA | op=STARTING_MODULE | msg=SMS SMPP Cloudhopper Module is started.
corr=NA | trans=NA | op=STARTING | msg=Module deployed: com.tdigital.tdaf.api.adapter~sms-smpp-ch~1.2.0-SNAPSHOT successfully
corr=NA | trans=NA | op=STARTING_MODULE | msg=SMS SMPP Transmitter Module is starting...
corr=NA | trans=NA | op=STARTING_MODULE | msg=SMS SMPP Receiver Module is starting...
java.lang.LinkageError: loader (instance of  org/vertx/java/platform/impl/ModuleClassLoader): attempted  duplicate class definition for
 name: "org/jboss/netty/channel/DefaultChannelFuture"
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:792)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at org.vertx.java.platform.impl.ModuleClassLoader.doLoadClass(ModuleClassLoader.java:90)
        at org.vertx.java.platform.impl.ModuleClassLoader.loadClass(ModuleClassLoader.java:70)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at com.tdigital.tdaf.api.adapter.sms.smpp.ch.BaseCloudhopperVerticle.createDefaultSmppClient(BaseCloudhopperVerticle.java:317)
        at com.tdigital.tdaf.api.adapter.sms.smpp.ch.BaseCloudhopperVerticle.start(BaseCloudhopperVerticle.java:207)
        at org.vertx.java.platform.Verticle.start(Verticle.java:82)
        at org.vertx.java.platform.impl.DefaultPlatformManager$19.run(DefaultPlatformManager.java:1551)
        at org.vertx.java.core.impl.DefaultContext$3.run(DefaultContext.java:176)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:724)
corr=NA | trans=NA | op=STARTING_MODULE | msg=SMS SMPP Mode Verticle deployed: com.tdigital.tdaf.api.adapter.sms.smpp.ch.ReceiverVertic
le successfully
corr=NA | trans=NA | op=STARTING_MODULE | msg=SMS SMPP Transmitter Module is started.
corr=NA | trans=NA | op=STARTING_MODULE | msg=SMS SMPP Mode Verticle deployed: com.tdigital.tdaf.api.adapter.sms.smpp.ch.TransmitterVer
ticle successfully

One strange thing is that Vert.x throws the exception and the deployed verticle doesn't work but the AsyncResult<String> var in the doneHandle of the deployeWorkerVerticle method returns wrong values in the methods "succeeded" and "failed".

My code:

- My Main module is called sms-smpp and when starts deploy a submodule called sms-smpp-ch 

mod.json file of the submodule sms-smpp-ch:
{
    "main": "com.tdigital.tdaf.api.adapter.sms.smpp.ch.CloudhopperMod",
    "worker": true,
    "multi-threaded": true
}

- Actions in the start method of the CloudhopperMod:
1. Read the working mode of the module. The problem happens when I have 2 working modes: RX and TX
2. For each working mode I need to deploy a Verticle ( RXVerticle and TXVerticle)
3. In the start method of each deployed verticle I have to connect to one external system. This action can take up to 1 or 2 secs.

public class CloudhopperMod extends BusModBase {
    @Override
    public void start() {
        super.start();
                logger.info(loggerMessage.log("SMS SMPP Cloudhopper Module is starting..."));

        String workingMode = config.getString("mode", "transceiver");
        // This List contains the canonical names of two verticals to deploy
        List<String> verticles = ModuleMode.fromWorkingMode(workingMode).getVerticalCanonicalNames();

        // Deploy
        for (final String name : verticles) {
            // DeployVerticle
            getContainer().deployWorkerVerticle(name, config, 1, true, new Handler<AsyncResult<String>>() {
                @Override
                public void handle(AsyncResult<String> verticle) {
                    logger.info("SMS SMPP Mode Verticle deployed: " + name + (verticle.succeeded() ? " successfully" : " with errors"));
                    if (verticle.failed()) {
                        logger.error(loggerMessage.log("Exception trace:"), verticle.cause());
                    }
                }
            });
        }
        logger.info("SMS SMPP Cloudhopper Module is started."));
    }
}

Maybe seeing my code, you can help me 

Thanks !!!


Tim Fox

unread,
Dec 3, 2013, 4:09:55 AM12/3/13
to ve...@googlegroups.com
On 02/12/13 21:40, Fernando Jordán Silva wrote:
Hi Tim

I have rebuilt my project using the maven archetype from Vert.x but the problem is still there.... At this moment, I'm not always getting the error that I pasted in my first post ( java.lang.LinkageError: loader (instance of  org/vertx/java/platform/impl/ModuleClassLoader): attempted  duplicate class definition for name: "com/cloudhopper/smpp/impl/DefaultSmppClient" )

Sometimes the system starts right, but others fails, it seems like a race condition when I'm deploying the verticals inside my module :(

I doubt it. It's a class loader issue - most probably because you have jars in the wrong place in your project, but without seeing your project, it's hard to be sure.

Fernando Jordán Silva

unread,
Dec 3, 2013, 4:24:44 AM12/3/13
to ve...@googlegroups.com
Tim, please send me an email to fjordansilva @ gmail . com and I will send you the project. I cannot make it public :(

Once you have seen the project, we can continue posting all messages in this group so everybody knows what the problem was.

Jon Keys

unread,
Dec 3, 2013, 10:20:58 AM12/3/13
to ve...@googlegroups.com
I continue to see this error myself (originally posted the question here: https://groups.google.com/d/msg/vertx/2M-cwJSw3HM/CqTdHKVul5wJ).
It occurs intermittently when starting the app with the exact same code.

Tim Fox

unread,
Dec 4, 2013, 3:18:07 AM12/4/13
to ve...@googlegroups.com

Unfortunately I have never been able to replicate this. Fernando is going to create a stripped down project which hopefully will allow me to replicate it. If I can see it, I can fix it :)

Fernando Jordán Silva

unread,
Dec 4, 2013, 1:12:23 PM12/4/13
to ve...@googlegroups.com
Tim, I have sent you an email with a stripped project. That project replicates the problem. 

Fernando Jordán Silva

unread,
Dec 12, 2013, 11:33:47 AM12/12/13
to ve...@googlegroups.com
Hi Tim

Did you receive my email with the sample project ?

Jon Keys

unread,
Dec 16, 2013, 9:32:51 AM12/16/13
to ve...@googlegroups.com
Hi Fernando,

Did you file a BZ for this? If not, can you file one here: https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Vertx ?

I'm going to have to find a work around for this before I can put vert.x v2.x in production so I'd be interested in collaborating with you to find a fix / workaround.
In your sample project are you deploying modules asynchronously? I do and I'm thinking this might be a good place to start looking for a fix.

Best,

Jon

Jon Keys

unread,
Jan 6, 2014, 11:13:03 AM1/6/14
to ve...@googlegroups.com
Just checking if there was ever a resolution on this?

@Tim/Norman: did you receive the sample package which demonstrates the issue?

Tim Fox

unread,
Jan 6, 2014, 11:52:14 AM1/6/14
to ve...@googlegroups.com
Is there a BZ for this?

Jon Keys

unread,
Jan 6, 2014, 12:15:08 PM1/6/14
to ve...@googlegroups.com


On Monday, January 6, 2014 11:52:14 AM UTC-5, Tim Fox wrote:
Is there a BZ for this?

I don't think so. Fernando had sent you some files offline but I don't believe he created a BZ.

I'm also happy to create a sample project to demonstrate the issue if needed -- I just didn't want to recreate Fernando's work.

Fernando Jordán Silva

unread,
Jan 6, 2014, 12:33:51 PM1/6/14
to ve...@googlegroups.com
Sorry, I was on holidays. I didn't create the bug report. Do you need it? Did my sample project reproduce the bug?

---
Sent from my iPhone 5
You received this message because you are subscribed to a topic in the Google Groups "vert.x" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vertx/PPgRQZjDYUk/unsubscribe.
To unsubscribe from this group and all of its topics, send an email to vertx+un...@googlegroups.com.

Tim Fox

unread,
Jan 7, 2014, 10:59:52 AM1/7/14
to ve...@googlegroups.com
Please attach the sample project to the BZ

Jon Keys

unread,
Jan 7, 2014, 11:24:43 AM1/7/14
to ve...@googlegroups.com


On Tuesday, January 7, 2014 10:59:52 AM UTC-5, Tim Fox wrote:
Please attach the sample project to the BZ

@Fernando: can you attach the sample project to the BZ (https://bugs.eclipse.org/bugs/show_bug.cgi?id=424950)?

Fernando Jordán Silva

unread,
Jan 8, 2014, 10:32:59 AM1/8/14
to ve...@googlegroups.com
I have added the sample project to the BZ. I hope it helps.

Thameem Ansari

unread,
Jan 8, 2014, 4:02:27 PM1/8/14
to ve...@googlegroups.com
I am having the exact same issue described in this thread. I believe verticle classloaders are overlapping on each other. 

Thanks
Thameem 

Tim Fox

unread,
Jan 9, 2014, 9:03:54 AM1/9/14
to ve...@googlegroups.com
This has been reported some time back.

Unfortunately, so far, no one has been able to create a *simple* (i.e. I don't want to see your entire application) reproducer that exhibits the problem, that I can unzip and run directly on Linux.

If someone can create such a thing, I will investigate.

Tim Fox

unread,
Jan 9, 2014, 9:05:30 AM1/9/14
to ve...@googlegroups.com
It shouldn't require any complex scripts, just vertx run, or vertx runmod should do.

Paco Hernández Gómez

unread,
Jan 9, 2014, 11:46:53 AM1/9/14
to ve...@googlegroups.com
Hi to all.

It seems that there is a problem with modules' libraries that conflict with main vert.x libraries.

I have opened the bug Bug 425211 that explains the conflict and attach an example that reproduces the problem.

This problem is happening to us after migrating from vert.x 2.0.0 to vert.x 2.1M2.

Thank you very much!

Best regards,
Paco Hernández.

Fernando Jordán Silva

unread,
Jan 9, 2014, 11:56:50 AM1/9/14
to ve...@googlegroups.com
I don't think the bug is the same. In the exception that I get the classloader is trying to load a duplicated class (already loaded previously), and the class belongs to an external lib (not from Vert.x or any of its dependencies). 

I think that we have two different bugs to fix :)

Best regards
Fernando


2014/1/9 Paco Hernández Gómez <pa...@hernandezgomez.com>

--
You received this message because you are subscribed to a topic in the Google Groups "vert.x" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vertx/PPgRQZjDYUk/unsubscribe.
To unsubscribe from this group and all of its topics, send an email to vertx+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Fernando Jordán Silva
Message has been deleted

Thameem Ansari

unread,
Jan 13, 2014, 4:33:41 PM1/13/14
to ve...@googlegroups.com
Yes. You are correct. I do see these two different exceptions intermittently. 

Thanks
Thameem

Thameem Ansari

unread,
Jan 13, 2014, 4:41:55 PM1/13/14
to ve...@googlegroups.com
 Looks like it has been fixed today and pushed to master branch https://github.com/eclipse/vert.x/commit/921278186d0cd72cbcd14abfdbc5fc5e83e27fcc

Explanation: 

Looks like the problem is with the org/vertx/java/platform/impl/ModuleClassLoader  trying to load a class which have been already loaded. It shouldn't simply try to load instead it should check the delegation model (cache, parent, disk) before it load it from scratch. 

Thanks
Thameem

On Thursday, January 9, 2014 8:56:50 AM UTC-8, Fernando Jordán Silva wrote:

Jon Keys

unread,
Jan 13, 2014, 4:44:52 PM1/13/14
to ve...@googlegroups.com


On Monday, January 13, 2014 4:41:55 PM UTC-5, Thameem Ansari wrote:
 Looks like it has been fixed today and pushed to master branch https://github.com/eclipse/vert.x/commit/921278186d0cd72cbcd14abfdbc5fc5e83e27fcc

Not quite fixed yet -- there is a discussion on the BZ here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=424950
Reply all
Reply to author
Forward
0 new messages