web-dev-qa-db-ja.com

Spring + TomcatでJSF2.2.9を使用すると、Java.lang.NoClassDefFoundErrorが発生します:javax / entity / context / spi / Contextual

私はJSFコンポーネント内でカスタムHTML属性を使用する必要があります。このため、私が見つけた唯一のソリューションは、JSF 2.2を使用することです。

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

問題は、Spring + Tomcatを使用していて、時間がないためにこれを変更できないことです。サーバーを起動するたびに、次のエラーが発生しました。

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

これはCDIを使用していないために発生することはわかっていますが、前述したように、時間の関係でSpringからCDIに変更することはできません。

この問題を解決するにはどうすればよいですか? JSF 2.2(カスタムhtml属性のため)とSpringを使用する必要があります。

解決済み:

この問題は解決されたため、JSF 2.2.6にダウングレードするとエラーが停止します。

スタックトレース:

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
12
Shelly

私は同じ問題を抱えており、グーグルであなたの質問を見つけました(私はJSF 2.2.9を使用しています)、hwellmannからの回答で、私は私のmavenプロジェクトのpom.xmlにこれらの依存関係を追加しました:

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

そして問題は解決しました、ありがとう!

21
wryel

セットアップに cdi-api.jar を含めましたか?

これは、アプリケーションでCDIをuse使用する必要があるという意味ではありませんが、JSFの依存関係を満たすために、APIクラスが存在する必要があります。

9
Harald Wellmann

おそらく、@ViewScopedからjavax.faces.beanを使用していますが、これはJSF2.0で追加されました。 JSF 2.2で追加されたjavax.faces.viewのアノテーションを使用してみてください。

1
Luiz