Connecting Libra to Java with jlibra

Actually not I made this, but I created a project using it.

Even though the original Libra node is implemented in Rust, a gRPC interface is co-deployed, so other languages and platforms can easily use Libra through gRPC.

There are several implementations right now for accessing Libra through other languages and platforms, eg. JavaScript, Python and Go.

https://github.com/ketola added a Java implementation: jlibra

To show how to use this library, I added two projects for Spring-Boot users:

So if you are using Java and/or Spring (Boot), these projects can help to avoid boilerplate code.

3 Likes

Nice. does this library work on Android?

1 Like

Honestly, we are not sure (see https://github.com/ketola/jlibra/issues/30).
But it is one goal to have it running on Android, maybe there will be a special version for this.

1 Like

Okay. Thank you. I’ll test the library out later and see if there is anyway I can help to get it supported.

3 Likes

Hello ice09 can i build jlibra with Ant?

1 Like

Hi, no, that’s not possible, it’s Maven based. But there should be converters available, though it might really make sense to use Maven or Gradle for this.

1 Like

ok, its just that am trying to build with maven and am getting the error below

Scanning for projects…
Sep 01, 2019 9:23:20 AM org.sonatype.guice.bean.reflect.Logs$JULSink warn
WARNING: Error injecting: kr.motd.maven.os.DetectExtension
com.google.inject.ConfigurationException: Guice configuration errors:

  1. Could not find a suitable constructor in kr.motd.maven.os.DetectExtension. Classes must have either one (and only one) constructor annotated with @Inject or a zero-argument constructor that is not private.
    at kr.motd.maven.os.DetectExtension.class(Unknown Source)
    while locating kr.motd.maven.os.DetectExtension

1 error
at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:991)
at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:950)
at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1000)
at org.sonatype.guice.bean.reflect.AbstractDeferredClass.get(AbstractDeferredClass.java:45)
at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:84)
at com.google.inject.internal.InternalFactoryToInitializableAdapter.provision(InternalFactoryToInitializableAdapter.java:52)
at com.google.inject.internal.ProviderInternalFactory$1.call(ProviderInternalFactory.java:70)
at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:100)
at org.sonatype.guice.plexus.lifecycles.PlexusLifecycleManager.onProvision(PlexusLifecycleManager.java:138)
at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:108)
at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:55)
at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:68)
at com.google.inject.internal.InternalFactoryToInitializableAdapter.get(InternalFactoryToInitializableAdapter.java:45)
at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1018)
at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
at com.google.inject.Scopes$1$1.get(Scopes.java:59)
at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
at com.google.inject.internal.InjectorImpl$3$1.call(InjectorImpl.java:965)
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1011)
at com.google.inject.internal.InjectorImpl$3.get(InjectorImpl.java:961)
at org.sonatype.guice.bean.locators.LazyBeanEntry.getValue(LazyBeanEntry.java:83)
at org.sonatype.guice.plexus.locators.LazyPlexusBean.getValue(LazyPlexusBean.java:49)
at org.sonatype.guice.bean.locators.EntryListAdapter$ValueIterator.next(EntryListAdapter.java:112)
at java.util.AbstractCollection.addAll(AbstractCollection.java:343)
at org.apache.maven.DefaultMaven.getLifecycleParticipants(DefaultMaven.java:538)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:270)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)

Internal error: com.google.inject.ProvisionException: Guice provision errors:

  1. Could not find a suitable constructor in kr.motd.maven.os.DetectExtension. Classes must have either one (and only one) constructor annotated with @Inject or a zero-argument constructor that is not private.
    at kr.motd.maven.os.DetectExtension.class(Unknown Source)
    while locating kr.motd.maven.os.DetectExtension
    at ClassRealm[extension>kr.motd.maven:os-maven-plugin:1.6.0, parent: sun.misc.Launcher$AppClassLoader@1f96302]
    at ClassRealm[extension>kr.motd.maven:os-maven-plugin:1.6.0, parent: sun.misc.Launcher$AppClassLoader@1f96302]
    while locating org.apache.maven.AbstractMavenLifecycleParticipant annotated with @com.google.inject.name.Named(value=detect-os)

1 error
-> [Help 1]
org.apache.maven.InternalErrorException: Internal error: com.google.inject.ProvisionException: Guice provision errors:

  1. Could not find a suitable constructor in kr.motd.maven.os.DetectExtension. Classes must have either one (and only one) constructor annotated with @Inject or a zero-argument constructor that is not private.
    at kr.motd.maven.os.DetectExtension.class(Unknown Source)
    while locating kr.motd.maven.os.DetectExtension
    at ClassRealm[extension>kr.motd.maven:os-maven-plugin:1.6.0, parent: sun.misc.Launcher$AppClassLoader@1f96302]
    at ClassRealm[extension>kr.motd.maven:os-maven-plugin:1.6.0, parent: sun.misc.Launcher$AppClassLoader@1f96302]
    while locating org.apache.maven.AbstractMavenLifecycleParticipant annotated with @com.google.inject.name.Named(value=detect-os)

1 error
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:168)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: com.google.inject.ProvisionException: Guice provision errors:

  1. Could not find a suitable constructor in kr.motd.maven.os.DetectExtension. Classes must have either one (and only one) constructor annotated with @Inject or a zero-argument constructor that is not private.
    at kr.motd.maven.os.DetectExtension.class(Unknown Source)
    while locating kr.motd.maven.os.DetectExtension
    at ClassRealm[extension>kr.motd.maven:os-maven-plugin:1.6.0, parent: sun.misc.Launcher$AppClassLoader@1f96302]
    at ClassRealm[extension>kr.motd.maven:os-maven-plugin:1.6.0, parent: sun.misc.Launcher$AppClassLoader@1f96302]
    while locating org.apache.maven.AbstractMavenLifecycleParticipant annotated with @com.google.inject.name.Named(value=detect-os)

1 error
at com.google.inject.internal.InjectorImpl$3.get(InjectorImpl.java:974)
at org.sonatype.guice.bean.locators.LazyBeanEntry.getValue(LazyBeanEntry.java:83)
at org.sonatype.guice.plexus.locators.LazyPlexusBean.getValue(LazyPlexusBean.java:49)
at org.sonatype.guice.bean.locators.EntryListAdapter$ValueIterator.next(EntryListAdapter.java:112)
at java.util.AbstractCollection.addAll(AbstractCollection.java:343)
at org.apache.maven.DefaultMaven.getLifecycleParticipants(DefaultMaven.java:538)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:270)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
… 11 more

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/InternalErrorException
Java HotSpot™ Client VM warning: ignoring option PermSize=256m; support was removed in 8.0
Java HotSpot™ Client VM warning: ignoring option MaxPermSize=512m; support was removed in 8.0
‘cmd’ is not recognized as an internal or external command,
operable program or batch file.

1 Like

Thank mvn clean install worked but some classes are still showing up with error, there are some import statements trying to import non existent classes, please did you noticed it

1 Like

No, it worked fine for us. If you find error, please report them as issues on Github: https://github.com/ketola/jlibra/issues

1 Like

i can’t github has refused to send verification code to my email so i can’t login
but this is the error am getting


This is the error am getting, in jlibra-core, it cant find classes such as
ImmutableAccountState
ImmutableEventPath
ImmutablePaymentEvent
ImmutableSignedTransactionWithProof
i have tried importing all modules except the “jlibra-gprc”

1 Like

Yes, that makes sense as these classes are generated (which is done during the Maven build). So, you will have to build all dependent projects and add the generated classes as well. Is there a special reason you don’t use Maven?

1 Like

How do i build all dependent projects?, also am self taught and i learnt ant, i don’t really know how to use maven

1 Like

It will be difficult if you cannot use an external Maven build to create all generated classes and then include the generated artefacts manually into your Ant build. I assume you will have to get into Maven first, but this is quite easy to do, as you just have to use Maven with already existing pom files. So the best starting point would be https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html and jump to the usage notes (as you don’t have to create, but just to use Maven). Also you can search for Ant / Maven migration guides.

1 Like