2

我对 GlassFish 3.1.2 上的泛型和 CDI/WELD 有疑问。我有这些课程:

这是持有对 JPA 实体的引用的抽象 bean。

public abstract class AbstractViewBean<T extends Serializable> implements ISelectableBean {

    ...        

    private T viewObject;

    ...
}

然后我有我的 JSF bean/页面的抽象类,我想在其中注入 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;
    ...
}

一切正常。但为什么?

谢谢。

编辑:

我将weld-osgi-bundle.jar 的WELD 版本更新为1.1.11,但没有任何效果。

4

0 回答 0