6
votes

I'm trying to do simple thing. Inject qualified String (or File) in 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 instantiate this bean. I am getting 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 is unproxable, but why WELD wants to create a proxy? It has @Dependent scope, so AFAIK it shouldn't create proxy anyway. How can I make it work?

1
Can you post FilesRepositoryBeanTest please?Jan Groth
file an issue in Weld. The code seems OK according to the spec.Bozho
Have a look here: stackoverflow.com/questions/7583871/…, seems to be a similar problemKris

1 Answers

3
votes

you need the default constructor

@ApplicationScoped
public class FilesRepository {

  public FilesRepository() {
  }

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