question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unclear on the use the `jx` module

See original GitHub issue

I am have bound services needing other bound services.

My binding looks like this:

val kodein = Kodein {
    import(jxInjectorModule)
    bind<Properties>() with singleton { PropertiesLoaderUtils.loadProperties(ClassPathResource("application.properties")) }
    bind<FileContentProvider>() with singleton { FileContentProvider.default }
    bind<DistributionService>() with singleton { jx.newInstance<DistributionServiceImpl>() }
    bind<InnkeeperClient>() with singleton { jx.newInstance<InnkeeperClientImpl>() }
    bind<QuiltClient>() with singleton { jx.newInstance<QuiltClientImpl>() }
    bind<TessellateClient>() with singleton { jx.newInstance<TessellateClientImpl>() }
    bind<JsonService>() with singleton { JsonServiceImpl() }
    bind<RequestContext>() with singleton { RequestContextImpl() }
    bind<Authorization>() with singleton { AuthorizationImpl() }
}

The moment I hit the resolving of the DistributionService, it fails with this message:

com.github.salomonbrys.kodein.Kodein$DependencyLoopException: Dependency recursion:
       ╔═> bind<JxInjector>()
       ╠─> bind<DistributionService>()
       ╚═> bind<JxInjector>()

The constructor of my DistributionServiceImpl is:

class DistributionServiceImpl(
    private val jsonService: JsonService,
    private val properties: Properties,
    private val quiltClient: QuiltClient,
    private val innkeeperClient: InnkeeperClient,
    private val tessellateClient: TessellateClient
) : DistributionService {

When I debug with breakpoints in every one of the singleton lambda, I observe that the following are called:

  • JsonServiceImpl()
  • FileContentProvider.default
  • jx.newInstance<DistributionServiceImpl>() Then it fails before entering the constructor of class DistributionServiceImpl.

I feel that I simply am not using this right. However, the documentation does not state a clear example of how to declare a binding block using the jx approach. It just states as an example:

val kodein = Kodein {
    import(jxInjectorModule)
    /* Other bindings */
}

I am interested in HOW to declare the other bindings here.

Thanks for whatever help you can provide.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
SalomonBryscommented, Jun 26, 2017

Certainly looks correct…

1reaction
SalomonBryscommented, Jun 24, 2017

Hi there, this really looks like a bug 😦 I;ll have a look as soon as I can

Read more comments on GitHub >

github_iconTop Results From Across the Web

JXCore packaging, NPM errors - node.js
I dont think,the problem is with NPM, step by step compile each of the .js file, and introduce required NPM package one by...
Read more >
Using custom SQLite Library Ubuntu fails · Issue #798
Hi, I am using custom SQLite library based on see I am trying to get JXCore to work with it following issue ......
Read more >
Prokaryote toxin–antitoxin modules: Complex regulation of an ...
Toxin–antitoxin (TA) modules are small operons in bacteria and archaea that encode a metabolic inhibitor (toxin) and a matching regulatory ...
Read more >
kumarvna/postgresql-db/azurerm
This module utilizes postgresadmin as a local administrator on PostgreSQL server. If you want to you use custom username, then specify the ...
Read more >
UPDATE 1-Japan's JX shuts vacuum distillation unit after fire
The fire started at 11:23 a.m. (0223 GMT) on Sunday and was extinguished by 6:57 p.m. (0957 GMT) the same day, the company...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found