it-swarm.com.de

Die Verwendung von JSF 2.2.9 auf Spring + Tomcat verursacht Java.lang.NoClassDefFoundError: Javax/Enterprise/Kontext/SPI/Kontext

Ich muss benutzerdefinierte HTML-Attribute in JSF-Komponenten verwenden, und die einzige Lösung, die ich gefunden habe, ist die Verwendung von JSF 2.2:

<f:passThroughAttribute name="data-toggle" value="modal" />

Das Problem ist, dass ich Spring + Tomcat verwende und dies nicht ändern kann, da ich keine Zeit habe. Jedes Mal, wenn ich meinen Server starte, bekam ich die folgende Fehlermeldung:

Informações: CDI @ViewScoped manager unavailable
Java.lang.NoClassDefFoundError: javax/enterprise/context/spi/Contextual

Ich weiß, dass dies geschieht, weil ich kein CDI benutze, aber wie gesagt, kann ich aus Zeitgründen nicht von Spring zu CDI wechseln. 

Wie kann ich dieses Problem lösen? Ich muss JSF 2.2 (weil benutzerdefinierte HTML-Attribute) und Spring verwenden.

Gelöst:

Dieses Problem wurde behoben, ich habe ein Downgrade auf JSF 2.2.6 durchgeführt und der Fehler wurde abgebrochen.

Stack-Trace:

Fev 01, 2015 4:13:57 PM com.Sun.faces.application.view.ViewScopeManager <init>
Informações: CDI @ViewScoped manager unavailable
Java.lang.NoClassDefFoundError: javax/enterprise/context/spi/Contextual
at com.Sun.faces.application.view.ViewScopeManager.<init>(Unknown Source)
at com.Sun.faces.application.view.ViewScopeManager.getInstance(Unknown Source)
at com.Sun.faces.application.view.ViewScopeEventListener.processEvent(Unknown Source)
at javax.faces.event.SystemEvent.processListener(Unknown Source)
at javax.faces.event.ComponentSystemEvent.processListener(Unknown Source)
at com.Sun.faces.application.ApplicationImpl.processListeners(Unknown Source)
at com.Sun.faces.application.ApplicationImpl.invokeListenersFor(Unknown Source)
at com.Sun.faces.application.ApplicationImpl.publishEvent(Unknown Source)
at javax.faces.component.UIViewRoot.getViewMap(Unknown Source)
at javax.faces.component.UIViewRoot.getViewMap(Unknown Source)
at com.Sun.faces.mgbean.BeanManager$ScopeManager$ViewScopeHandler.handle(Unknown Source)
at com.Sun.faces.mgbean.BeanManager$ScopeManager.pushToScope(Unknown Source)
at com.Sun.faces.mgbean.BeanManager.createAndPush(Unknown Source)
at com.Sun.faces.mgbean.BeanManager.create(Unknown Source)
at com.Sun.faces.el.ManagedBeanELResolver.resolveBean(Unknown Source)
at com.Sun.faces.el.ManagedBeanELResolver.getValue(Unknown Source)
at com.Sun.faces.el.DemuxCompositeELResolver._getValue(Unknown Source)
at com.Sun.faces.el.DemuxCompositeELResolver.getValue(Unknown Source)
at org.Apache.el.parser.AstIdentifier.getValue(AstIdentifier.Java:71)
at org.Apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.Java:189)
at com.Sun.faces.facelets.el.TagValueExpression.getValue(Unknown Source)
at javax.faces.component.UIComponentBase$AttributesMap.get(Unknown Source)
at com.Sun.faces.el.CompositeComponentAttributesELResolver$ExpressionEvalMap.get(Unknown Source)
at javax.el.MapELResolver.getValue(MapELResolver.Java:52)
at com.Sun.faces.el.DemuxCompositeELResolver._getValue(Unknown Source)
at com.Sun.faces.el.DemuxCompositeELResolver.getValue(Unknown Source)
at org.Apache.el.parser.AstValue.getValue(AstValue.Java:169)
at org.Apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.Java:189)
at com.Sun.faces.facelets.el.ContextualCompositeValueExpression.getValue(Unknown Source)
at com.Sun.faces.facelets.el.TagValueExpression.getValue(Unknown Source)
at com.Sun.faces.application.ApplicationImpl.createComponentApplyAnnotations(Unknown Source)
at com.Sun.faces.application.ApplicationImpl.createComponent(Unknown Source)
at com.Sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.createComponent(Unknown Source)
at com.Sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(Unknown Source)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(Unknown Source)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(Unknown Source)
at com.Sun.faces.facelets.tag.composite.ImplementationHandler.apply(Unknown Source)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(Unknown Source)
at com.Sun.faces.facelets.compiler.NamespaceHandler.apply(Unknown Source)
at com.Sun.faces.facelets.compiler.EncodingHandler.apply(Unknown Source)
at com.Sun.faces.facelets.impl.DefaultFacelet.include(Unknown Source)
at com.Sun.faces.facelets.impl.DefaultFacelet.include(Unknown Source)
at com.Sun.faces.facelets.impl.DefaultFaceletContext.includeFacelet(Unknown Source)
at com.Sun.faces.facelets.tag.jsf.CompositeComponentTagHandler.applyCompositeComponent(Unknown Source)
at com.Sun.faces.facelets.tag.jsf.CompositeComponentTagHandler.applyNextHandler(Unknown Source)
at com.Sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(Unknown Source)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(Unknown Source)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(Unknown Source)
at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(Unknown Source)
at com.Sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(Unknown Source)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(Unknown Source)
at com.Sun.faces.facelets.tag.ui.DefineHandler.applyDefinition(Unknown Source)
at com.Sun.faces.facelets.tag.ui.CompositionHandler.apply(Unknown Source)
at com.Sun.faces.facelets.impl.DefaultFaceletContext$TemplateManager.apply(Unknown Source)
at com.Sun.faces.facelets.impl.DefaultFaceletContext.includeDefinition(Unknown Source)
at com.Sun.faces.facelets.tag.ui.InsertHandler.apply(Unknown Source)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(Unknown Source)
at com.Sun.faces.facelets.compiler.NamespaceHandler.apply(Unknown Source)
at com.Sun.faces.facelets.compiler.EncodingHandler.apply(Unknown Source)
at com.Sun.faces.facelets.impl.DefaultFacelet.include(Unknown Source)
at com.Sun.faces.facelets.impl.DefaultFacelet.include(Unknown Source)
at com.Sun.faces.facelets.impl.DefaultFacelet.include(Unknown Source)
at com.Sun.faces.facelets.impl.DefaultFaceletContext.includeFacelet(Unknown Source)
at com.Sun.faces.facelets.tag.ui.CompositionHandler.apply(Unknown Source)
at com.Sun.faces.facelets.compiler.NamespaceHandler.apply(Unknown Source)
at com.Sun.faces.facelets.compiler.EncodingHandler.apply(Unknown Source)
at com.Sun.faces.facelets.impl.DefaultFacelet.apply(Unknown Source)
at com.Sun.faces.application.view.FaceletViewHandlingStrategy.buildView(Unknown Source)
at com.Sun.faces.lifecycle.RenderResponsePhase.execute(Unknown Source)
at com.Sun.faces.lifecycle.Phase.doPhase(Unknown Source)
at com.Sun.faces.lifecycle.LifecycleImpl.render(Unknown Source)
at javax.faces.webapp.FacesServlet.service(Unknown Source)
at org.Apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.Java:304)
at org.Apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.Java:210)
at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.Java:72)
at org.Apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.Java:243)
at org.Apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.Java:210)
at br.com.jwebbuild.filter.LoginFilter.doFilter(LoginFilter.Java:73)
at org.Apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.Java:243)
at org.Apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.Java:210)
at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.Java:113)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.Java:76)
at org.Apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.Java:243)
at org.Apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.Java:210)
at org.Apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.Java:240)
at org.Apache.catalina.core.StandardContextValve.invoke(StandardContextValve.Java:164)
at org.Apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.Java:462)
at org.Apache.catalina.core.StandardHostValve.invoke(StandardHostValve.Java:164)
at org.Apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.Java:100)
at org.Apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.Java:562)
at org.Apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.Java:118)
at org.Apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.Java:395)
at org.Apache.coyote.http11.Http11Processor.process(Http11Processor.Java:250)
at org.Apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.Java:188)
at org.Apache.Tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.Java:302)
at Java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.Java:1145)
at Java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.Java:615)
at Java.lang.Thread.run(Thread.Java:744)
Caused by: Java.lang.ClassNotFoundException: javax.enterprise.context.spi.Contextual
at org.Apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.Java:1676)
at org.Apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.Java:1521)
... 98 more
10
Shelly

Ich habe dasselbe Problem und habe Ihre Frage auf Google (ich verwende JSF 2.2.9) gefunden. Mit der Antwort von hwellmann habe ich diese Abhängigkeit in pom.xml meines Maven-Projekts hinzugefügt:

<dependency>
    <groupId>javax.enterprise</groupId>
    <artifactId>cdi-api</artifactId>
    <version>1.2</version>
</dependency>

und Problem gelöst, danke!

18
wryel

Haben Sie den cdi-api.jar in Ihr Setup aufgenommen? 

Das bedeutet nicht, dass Sie use CDI in Ihrer Anwendung verwenden müssen, aber die API-Klassen müssen vorhanden sein, um die Abhängigkeiten von JSF zu erfüllen.

8
Harald Wellmann

Wahrscheinlich verwenden Sie den @ViewScoped von javax.faces.bean, der in JSF 2.0 hinzugefügt wurde. Versuchen Sie es mit der in JSF 2.2 hinzugefügten Anmerkung aus javax.faces.view.

0
Luiz