简体   繁体   English

JSF 2.2流和Tomcat 7 java.lang.NoClassDefFoundError:javax / enterprise / context / spi / Context

[英]JSF 2.2 Flows and Tomcat 7 java.lang.NoClassDefFoundError: javax/enterprise/context/spi/Context

I try to get familiar with the new jsf 2.2 features like page flows. 我尝试熟悉页面流之类的新jsf 2.2功能。 So I did my Project within Tomcat 7 and the help of Spring. 所以我在Tomcat 7和Spring的帮助下完成了我的项目。

Everything works fine until I added the first flow configuration and try to access the flow. 一切正常,直到我添加了第一个流程配置并尝试访问该流程。 I am pretty sure I have a missing dependency but what kind of. 我很确定我缺少一个依赖项,但是是什么样的。

I got the following Stacktrace within the call: 我在调用中得到了以下Stacktrace:

Sep 05, 2013 6:03:34 PM com.sun.faces.context.ExceptionHandlerImpl 
log 1100: javax/enterprise/context/spi/Context 
java.lang.NoClassDefFoundError: javax/enterprise/context/spi/Context
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:792)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2627)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:989)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1432)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1310)
at com.sun.faces.flow.FlowHandlerImpl.pushFlow(FlowHandlerImpl.java:374)
at com.sun.faces.flow.FlowHandlerImpl.transition(FlowHandlerImpl.java:278)
at com.sun.faces.flow.FlowHandlerImpl.clientWindowTransition(FlowHandlerImpl.java:321)
at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:270)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:121)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)

I have the following dependencies described in my pom file 我的pom文件中描述了以下依赖项

<properties>
    <org.springframework.version>3.2.3.RELEASE</org.springframework.version>
</properties>


<dependencies>

    <!-- Spring framework -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>
    <!-- Spring MVC framework -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>
    <!-- JSR-330 -->
    <dependency>
        <groupId>javax.inject</groupId>
        <artifactId>javax.inject</artifactId>
        <version>1</version>
    </dependency>

    <!-- JSF -->
    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-api</artifactId>
        <version>2.2.2</version>
    </dependency>
    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-impl</artifactId>
        <version>2.2.2</version>
    </dependency>

    <!-- servlet -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.0.1</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.1</version>
        <scope>provided</scope>
    </dependency>


</dependencies>

maybe someone knows how to deal with tomcat spring and jsf 2.2. 也许有人知道如何处理tomcat spring和jsf 2.2。

A maybe this could be helpful as well: I did not add anything to tomcat lib folder,I just add all jsf jars to the web archive, but that should make no difference, because the class is missing at all. 也许这也可能会有所帮助:我没有在tomcat lib文件夹中添加任何内容,我只是将所有jsf jar添加到了Web存档中,但这没有什么区别,因为该类完全丢失了。

JSF is slowly moving to CDI as to bean management. JSF正在将bean管理逐渐转移到CDI。 The new JSF 2.2 @FlowScoped annotation is CDI based. 新的JSF 2.2 @FlowScoped注释基于CDI。 CDI is part of Java EE Web Profile. CDI是Java EE Web Profile的一部分。 This is out the box provided by true Java EE containers such as TomEE , GlassFish , JBoss AS/EAP , WebSphere , WebLogic , Resin , etc, but not by barebones JSP/Servlet containers such as Tomcat and Jetty . 真正的Java EE容器(例如TomEEGlassFishJBoss AS / EAPWebSphereWebLogicResin等)提供了开箱即用的功能,但是准系统JSP / Servlet容器(例如TomcatJetty)没有提供此功能

Spring is essentially a full competitor of Java EE (CDI/EJB/JPA/JSF). Spring本质上是Java EE(CDI / EJB / JPA / JSF)的完整竞争对手。 You seem to have chosen for Tomcat+Spring instead of a real Java EE container. 您似乎选择了Tomcat + Spring,而不是真正的Java EE容器。 If you want to stick to Spring for some unclear reason, then you should be using Spring Web Flow instead of JSF Flow scope. 如果您出于某些不清楚的原因而坚持使用Spring ,那么应该使用Spring Web Flow而不是JSF Flow范围。

But if you're open to replacing Tomcat+Spring, then you can also just replace it altogether by one of the aforementioned Java EE containers. 但是,如果您愿意替换Tomcat + Spring,那么也可以只用上述Java EE容器之一完全替换它。 They will provide CDI/EJB/JPA (and JSF) out the box. 他们将提供开箱即用的CDI / EJB / JPA(和JSF)。 You can if necessary easily upgrade their bundled JSF implementation to the desired Mojarra 2.2.2 version. 您可以根据需要轻松地将其捆绑的JSF实现升级到所需的Mojarra 2.2.2版本。 The exact instructions depends on the container used. 确切说明取决于所使用的容器。

An alternative would be to install CDI in Tomcat. 一种替代方法是在Tomcat中安装CDI。 Weld (the CDI reference implementation) has a guide on exactly that subject: Application servers and environments supported by Weld . Weld(CDI参考实现)具有关于该主题的指南: Weld支持的应用程序服务器和环境

Newer versions of JSF expect a, more or less, full Web Profile to be available and tomcat isn't providing that. 较新版本的JSF期望或多或少可以使用完整的Web Profile,而tomcat不提供该Web Profile。 To be exact it is missing the CDI api, next to that you probably need a CDI implementation active (like Weld or the likes). 确切地说,它缺少CDI API,此外,您可能需要激活的CDI实现(例如Weld等)。

Some information in this forum post on the JBoss website. JBoss网站上此论坛中的一些信息。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 tomcat 10: java.lang.NoClassDefFoundError: jakarta/enterprise/context/spi/Contextual Error - tomcat 10: java.lang.NoClassDefFoundError: jakarta/enterprise/context/spi/Contextual Error java.lang.NoClassDefFoundError: javax/faces/context/FacesContextFactory - java.lang.NoClassDefFoundError: javax/faces/context/FacesContextFactory java.lang.NoClassDefFoundError:javax / persistence / spi / PersistenceProvider - java.lang.NoClassDefFoundError: javax/persistence/spi/PersistenceProvider 错误 java.lang.ClassNotFoundException:javax.enterprise.context.spi.Contextual - Error java.lang.ClassNotFoundException: javax.enterprise.context.spi.Contextual java.lang.NoClassDefFoundError:org / springframework / web / context / ContextCleanupListener - java.lang.NoClassDefFoundError: org/springframework/web/context/ContextCleanupListener java.lang.NoClassDefFoundError:org / springframework / context / EnvironmentAware - java.lang.NoClassDefFoundError: org/springframework/context/EnvironmentAware java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext maven - java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext maven 弹簧 java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext - SPRING java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext java.lang.NoClassDefFoundError: org/springframework/test/context/TestContextAnnotationUtils - java.lang.NoClassDefFoundError: org/springframework/test/context/TestContextAnnotationUtils Tomcat 7 - java.lang.NoClassDefFoundError:org / apache / log4j / spi / ThrowableInformation - Tomcat 7 - java.lang.NoClassDefFoundError: org/apache/log4j/spi/ThrowableInformation
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM