Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CDI container should be able to inject Cache #188

Closed
jerrinot opened this issue Jan 30, 2015 · 3 comments
Closed

CDI container should be able to inject Cache #188

jerrinot opened this issue Jan 30, 2015 · 3 comments

Comments

@jerrinot
Copy link
Contributor

currently the JCache CDI extension can inject CacheProvider and CacheManager. It mean a user still has to get a cache programmatically. I'd like to use:

    @Inject
    private Cache<String, Integer> cache2;

Currently it throws an exception during application deployment:

[2015-01-30T21:08:51.381+0000] [Payara 4.1] [SEVERE] [] [javax.enterprise.system.core] [tid: _ThreadID=44 _ThreadName=admin-listener(5)] [timeMillis: 1422652131381] [levelValue: 1000] [[
  Exception while loading the app : CDI deployment failure:WELD-001408: Unsatisfied dependencies for type Cache<String, Integer> with qualifiers @Default
  at injection point [BackedAnnotatedField] @Inject private info.jerrinot.demo.websession.CdiServlet.cache2
  at info.jerrinot.demo.websession.CdiServlet.cache2(CdiServlet.java:0)

org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type Cache<String, Integer> with qualifiers @Default
  at injection point [BackedAnnotatedField] @Inject private info.jerrinot.demo.websession.CdiServlet.cache2
  at info.jerrinot.demo.websession.CdiServlet.cache2(CdiServlet.java:0)

    at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:371)
    at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:293)
    at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:134)
    at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:167)
    at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:530)
    at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:516)
    at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:491)
    at org.jboss.weld.bootstrap.WeldStartup.validateBeans(WeldStartup.java:437)
    at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:90)
    at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:225)
    at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:131)
    at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:328)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:496)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
    at org.glassfish.deployment.admin.InstanceDeployCommand.execute(InstanceDeployCommand.java:213)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:539)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:535)
[...]
@smillidge
Copy link
Contributor

We didn't have time to do this as it needs a little more thought.

For example what is the semantics of
@Inject
private Cache<String, Integer> cache1;

@Inject
private Cache<String, Integer> cache2;

Does it inject the same cache or a different cache?
What is the name of the injected cache?
Also it would be good to be able to inject a Named Cache explicitly.

@smillidge
Copy link
Contributor

What do you think the default name should be when a user doesn't specify one. I've got working code for;

@NamedCache(value="MyCache")
@Inject
private Cache cache;

What will be the name for;

@Inject
private Cache cache;

JSR107 spec CacheMethodDetails Annotation used by interceptors uses a cache name fully qualified class name + . + method name + all parameters.

So I was thinking a raw class injection should use the fully qualified class name as the cache name?

Thoughts?

@Quix0r
Copy link

Quix0r commented Jan 28, 2019

@NamedCache is Payara-specific. Is there any portable way available? I like to to get rid of the annotation, not Payara to have it (my WAR project) fully portable (also runs the same way on any web container.

Cousjava pushed a commit to Cousjava/Payara that referenced this issue Nov 2, 2020
…DBCPoolTest

[QACI-445] - Disable PingJDBCPoolTest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants