I am using a CDI Weld container with JSF 2.2 stream.
<dependency>
<groupId>org.jboss.weld.servlet</groupId>
<artifactId>weld-servlet-core</artifactId>
<version>2.2.11.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-core-jsf</artifactId>
<version>2.2.11.Final</version>
</dependency>
I use annotated discovery mode
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns = "http://xmlns.jcp.org/xml/ns/javaee" bean-discovery-mode = "annotated"/>
I am also trying to use sleep mode in the latest stable version application
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.3.10.Final</version>
</dependency>
This version has a transitive dependency org.jboss: jandex: 1.1.0.Final, which displays a Weld exception
Caused by: java.lang.NoSuchMethodError: org.jboss.jandex.ClassInfo.hasNoArgsConstructor()Z
at org.jboss.weld.environment.deployment.discovery.jandex.JandexClassFileInfo.<init>(JandexClassFileInfo.java:65)
at org.jboss.weld.environment.deployment.discovery.jandex.JandexClassFileServices.getClassFileInfo(JandexClassFileServices.java:82)
at org.jboss.weld.bootstrap.FastAnnotatedTypeLoader.loadAnnotatedType(FastAnnotatedTypeLoader.java:64)
at org.jboss.weld.bootstrap.BeanDeployer.addClass(BeanDeployer.java:97)
at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$1.doWork(ConcurrentBeanDeployer.java:65)
at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$1.doWork(ConcurrentBeanDeployer.java:62)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:60)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:53)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
... 3 more
To get around the exception, I added the latest jandex dependency to the classpath
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jandex</artifactId>
<version>1.2.4.Final</version>
</dependency>
If jandex is present in the path to Weld classes, @ javax.faces.view.ViewScoped and @ javax.faces.flow.FlowScoped beans are not registered. The problem is that having org.jboss.jandex.Index in the classpath applies the org.jboss.weld.environment.deployment.discovery.jandex.JandexDiscoveryStrategy strategy for registering beans.
org.jboss.weld.environment.deployment.discovery.DiscoveryStrategyFactory
if (Reflections.isClassLoadable(resourceLoader, JANDEX_INDEX_CLASS_NAME)) {
CommonLogger.LOG.usingJandex();
try {
return cast(classForName(resourceLoader, JANDEX_DISCOVERY_STRATEGY_CLASS_NAME).getConstructor(ResourceLoader.class, Bootstrap.class, Set.class)
.newInstance(resourceLoader, bootstrap, initialBeanDefiningAnnotations));
} catch (Exception e) {
throw CommonLogger.LOG.unableToInstantiate(JANDEX_DISCOVERY_STRATEGY_CLASS_NAME,
Arrays.toString(new Object[] { resourceLoader, bootstrap, initialBeanDefiningAnnotations }), e);
}
}
return new ReflectionDiscoveryStrategy(resourceLoader, bootstrap, initialBeanDefiningAnnotations);
@ViewScoped @FlowScoped bean.
org.jboss.weld.environment.deployment.discovery.ReflectionDiscoveryStrategy, bean. , @javax.enterprise.context.NormalScope
@NormalScope
@Inherited
@Documented
@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD})
@Retention(value = RetentionPolicy.RUNTIME)
public @interface ViewScoped {
}
org.jboss.weld.environment.deployment.discovery.ReflectionDiscoveryStrategy # hasBeanDefiningAnnotation
for (Class<? extends Annotation> metaAnnotation : metaAnnotations) {
if (hasBeanDefiningMetaAnnotationSpecified(clazz.getAnnotations(), metaAnnotation)) {
return true;
}
}
, ,