0 Replies Latest reply on Mar 21, 2018 7:14 AM by Roberto P.

    WELD-001475: Injecting with Arquillian

    Roberto P. Newbie

      H,

      when i deploy using ShrinkWrap a WebArchive, I get this Exception above, that i dont get when deploy war files manually to Wildfly 10 (and it works perfectly) why?

       

       

      11:51:08,457 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC000001: Failed to start service jboss.deployment.unit."javaee-soteria-1.0.0.war".WeldStartService: org.jboss.msc.service.StartException in service jboss.deployment.unit."javaee-soteria-1.0.0.war".WeldStartService: Failed to start service

      at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904)

      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

      at java.lang.Thread.run(Thread.java:745)

      Caused by: org.jboss.weld.exceptions.DeploymentException: Exception List with 2 exceptions:

      Exception 0 :

      org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type HashGenerator with qualifiers @Sha @HashServiceType

        at injection point [BackedAnnotatedField] @Inject @HashServiceType @Sha id.swhp.javaee.soteria.business.security.boundary.TokenStore.hash

        at id.swhp.javaee.soteria.business.security.boundary.TokenStore.hash(TokenStore.java:0)

      WELD-001475: The following beans match by type, but none have matching qualifiers:

        - Session bean [class id.swhp.javaee.soteria.business.security.control.SHAGenerator with qualifiers [@HashServiceType @Any]; local interfaces are [HashGenerator],

        - Session bean [class id.swhp.javaee.soteria.business.security.control.PbkdfGenerator with qualifiers [@HashServiceType @Any]; local interfaces are [HashGenerator]

       

       

      at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:359)

      at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:281)

      at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:134)

      at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:155)

      at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:518)

      at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:68)

      at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:66)

      at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:63)

      at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:56)

      at java.util.concurrent.FutureTask.run(FutureTask.java:266)

      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

      at java.lang.Thread.run(Thread.java:745)

      at org.jboss.threads.JBossThread.run(JBossThread.java:320)

      Exception 1 :

      org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type HashGenerator with qualifiers @Sha @HashServiceType

        at injection point [BackedAnnotatedField] @Inject @HashServiceType @Sha id.swhp.javaee.soteria.business.account.boundary.AccountStore.tokenHash

        at id.swhp.javaee.soteria.business.account.boundary.AccountStore.tokenHash(AccountStore.java:0)

      WELD-001475: The following beans match by type, but none have matching qualifiers:

        - Session bean [class id.swhp.javaee.soteria.business.security.control.SHAGenerator with qualifiers [@HashServiceType @Any]; local interfaces are [HashGenerator],

        - Session bean [class id.swhp.javaee.soteria.business.security.control.PbkdfGenerator with qualifiers [@HashServiceType @Any]; local interfaces are [HashGenerator]

       

      I have interface class HashGenerator implemented by:

      @Stateless
      @HashServiceType(HashType.SHA)

      public class SHAGenerator implements HashGenerator {..}

       

      and

       

      @Stateless
      @HashServiceType(HashType.PBKDF)

      public class PbkdfGenerator implements HashGenerator{..]

       

      I have a Producer method for only @Sha annotation:

       

      public class AlgorithmProducer {

       

         @Produces
         @HashServiceType(HashType.SHA)

         @Sha
         public HashGenerator produceHashGenerator(InjectionPoint ip) {

        HashGenerator hashGenerator = null;

        for (Annotation annotation : ip.getAnnotated().getAnnotations()) {

         if (annotation instanceof Sha) {

       

         Sha shaAnnotation = (Sha) annotation;
         hashGenerator = new SHAGenerator(shaAnnotation.algorithm().getAlgorithmName());
         }

        }

       

         return hashGenerator;
         }

      }

       

       

      I think he doesn't like in a AccountStore Ejb these variables declaration:

       

      @Stateless
      public class AccountStore {

       

      @Inject
      @HashServiceType(HashType.SHA)

      @Sha(algorithm = SHAAlgorithm.SHA256)

      HashGenerator tokenHash;

      @Inject
      @HashServiceType(HashType.PBKDF)

      HashGenerator passwordHash;

      ...

      ...

      }

       

      I think HashServiceType has got the right HashType.SHA enum as parameter(member type passed through the annotation graphs "( ..)") and not other ones, using @NonBindind didin't resolve my problem..

       

      The  annotation interfaces :

       

      @Documented
      @Qualifier
      @Retention(RUNTIME)

      @Target({METHOD, FIELD, PARAMETER, TYPE})

      public @interface HashServiceType {

       

        HashType value();

      }

      @Documented
      @Qualifier
      @Retention(RUNTIME)

      @Target({METHOD, FIELD, PARAMETER, TYPE})

      public @interface Sha {

       

         @Nonbinding
         SHAAlgorithm algorithm() default SHAAlgorithm.SHA512;
      }

       

      My Shrinkwar contains all classes and read deployements descriptor from java source like my deployed war:

       

      @Deployment
         public static Archive deploy(){

         //import pom with transitive deps
         resolveProjectSrcFilesPath(); --> read pom.xml, persistence.xml,beans.xml from filesystem and setting variables above:persistencePath,beansPath,webPath
         File[] files = Maven.resolver()beansPath

        .loadPomFromFile(pompath)

        .importRuntimeAndTestDependencies()

        .resolve()

        .withTransitivity()

        .asFile();
         return ShrinkWrap.create(WebArchive.class, "javaee-soteria-1.0.0.war")

        .addAsLibraries(files)

        .addClass(Account.class)

        .addClass(AccountStore.class)

        .addClass(AccountNotVerifiedException.class)

        .addClass(AlgorithmProducer.class)

        .addClass(BusinessException.class)

        .addClass(HashGenerator.class)

        .addClass(HashType.class)

        .addClass(HashServiceType.class)

        .addClass(InstantConverter.class)

        .addClass(InvalidPasswordException.class)

        .addClass(InvalidClassException.class)

        .addClass(InvalidCredentialException.class)

        .addClass(InvalidUsernameException.class)

        .addClass(PbkdfGenerator.class)

        .addClass(SHAAlgorithm.class)

        .addClass(SHAGenerator.class)

        .addClass(Sha.class)

        .addClass(SoteriaFormAuthenticationMechanism.class)

        .addClass(SoteriaIdentityStore.class)

        .addClass(SoteriaRememberMeIdentityStore.class)

        .addClass(Token.class)

        .addClass(TokenScheduler.class)

        .addClass(TokenStore.class)

        .addClass(TokenType.class)

        .addClass(User.class)

        .addClass(UserNameNotTaken.class)

        .addClass(UserNameNotTakenValidator.class)

        .addClass(Register.class)

        .addAsResource(new File(persistencePath))

         .addAsResource (new File(beansPath))
         .addAsWebInfResource(new File(webPath));

         }

       

      Thanks