Questions tagged [cdi]

Contexts and Dependency Injection (CDI): Java Platform, Enterprise Edition (Java EE) 5 brought dependency injection (DI) with Convention over Configuration to Enterprise JavaBeans (EJB) 3.0. Java EE 6 introduces the flexible and powerful @Inject dependency injection model (JSR-330 and JSR-299) in addition to the already existing @EJB annotation.

Filter by
Sorted by
Tagged with
0 votes
0 answers
28 views

@Inject does not seem to work in my @WebServlet, the dependency is null

This is my servlet code. I'm using java ee and servlet to save my information. I used dependency injection. when I press button to run the servlet I have the error: Cannot invoke "appuser.model....
F.M's user avatar
  • 487
0 votes
1 answer
42 views

Quarkus: Inject/Use CDI bean inside a non-CDI bean

I'm trying to inject my singleton bean into a non-bean class, but for now, I always get that my injected dependency is null. Quarkus: 3.2.2 @Named("singletonConfiguration") @Singleton public ...
Dmitry Sinyavskiy's user avatar
-1 votes
0 answers
44 views

CRUD Weirdness After Switching from Spring Boot/Vaadin 14 to Vaadin 14 CDI

Per a different question thread, I'm following someone's advise to switch from Spring Boot/Vaadin to Vaadin CDI, so my app will finally deploy on JBoss 7.1 under Java 8. I've successfully deployed a ...
BelaOxmyx's user avatar
0 votes
0 answers
38 views

quarkus, @produces interface with multiple implementation

So I have one interface: public interface GService { String doIt(); } 2 implementations: @ApplicationScoped public class GServiceBImpl implements GService { @Override public String doIt() ...
Fabrizio Stellato's user avatar
-1 votes
0 answers
38 views

Using CDI in JAX-RS resource

I am working on a small app in which i am trying to build a Rest api using JAX-RS. I have this resource class, i which i am trying to unject the UserPersistenceService using the Inject annotaion from ...
Hadi Rifaii's user avatar
0 votes
1 answer
59 views

Microstream 8 CDI @Store type

Looking at a blog: https://openliberty.io/blog/2022/05/03/microstream-cdi-ext.html This example mentions the annotation type @Store. I'm using version 8 with JarkartaEE 10 and microprofile 6 so I'm ...
Jeff Rogers's user avatar
0 votes
0 answers
15 views

@predestroy of entity1 is being called on third redirect of any other entity in second tab

@predestroy of a page is being called whenever I redirect to another page in a new tab (for the third direction) My controller is @ViewScopped from java.faces.view cdi and @named the navigation to ...
Zeinab Abbas's user avatar
0 votes
1 answer
210 views

Quarkus native and Google Cloud Storage: "Your default credentials were not found" when injecting Storage via Producer

In my Quarkus service project I'm using Google Cloud Storage (GCS) to read from and write to GCS buckets. Recently I have refactored the code regarding GCS access to be able to unit test my service ...
devrys's user avatar
  • 1,569
0 votes
0 answers
49 views

@Inject from Jakarta failing to provide MetricRegistry Microprofile

I have a problem that I've been trying to solve for a while. I am trying to measure the performance in the app, and for that I want to use the microprofile metrics library from eclipse (more exactly, ...
alwond's user avatar
  • 1
0 votes
1 answer
36 views

Adding class annotations using CDI

I'm trying to use CDI extension event ProcessAnnotatedType to add a new annatioion to the interface of annotated type. Something like that: < T > void processAnnotatedType( @Observes ...
tomasz-mer's user avatar
  • 3,824
1 vote
1 answer
132 views

weld-junit5 with Java 17

Is it possible to run weld-junit5 with Java 17? We are using Wildfly 26 with Java 17. When I run a Unit test I get an exception: org.jboss.weld.exceptions.WeldException: WELD-001524: Unable to load ...
Jens's user avatar
  • 21
0 votes
0 answers
52 views

Field injection in Quarkus

I understand why Field Injection of CDI beans is not recommended in Spring (via @Autowired annotation). In Quarkus, however, this is a common practice (via @Inject annotation). Why is Field Injection ...
Morlin's user avatar
  • 49
0 votes
1 answer
40 views

GraalVM polyglot context and Jakarta CDI context: how access beans from scripts?

I'm sure I'm missing something, so here's how I understand things as for now: In order to execute a script we have to provide it with a context which among other things boils down to a set of variable ...
fedd's user avatar
  • 880
0 votes
3 answers
53 views

CDI factory design pattern with properties file

I have a interface like this : @Singleton public interface StorageEngine { String upload(InputStream inputStream); InputStream download(String fileName); int size(String fileName); ...
mah454's user avatar
  • 1,647
0 votes
0 answers
54 views

registering a dynamic bean with injection point in custom extension throws unsatisfied dependencies exception in cdi container bean validation phase

i am trying to write a cdi extension that registers a custom bean that himself has a injection of a managed bean. When deploying application to payara server i got error message: Exception during ...
durchflieger's user avatar
0 votes
0 answers
24 views

CDI dependency injection not working in JAX-RS resource

I'm building a REST API using JAX-RS framework for a school project but for some reason the CDI doesn't work, when I manually create a new instance of a class everything works as it should but when I ...
Thefizzlee's user avatar
0 votes
1 answer
102 views

Unsatisfied dependency for type MongoClient and qualifiers [@Default]

I've been struggling on the problem for 2 days already. I can't understand why CDI fails to inject MongoClient in my code: package edu.kmaooad.capstone23.relations.dal; import com.mongodb.client....
Capy Maths's user avatar
0 votes
1 answer
62 views

Why is @Specializes annotation not replacing my bean?

we have a java EE app that has a core module and some other modules. In the core module exists a scheduler, declared as follows: @Singleton @Transactional @RunAs("admintask") @RunAsPrincipal(...
Octavia's user avatar
  • 194
0 votes
1 answer
47 views

How can I exclude/remove a CDI extension that is added through a 3rd party jar?

As the title says, I want to exclude/remove a CDI extension at runtime that is added through a 3rd party jar? I tried several like ( but with no success) : AlterableContext destroy veto-ing
Stefan Rusen's user avatar
0 votes
0 answers
32 views

Unsatisfied Dependency in ConstraintValidator

I'm working on a Jakarta 8 application which runs on Payara 5.2020.4. Its uses CDI all over the place and its working without issues. Now I want to use Bean Validation. I have created a ...
Martin's user avatar
  • 852
1 vote
4 answers
151 views

Can you use alternative dependency injection frameworks with Helidon MP?

I'm getting started with Helidon MP and for the most part its pretty sweet. I'm not a huge fan of the CDI system as I have extensive experience with Guice in past projects. I've been trying to figure ...
slayton's user avatar
  • 20.2k
1 vote
1 answer
37 views

CDI exception when trying to use Infinispan JCache on OpenLiberty

I'm trying to use Infinispan and JCache API to add some caching feature tu my JEE app running on OpenLiberty. I'm trying to make it work in a POC project so, for now, I don't have any code, I'm just ...
Clément Honoré's user avatar
2 votes
1 answer
88 views

java.lang.RuntimeException: javax.faces.FacesException: Unable to find CDI BeanManager [duplicate]

I am completely new to JSF development and I am getting following exception while deploying to Tomcat 9.0.80: 27-Aug-2023 22:34:59.067 SEVERE [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core....
Python_user's user avatar
  • 1,427
0 votes
1 answer
49 views

Warning: Unable to register kotlin.Lazy for reflection using Quarkus

I have the following data class in my Kotlin code that uses Quarkus as a server side framework. data class Location( val id: String, val serviceTimeInMinutes: Long, val openingTimes: List&...
greyhairredbear's user avatar
1 vote
1 answer
80 views

No available endpoints in a helidon-mp 4.0.0-M1 application

I am experimenting with 4.0.0-M1 and helidon-mp. I have a simple app, with a database connection. However I am using CDI and am wondering why no endpoints are exposed. All my endpoints on localhost:...
Jens Mohrmann's user avatar
1 vote
0 answers
41 views

How to overcome multiple @Produces methods?

I have javaEE application in which i have factory class which has multiple @Produces methods. This method produce classes that i use in application with @Inject annotation. The issue is, when i want ...
Matej Delinčák's user avatar
0 votes
0 answers
61 views

When implementing a bean with the @Dependent annotation, 2 constructor calls occur

Why is this happening? Must the call occur 1 time? If I use @RequestScoped, then everything happens as usual and the constructor is called 1 time. @WebServlet(value = "/tes") public class ...
Vsevolod Kasatchikov's user avatar
0 votes
1 answer
28 views

I don't understand how the @ConversationScoped annotation works in CDI

I'm using the following code to test the operation of ConversationScoped, but I don't understand how it works. I open conversation, set the value of conversationBean.i = 1, then close conversation and ...
Vsevolod Kasatchikov's user avatar
2 votes
1 answer
140 views

CDI: Replacement for BeanManager.fireEvent()?

In a previous CDI version, there is a method on javax.enterprise.inject.spi.BeanManager called fireEvent that allows you to programmatically fire off an ad hoc CDI event, rather than requiring you to ...
Shadowman's user avatar
  • 11.3k
1 vote
1 answer
51 views

Does any class from a Spring ecosystem implement SeContainerInitializer or SeContainer?

I'm trying to use Jakarta jnosql Artemis along with a Spring Boot application. Artemis requires a CDI (Context and Dependency Injection) implementation to be provided. Overall, Spring Framework does ...
xinus01's user avatar
  • 47
0 votes
1 answer
41 views

How to annotate proxy beans to not be considered as "bean of interface" in CDI

Following scenario public interface MyInterface{ void doSomething(); } @ApplicationScoped public static class MyInterfaceImpl implements MyInterface{ @Override public void ...
Marian Klühspies's user avatar
1 vote
1 answer
47 views

Changing reference of ViewScoped beans in JSF 2.3 dynamically

I am working on an application in JSF, in which I have two ViewScoped beans within the same screen, and they need to communicate with each other. The first bean represents the main screen, and the ...
dssof's user avatar
  • 117
1 vote
0 answers
56 views

What scope should be used for ResteasyClient?

I am a bit confused about the proper scope of ResteasyClient in Quarkus. Based on the Quarkus documentation, the default scope for ResteasyClient is @Dependent which is bound to the bean injecting it, ...
khesam109's user avatar
  • 530
0 votes
0 answers
13 views

Using JSF websockets in an asynchronous context [duplicate]

I have a JSF Application and want to use websockets to send messages to the webclient. On the server side I'm executing some long-running asyn tasks, I perform it using the @Asynchronous annotation ...
Neo's user avatar
  • 1,337
0 votes
0 answers
172 views

Is it possible to define an interceptor on an interface in Quarkus?

In my working on an application using Quarkus and I want to intercept a method of an interface. I tried the following but its not working: First of all I define an annotation: @Target({ TYPE, METHOD ...
khesam109's user avatar
  • 530
5 votes
2 answers
76 views

How to fail when bean annotated with javax.faces.bean.ViewScoped

Is there a way of detecting @Named CDI-Beans which are created with javax.faces.bean.ViewScoped? It happened multiple times to me, that the IDE preferred this annotation to javax.faces.view.ViewScoped....
Adrian Jałoszewski's user avatar
1 vote
3 answers
59 views

CDI producer that handles any qualifier

Can I create a producer method that handles any arbitrary qualifier? i.e.: even qualifiers I'm not "aware-of" at design time? The challenge is that I want to create an injectable ...
Glenn Lane's user avatar
  • 3,902
0 votes
0 answers
68 views

Wildfly and QuartzScheduler - WELD-001303: No active contexts for scope type javax.enterprise.context.RequestScoped

i'm working on a ear java project using Quartz scheduler to schedule several jobs. When deploying my app on the local server I got this kind exception : 11:17:11,775 ERROR [org.quartz.core.JobRunShell]...
Geoffrey Aulombard's user avatar
0 votes
2 answers
576 views

ClassnotFoundException jakarta.Name:NamingException when running test CDITestRunner of deltaspike 1.9.6 with Jakarta

I am trying to use CDITestRunner in our tests using deltaspike with jakarta 1.9.6 versionand with apache open web beans. which is not running the tests with CDITestRunner and throwing ...
Gaurav's user avatar
  • 33
0 votes
0 answers
37 views

Obtaining CDI Alternatives programatically

I had the following interface public interface A { InputStream getPdf(String value); } with several implementations, each of them marked by a qualifier. For example: @Dependent @Vac public class ...
SJuan76's user avatar
  • 24.6k
1 vote
1 answer
405 views

Quarkus CDI not working when creating a library

I have two projects A and B in project B and i want to injcet a CDI bean from project A however, this fails due too java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build ...
santi254's user avatar
1 vote
1 answer
38 views

Is it possible to create a CDI Event factory?

On my quarkus app i have a application scope service with a lot of cdi event injections @ApplicationScoped public class SomeService { @Inject Event<EventA> eventAEmitter; @...
Bentz's user avatar
  • 103
1 vote
1 answer
36 views

Microprofile REST client providers not active if in separate jar file

I'd like to use some Microprofile REST client, injected with @RestClient, in different war files. I need to register a javax.ws.rs.client.ClientRequestFilter for basic authentication. If this filter ...
grigouille's user avatar
1 vote
0 answers
20 views

When CDI speaks of a parameterized type, does it also incorrectly mean array types of parameterized element types?

CDI frequently speaks of parameterized types. Does CDI (incorrectly) consider the array type java.util.List<java.lang.String>[] to be a parameterized type? (It is not, of course; its element ...
Laird Nelson's user avatar
  • 15.6k
2 votes
0 answers
19 views

What section of the CDI spec says that a bean type of String "matches" a required type of String?

The CDI specification says, in part: A bean is assignable to a given injection point if: The bean has a bean type that matches the required type. For this purpose, primitive types are considered to ...
Laird Nelson's user avatar
  • 15.6k
4 votes
1 answer
2k views

ERROR Couldn't find type javax.enterprise.context.ApplicationScoped. Are you missing a dependency on your classpath?

I'm writing Backend using Quarkus. Below is my POM.xml file: <?xml version="1.0"?> <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/...
MightyThor's user avatar
0 votes
0 answers
47 views

Providing zip/unzip functionalities as a service in Spring/CDI/etc

My application - a Swing-based desktop application (but I think that doesn't matter) - uses Spring Boot (but the question would be the same if I'd use CDI or DI container XYZ). The application is ...
Natasha's user avatar
  • 546
2 votes
2 answers
176 views

How to inject beans in QuarkusTestResourceLifecycleManager implementations

I try to implement a QuarkusTestResourceLifecycleManager implemenation which injects/looks up a bean in ArC, however the bean is not found. public class FlywayTestResource implements ...
syr's user avatar
  • 844
0 votes
1 answer
118 views

ViewScoped bean being initialized multiple times with includeViewParams="true"

I'm currently migrating an web application developed in JSF from Wildfly 26 to Wildfly28. All the code was refactored to jakarta.* and I'm experiencing some strange behaviour with ViewScoped beans. On ...
areal's user avatar
  • 157
0 votes
0 answers
107 views

org.jboss.weld.context.ContextNotActiveException: WELD-001303: No active contexts for scope type javax.enterprise.context.SessionScoped

The CDI SessionScoped is working great until the cluster server is restarted. Encounter "ContextNotActiveException: WELD-001303"(as below) when try to access. But the error go away after ...
Error 404's user avatar
  • 107

1
2 3 4 5
81