Reputation: 1
Here is the code I ran:
package org.example;
import com.google.inject.*;
import org.pac4j.core.context.session.SessionStore;
import org.pac4j.play.store.PlayCacheSessionStore;
import org.pac4j.play.store.PlaySessionStore;
import play.cache.SyncCacheApi;
class AuthModule extends AbstractModule {
@Override
protected void configure() {
System.out.println("here");
final PlayCacheSessionStore playCacheSessionStore = new PlayCacheSessionStore(getProvider(SyncCacheApi.class));
bind(SessionStore.class).toInstance(playCacheSessionStore);
bind(PlaySessionStore.class).toInstance(playCacheSessionStore);
}
}
class AuthenticationController {
@Inject
private PlaySessionStore _playSessionStore;
public void printSomething() {
System.out.println(_playSessionStore);
}
}
class GuiceTester {
public static void main(String[] args) {
Injector injector = Guice.createInjector(new AuthModule());
AuthenticationController authenticationController = injector.getInstance(AuthenticationController.class);
authenticationController.printSomething();
System.out.println("hello");
}
}
The dependencies:
dependencies {
implementation "org.pac4j:pac4j-oidc:4.5.7"
implementation "com.typesafe.play:play-guice_2.12:2.8.18"
implementation "com.google.inject:guice:4.2.3"
implementation "com.typesafe.play:play-cache_2.12:2.8.18"
implementation "org.pac4j:play-pac4j_2.12:9.0.2"
}
I referenced the code from play-pac4j-java-demo play-pac4j-java-demo/app/modules/SecurityModule.java
(https://github.com/pac4j/play-pac4j-java-demo/blob/master/app/modules/SecurityModule.java).
I created the PlayCacheSessionStore instance, tried using Guice to ingest, but got the following error:
1) No implementation for play.cache.SyncCacheApi was bound.
at org.example.AuthModule.configure(GuiceTester.java:14)
1 error
at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:554)
at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:161)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:108)
at com.google.inject.Guice.createInjector(Guice.java:87)
at com.google.inject.Guice.createInjector(Guice.java:69)
at com.google.inject.Guice.createInjector(Guice.java:59)
at org.example.GuiceTester.main(GuiceTester.java:32)
I'm new to pac4j and guice, any help would be appreciated!
Upvotes: 0
Views: 236
Reputation: 2699
I'm not sure here, but I don't see any real cache implementation in your dependencies: can you try adding this dependency:
libraryDependencies ++= Seq(
caffeine
)
?
Upvotes: 0