lightningj-org/lightningj

Following the docs lead to a ClassNotFoundException

Closed this issue · 6 comments

Subject of the issue

Following the guide leads to exceptions

Your environment

  • version of lightningj: 0.6.1-Beta
  • version and vendor of JDK: Oracle JDK 8
  • your operationg systems: Ubuntu 16.04

Steps to reproduce

  • Follow the steps on https://www.lightningj.org
  • Add the lightningj dependency.
  • Run the code from the Synchronous API of Using the High Level API

Expected behaviour

Calling synchronousLndAPI.channelBalance() returns the channel balance.

Actual behaviour

An exception is thrown:

Exception in thread "main" java.lang.NoClassDefFoundError: javax/json/JsonPatch
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:264)
	at javax.json.spi.JsonProvider.provider(JsonProvider.java:94)
	at javax.json.Json.createGeneratorFactory(Json.java:173)
	at org.lightningj.lnd.util.JsonGenUtils.<clinit>(JsonGenUtils.java:37)
	at org.lightningj.lnd.wrapper.Message.toJson(Message.java:76)
	at org.lightningj.lnd.wrapper.Message.toJsonAsString(Message.java:89)
	at org.lightningj.lnd.wrapper.Message.toString(Message.java:120)
	at org.lightningj.lnd.wrapper.API.processRequest(API.java:142)
	at org.lightningj.lnd.wrapper.SynchronousLndAPI.channelBalance(SynchronousLndAPI.java:196)
	at org.lightningj.lnd.wrapper.SynchronousLndAPI.channelBalance(SynchronousLndAPI.java:176)

Hi, this was very strange, since it builds on travis and the same error should occur there unless there is something wrong with my test suite.

The javax.json.JsonPatch class is defined in an external jar dependency for JSON-P. Can you check if you have: javax.json:javax.json-api:1.0 and org.glassfish:javax.json:1.1.2 in the class path?

Which build system are you using? Maven, Gradle or other?

Regards
Philip

When playing with it I started adding those libraries manually, it looks like they didn't get resolved transitively as usual, I'm using sbt.

I don't have much experience with sbt myself. Do you know if I can change anything in the generated POM file for them to be added by sbt? Can cannot se any differences fromt the other libraries apart for associated licenses.

Otherwise I can just update the documentation on the website.

Hi again, I have updated the website with a note that the required dependencies if using sbt.

Sadly, I haven't had the time to prepare a PoC, I ended up not using this library but generating a gRPC client using scalapb, this is the first time I hit an issue like this with sbt, thanks!

You can fix this issue by adding:

        <dependency>
            <groupId>javax.json</groupId>
            <artifactId>javax.json-api</artifactId>
            <version>1.1.2</version>
        </dependency>

to your pom.xml.