0

Deltaspikes @WindowScoped を TomEE で動作させる方法に苦労しています (1.5.2、1.5.3-SNAPSHOT、および 1.6.0-SNAPSHOT を試しました)。

deltaspike 0.4 コア + jsf の依存関係を伴う、非常に最小限の戦争です。

今、私はこのような HelloWorldBean を作成しました:

@Named("HW")
@WindowScoped
public class HelloWorldBean implements PassivationCapable,Serializable{

    private static final long serialVersionUID = 1L;
    private String name;

    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @PostConstruct
    public void test() {
        System.out.println("Bean did get constructed");
    }
....
}

空のbeans.xml、空のfaces-config.xml、および非常に最小限のweb.xmlがあります。

私が持っている非常に単純なページで。

<h:form>
           <h:inputText value="#{HW.name}"></h:inputText>
       <h:commandButton value="Welcome Me" actionListener="#{HW.printIt}"></h:commandButton>
        </h:form>

ページは正常に動作し、windowId がリクエストに追加され、ページを更新すると、Bean がインスタンス化されていないことがわかります (つまり、test() は 1 回だけ呼び出されます)。しかし、commandButton を押すとすぐに ContextNotActiveException 例外が発生します。

org.apache.myfaces.view.facelets.el.ContextAwareELException: javax.el.ELException: Error reading 'name' on type de.glauche.beans.HelloWorldBean$$OwbNormalScopeProxy0
    at org.apache.myfaces.view.facelets.el.ContextAwareTagValueExpression.getValue(ContextAwareTagValueExpression.java:104)
    at javax.faces.component._DeltaStateHelper.eval(_DeltaStateHelper.java:249)
    at javax.faces.component.UIOutput.getValue(UIOutput.java:67)
    at javax.faces.component.UIInput.getValue(UIInput.java:151)
    at javax.faces.component.UIInput.validate(UIInput.java:618)
    at javax.faces.component.UIInput.processValidators(UIInput.java:274)
    at javax.faces.component.UIForm.processValidators(UIForm.java:213)
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1427)
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1427)
    at javax.faces.component.UIViewRoot._processValidatorsDefault(UIViewRoot.java:1456)
    at javax.faces.component.UIViewRoot.access$500(UIViewRoot.java:74)
    at javax.faces.component.UIViewRoot$ProcessValidatorPhaseProcessor.process(UIViewRoot.java:1563)
    at javax.faces.component.UIViewRoot._process(UIViewRoot.java:1412)
    at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:812)
    at org.apache.myfaces.lifecycle.ProcessValidationsExecutor.execute(ProcessValidationsExecutor.java:38)
    at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:170)
    at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
    at org.apache.deltaspike.jsf.impl.listener.request.DeltaSpikeLifecycleWrapper.execute(DeltaSpikeLifecycleWrapper.java:75)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:45)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
    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:724)
Caused by: javax.el.ELException: Error reading 'name' on type de.glauche.beans.HelloWorldBean$$OwbNormalScopeProxy0
    at javax.el.BeanELResolver.getValue(BeanELResolver.java:68)
    at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:58)
    at org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:179)
    at org.apache.el.parser.AstValue.getValue(AstValue.java:183)
    at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:185)
    at org.apache.webbeans.el22.WrappedValueExpression.getValue(WrappedValueExpression.java:70)
    at org.apache.myfaces.view.facelets.el.ContextAwareTagValueExpression.getValue(ContextAwareTagValueExpression.java:96)
    ... 35 more
Caused by: javax.enterprise.context.ContextNotActiveException: WebBeans context with scope type annotation @WindowScoped does not exist within current thread
    at org.apache.webbeans.container.BeanManagerImpl.getContext(BeanManagerImpl.java:299)
    at org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.getContextualInstance(NormalScopedBeanInterceptorHandler.java:88)
    at org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.get(NormalScopedBeanInterceptorHandler.java:70)
    at de.glauche.beans.HelloWorldBean$$OwbNormalScopeProxy0.getName(de/glauche/beans/HelloWorldBean.java)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at javax.el.BeanELResolver.getValue(BeanELResolver.java:64)
    ... 41 more

明らかな何かが欠けていますか?それともDeltaSpikeのバグですか?(またはTomEE?)

4

1 に答える 1

2

この例外は、windowId が WindowContext に設定されていないことを示します。適切な DeltaSpike タグをフラグメントに追加しましたか?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:c="http://java.sun.com/jsp/jstl/core"
  xmlns:ds="http://deltaspike.apache.org/jsf">

<h:head></h:head>

<h:body>
<ds:windowId/>
...

ds:windowId の部分が重要です。DeltaSpikeLifecycleWrapper#execute にデバッグして、windowId が正しく検出されるかどうかを確認できます。

于 2013-08-16T21:13:49.180 に答える