moquette-io / moquette

Java MQTT lightweight broker
http://moquette-io.github.io/moquette/
Apache License 2.0
2.3k stars 818 forks source link

Exception: java.lang.NoClassDefFoundError: org/mapdb/DBMaker #248

Open ThomasSchemmer opened 7 years ago

ThomasSchemmer commented 7 years ago

Hi Moquette Team,

I'm currently trying to include an embedded version of moquette into my spring boot app. I added the repository link and dependency to my pom.xml, but when i try to run it I get the following errors at mqttBroker.startServer(classPathConfig, userHandlers);:

Exception in thread "main" java.lang.NoClassDefFoundError: org/mapdb/DBMaker at io.moquette.spi.persistence.MapDBPersistentStore.initStore(MapDBPersistentStore.java:97) at io.moquette.spi.impl.SimpleMessaging.init(SimpleMessaging.java:86) at io.moquette.server.Server.startServer(Server.java:125) at io.moquette.server.Server.startServer(Server.java:110) at com.comm.pubsub.mqtt.moquette.EmbeddedLauncher.start(EmbeddedLauncher.java:46) at com.comm.pubsub.ServerApplication.main(ServerApplication.java:49) Caused by: java.lang.ClassNotFoundException: org.mapdb.DBMaker at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

I assume this is caused by a missing DBMaker dependency, but when I include the maven link

org.mapdb mapdb 1.0.8 i still get the same error. My IDE does not yield any pre compile errors (like missing / unknown includes). Am I missing something? (I guess so, but what? :D) In case thats helpful, im using STS on a windows 10 machine.

Thanks for your help Thomas

Edit: Im using a slightly edited version of your code from here

andsel commented 7 years ago

If you do mvn dependency:tree to see how maven resolves, which is the output? This seems strange it look like the dependency in you pom is scope runtime

ThomasSchemmer commented 7 years ago

Hi Andsel, thanks for your reply. Below is the output.

[INFO] com.comm.pubsub:server:jar:0.0.1-SNAPSHOT [INFO] +- io.moquette:moquette-broker:jar:0.8:compile [INFO] | +- io.moquette:moquette-parser-commons:jar:0.8:compile [INFO] | +- io.moquette:moquette-netty-parser:jar:0.8:compile [INFO] | +- org.slf4j:slf4j-api:jar:1.7.21:compile [INFO] | +- io.netty:netty-common:jar:4.0.33.Final:compile [INFO] | +- io.netty:netty-buffer:jar:4.0.33.Final:compile [INFO] | +- io.netty:netty-transport:jar:4.0.33.Final:compile [INFO] | +- io.netty:netty-handler:jar:4.0.33.Final:compile [INFO] | +- io.netty:netty-codec:jar:4.0.33.Final:compile [INFO] | +- io.netty:netty-codec-http:jar:4.0.33.Final:compile [INFO] | +- commons-codec:commons-codec:jar:1.10:compile [INFO] | +- org.mapdb:mapdb:jar:1.0.8:compile [INFO] | - org.hdrhistogram:HdrHistogram:jar:2.1.4:compile [INFO] +- org.eclipse.paho:org.eclipse.paho.client.mqttv3:jar:1.1.0:compile [INFO] +- org.springframework.boot:spring-boot-starter-websocket:jar:1.4.2.RELEASE:compile [INFO] | +- org.springframework.boot:spring-boot-starter:jar:1.4.2.RELEASE:compile [INFO] | | +- org.springframework.boot:spring-boot:jar:1.4.2.RELEASE:compile [INFO] | | +- org.springframework.boot:spring-boot-autoconfigure:jar:1.4.2.RELEASE:compile [INFO] | | +- org.springframework.boot:spring-boot-starter-logging:jar:1.4.2.RELEASE:compile [INFO] | | | +- ch.qos.logback:logback-classic:jar:1.1.7:compile [INFO] | | | | - ch.qos.logback:logback-core:jar:1.1.7:compile [INFO] | | | +- org.slf4j:jcl-over-slf4j:jar:1.7.21:compile [INFO] | | | +- org.slf4j:jul-to-slf4j:jar:1.7.21:compile [INFO] | | | - org.slf4j:log4j-over-slf4j:jar:1.7.21:compile [INFO] | | - org.yaml:snakeyaml:jar:1.17:runtime [INFO] | - org.springframework:spring-websocket:jar:4.3.4.RELEASE:compile [INFO] +- org.springframework.boot:spring-boot-starter-actuator:jar:1.4.2.RELEASE:compile [INFO] | - org.springframework.boot:spring-boot-actuator:jar:1.4.2.RELEASE:compile [INFO] +- org.springframework:spring-messaging:jar:4.3.4.RELEASE:compile [INFO] | +- org.springframework:spring-beans:jar:4.3.4.RELEASE:compile [INFO] | +- org.springframework:spring-context:jar:4.3.4.RELEASE:compile [INFO] | | - org.springframework:spring-expression:jar:4.3.4.RELEASE:compile [INFO] | - org.springframework:spring-core:jar:4.3.4.RELEASE:compile [INFO] +- com.google.code.gson:gson:jar:2.8.0:compile [INFO] +- org.springframework.boot:spring-boot-starter-security:jar:1.4.2.RELEASE:compile [INFO] | +- org.springframework:spring-aop:jar:4.3.4.RELEASE:compile [INFO] | +- org.springframework.security:spring-security-config:jar:4.1.3.RELEASE:compile [INFO] | | - org.springframework.security:spring-security-core:jar:4.1.3.RELEASE:compile [INFO] | - org.springframework.security:spring-security-web:jar:4.1.3.RELEASE:compile [INFO] +- org.springframework.boot:spring-boot-starter-web:jar:1.4.2.RELEASE:compile [INFO] | +- org.springframework.boot:spring-boot-starter-tomcat:jar:1.4.2.RELEASE:compile [INFO] | | +- org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.6:compile [INFO] | | +- org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.6:compile [INFO] | | - org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.5.6:compile [INFO] | +- org.hibernate:hibernate-validator:jar:5.2.4.Final:compile [INFO] | | +- javax.validation:validation-api:jar:1.1.0.Final:compile [INFO] | | +- org.jboss.logging:jboss-logging:jar:3.3.0.Final:compile [INFO] | | - com.fasterxml:classmate:jar:1.3.3:compile [INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.8.4:compile [INFO] | | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.8.4:compile [INFO] | | - com.fasterxml.jackson.core:jackson-core:jar:2.8.4:compile [INFO] | +- org.springframework:spring-web:jar:4.3.4.RELEASE:compile [INFO] | - org.springframework:spring-webmvc:jar:4.3.4.RELEASE:compile [INFO] +- org.springframework.boot:spring-boot-starter-test:jar:1.4.2.RELEASE:test [INFO] | +- org.springframework.boot:spring-boot-test:jar:1.4.2.RELEASE:test [INFO] | +- org.springframework.boot:spring-boot-test-autoconfigure:jar:1.4.2.RELEASE:test [INFO] | +- com.jayway.jsonpath:json-path:jar:2.2.0:test [INFO] | | - net.minidev:json-smart:jar:2.2.1:test [INFO] | | - net.minidev:accessors-smart:jar:1.1:test [INFO] | | - org.ow2.asm:asm:jar:5.0.3:test [INFO] | +- junit:junit:jar:4.12:test [INFO] | +- org.assertj:assertj-core:jar:2.5.0:test [INFO] | +- org.mockito:mockito-core:jar:1.10.19:test [INFO] | | - org.objenesis:objenesis:jar:2.1:test [INFO] | +- org.hamcrest:hamcrest-core:jar:1.3:test [INFO] | +- org.hamcrest:hamcrest-library:jar:1.3:test [INFO] | +- org.skyscreamer:jsonassert:jar:1.3.0:test [INFO] | | - org.json:json:jar:20140107:test [INFO] | - org.springframework:spring-test:jar:4.3.4.RELEASE:test [INFO] +- org.thymeleaf.extras:thymeleaf-extras-springsecurity4:jar:2.1.2.RELEASE:compile [INFO] | - org.thymeleaf:thymeleaf:jar:2.1.5.RELEASE:compile [INFO] | +- ognl:ognl:jar:3.0.8:compile [INFO] | +- org.javassist:javassist:jar:3.20.0-GA:compile [INFO] | - org.unbescape:unbescape:jar:1.1.0.RELEASE:compile [INFO] +- org.springframework.boot:spring-boot-starter-thymeleaf:jar:1.4.2.RELEASE:compile [INFO] | +- org.thymeleaf:thymeleaf-spring4:jar:2.1.5.RELEASE:compile [INFO] | - nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:jar:1.4.0:compile [INFO] | - org.codehaus.groovy:groovy:jar:2.4.7:compile [INFO] +- org.webjars:webjars-locator:jar:0.32:compile [INFO] | - org.webjars:webjars-locator-core:jar:0.30:compile [INFO] | +- org.apache.commons:commons-lang3:jar:3.1:compile [INFO] | - org.apache.commons:commons-compress:jar:1.9:compile [INFO] +- org.webjars.bower:bootstrap:jar:3.3.7:compile [INFO] - org.webjars.bower:jquery:jar:3.1.1:compile

andsel commented 7 years ago

@Klarzahs could you try with version 0.9? To reprodcue I just need to create a plain maven Spring boot app and add the Moquette dependency?