错误 java.lang.ClassNotFoundException:javax.enterprise.context.spi.Contextual

Error java.lang.ClassNotFoundException: javax.enterprise.context.spi.Contextual

我现在使用的是:

我正在尝试用我已经创建的列表填充 "ace:dataTable"。

当我尝试 运行 "Principal.xhtml" 时 ace:dataTable 页面加载正常,但是如果我添加 ace:dataTable 我想要填充的值它向我显示了错误 "HTTP 500 – Internal Server Error",除了“javax.servlet.ServletException: javax/enterprise/context/spi/Contextual javax.faces.webapp.FacesServlet.service(FacesServlet.java:683) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)"

这是我在 pom.xml

中使用的依赖项
   <dependency>
            <groupId>org.icefaces</groupId>
            <artifactId>icefaces</artifactId>
            <version>4.3.0</version>
        </dependency>

        <dependency>
            <groupId>org.icefaces</groupId>
            <artifactId>icefaces-ace</artifactId>
            <version>4.3.0</version>
        </dependency>

        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>7.0</version>
            <scope>provided</scope>
        </dependency>

这也是我在 XHTML 中使用的代码


<html  xmlns="http://www.w3.org/1999/xhtml"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:icecore="http://www.icefaces.org/icefaces/core"
       xmlns:ace="http://www.icefaces.org/icefaces/components">

    <h:head>
        <title>List Test</title>
    </h:head>
    <h:body>
        <ace:dataTable id="test"
                       value="#{personaController.listaPersona}"
                       rows="5"
                       var="item" 
                       paginator="true" styleClass="textTabla" paginatorPosition="bottom">

            <ace:column>
                <f:facet name="header">
                    <h:outputText value="SOLICITUD" styleClass="textTablaCabeza" />
                </f:facet>
                <h:outputText value="#{item.nombre}"  styleClass="textTablaDetalle" />
            </ace:column>
        </ace:dataTable>
    </h:body> 
</html>

这是控制器

import lista.model.PersonaModel;
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import lista.beans.PersonaBean;

@ManagedBean()
@ViewScoped
public class PersonaController {

    private List<PersonaBean> listaPersonaBean;
    private PersonaModel model;

    public PersonaController() {
        consultarLista();
    }

    public void consultarLista() {
        this.listaPersonaBean = this.model.retornaLista();
    }

    public List<PersonaBean> getListaPersona() {
        return listaPersonaBean;
    }

}

控制器之间有一个模型来设置列表,但这不是主要问题。

不知道该怎么做

这是完整的错误

excepción

javax.servlet.ServletException: javax/enterprise/context/spi/Contextual
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:683)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

causa raíz

java.lang.NoClassDefFoundError: javax/enterprise/context/spi/Contextual
    java.lang.Class.forName0(Native Method)
    java.lang.Class.forName(Class.java:348)
    com.sun.faces.util.Util.loadClass(Util.java:333)
    com.sun.faces.application.ApplicationImpl.newThing(ApplicationImpl.java:1847)
    com.sun.faces.application.ApplicationImpl.createComponentApplyAnnotations(ApplicationImpl.java:2019)
    com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:1246)
    com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.createComponent(ComponentTagHandlerDelegateImpl.java:588)
    com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:176)
    javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:135)
    javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:96)
    javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:161)
    com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:203)
    javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:135)
    javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:96)
    com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:94)
    javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:96)
    com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:88)
    com.sun.faces.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:162)
    com.sun.faces.application.view.FaceletViewHandlingStrategy.buildView(FaceletViewHandlingStrategy.java:381)
    com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:102)
    com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
    com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:223)
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:671)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

您的 pom 中似乎缺少 cdi-api:

所需的依赖项
<dependency>
    <groupId>javax.enterprise</groupId>
    <artifactId>cdi-api</artifactId>
    <version>1.2</version>
</dependency>

最后,我需要添加 cdi-api 依赖项,我不得不手动将 .jar 添加到 "WEB-INF/lib/" 文件夹

try with the following dependencies

<!-- CDI required APIs -->
        <dependency>
            <groupId>org.apache.geronimo.specs</groupId>
            <artifactId>geronimo-atinject_1.0_spec</artifactId>
            <version>1.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.geronimo.specs</groupId>
            <artifactId>geronimo-jcdi_2.0_spec</artifactId>
            <version>1.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.geronimo.specs</groupId>
            <artifactId>geronimo-interceptor_1.2_spec</artifactId>
            <version>1.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.geronimo.specs</groupId>
            <artifactId>geronimo-annotation_1.3_spec</artifactId>
            <version>1.0</version>
        </dependency>

        <!-- CDI Impl -->
        <dependency>
            <groupId>org.apache.openwebbeans</groupId>
            <artifactId>openwebbeans-impl</artifactId>
            <version>${owb.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.openwebbeans</groupId>
            <artifactId>openwebbeans-web</artifactId>
            <version>${owb.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.openwebbeans</groupId>
            <artifactId>openwebbeans-jsf</artifactId>
            <version>${owb.version}</version>
        </dependency>