我在GlassFish 3.1.2上遇到泛型和CDI / WELD问题。我有这些课程:
这是一个抽象bean,它持有对JPA实体的引用。
public abstract class AbstractViewBean<T extends Serializable> implements ISelectableBean {
...
private T viewObject;
...
}
然后我有我的JSF bean / pages的抽象类,我想要注入TableLazyDataModel
public abstract class AbstractListPageAction<T extends AbstractViewBean<K>, K extends
Serializable> {
...
@Inject
private TableLazyDataModel<T, K> dataModel;
...
}
TableLazyDataModel:
public class TableLazyDataModel<T extends AbstractViewBean<K>, K extends Serializable>
extends LazyDataModel<T> {
...
}
如果我想部署应用程序,我会得到:
org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [TableLazyDataModel<UserViewBean, CcalPracovnik>] with qualifiers [@Default] at injection point [[field] @Inject private cz.wf.ui.component.page.AbstractListPageAction.dataModel]
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:311)
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:280)
at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:143)
at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:163)
at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:382)
at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:367)
at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:379)
at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:199)
如果我从AbstractViewBean和其他类中删除 extends Serializable :
public abstract class AbstractViewBean<T> implements ISelectableBean {
...
private T viewObject;
...
}
public abstract class AbstractListPageAction<T extends AbstractViewBean<K>, K> {
...
@Inject
private TableLazyDataModel<T, K> dataModel;
...
}
Everithing工作正常。但为什么呢?
感谢。
修改
我将weld-osgi-bundle.jar的WELD版本更新为1.1.11,但没有效果。