Insert qualifier string in CDI

I'm trying to do a simple thing. Inject assigned String (or File ) to the CDI.

So, I have a qualifier:

 @Retention(RetentionPolicy.RUNTIME) @Target({FIELD,METHOD,PARAMETER,TYPE}) @Qualifier public @interface FilesRepositoryPath {} 

I have a producer:

 public class FilesRepositoryPathProducer { @Produces @FilesRepositoryPath public String getRepositoryDirectory() { return "path.taken.from.configuration"; } } 

And I'm trying to use it:

 @ApplicationScoped public class FilesRepository { @Inject public FilesRepository(@FilesRepositoryPath String filesDirectory) { //Do some stuff } } 

However, WELD cannot create an instance of a bean. I get an exception:

 org.jboss.arquillian.impl.event.FiredEventException: org.jboss.weld.exceptions.UnproxyableResolutionException: WELD-001410 The injection point [field] @Inject private za.co.fnb.commercial.dms.file.FilesRepositoryBeanTest.repo has non-proxyable dependencies 

I know String impregnable, but why does WELD want to create a proxy? It has an @Dependent , so AFAIK should not create a proxy server. How can I make it work?

+6
source share
1 answer

you need a default constructor

 @ApplicationScoped public class FilesRepository { public FilesRepository() { } @Inject public FilesRepository(@FilesRepositoryPath String filesDirectory) { //Do some stuff } } 
+2
source

Source: https://habr.com/ru/post/886328/


All Articles