Announcement Announcement Module
Collapse
No announcement yet.
Unavailable Scope Variable causes SpelEvaluationException: EL1008E Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Unavailable Scope Variable causes SpelEvaluationException: EL1008E

    Hi all,

    currently I'm migrating from Spring 2.x, Spring Security 2.0.4 and Spring Webflow 2.0.8 to Spring 3.0.5, Spring Security 3.0.5 and Webflow 2.2.1.

    I'm facing following Exception when a scoped variable is not set, but given in the flowdefinition.
    Code:
    Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 16): Field or property 'newDocumentation' cannot be found on object of type 'org.springframework.webflow.engine.impl.RequestControlContextImpl'
    	at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:207)
    	at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:71)
    	at org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:64)
    	at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:57)
    	at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:102)
    	at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:97)
    	at org.springframework.binding.expression.spel.SpringELExpression.getValue(SpringELExpression.java:78)
    	... 88 more
    In Webflow 2.0.8 a variable, which is not in scope returns NULL, now in 2.2.1 this Exception is thrown - that breaks my whole application

    To be more specific - here are the settings:

    flowdefinition: documentation.xml
    Code:
    <view-state id="enterDocumentation">
    	<transition on="edit" to="editDocumentation">
    		<evaluate expression="DocumentationBB.init(SoDocumentationEDM.rowData)" result="flowScope.selectedDocumentation"/>
    	</transition>
    	<transition on="create" to="editDocumentation">
    		<evaluate expression="DocumentationBB.init(newDocumentation)" result="flowScope.selectedDocumentation"/>
    	</transition>
    </view-state>
    <view-state id="editDocumentation">
    ...
    </view-state>
    java code: DocumentationBB.java
    Code:
    public SoDocumentation init(SoDocumentation doc){
    	if(doc == null){
    		doc = new SoDocumentation();
    		...
    	}
    		
    	return doc;
    }
    This flowdefinition throws the SpelEvaluationException when transition 'create' should be executed (using WebFlow 2.2.1 and Spring/Security 3.0.5). With WebFlow 2.0.8 and Spring/Security 2.x - this worked without any errors.

    To get this flow working in 2.2.1 I have to change the flowdefinition as follows:
    Code:
    <transition on="create" to="editDocumentation">
        <evaluate expression="DocumentationBB.init(flowScope.newDocumentation)" result="flowScope.selectedDocumentation"/>
    </transition>
    So can someone please tell me if I did something wrong or if this behaviour is a bug or a new feature?
    If this is a new feature, is it possible to tweak some settings to use the old behaviour? ...otherwise I have to rewrite all our flows.

    Thanks in advance - Jan

  • #2
    I think this behaviour is based on a change in the flow search algorithm...

    Looking at org.springframework.webflow.expression.spel.ScopeS earchingPropertyAccessor
    which is called by org.springframework.expression.spel.ast.PropertyOr FieldReference
    by method:
    Code:
    private TypedValue readProperty(ExpressionState state, String name) throws EvaluationException
    ScopeSearchingPropertyAccessor
    Code:
    public boolean canRead(EvaluationContext context, Object target, String name) throws AccessException {
    		return (findScopeForAttribute((RequestContext) target, name) != null);
    	}
    
    private MutableAttributeMap findScopeForAttribute(RequestContext requestContext, String name) {
    		if (requestContext.getRequestScope().contains(name)) {
    			return requestContext.getRequestScope();
    		}
    		if (requestContext.getFlashScope().contains(name)) {
    			return requestContext.getFlashScope();
    		}
    		if (requestContext.inViewState() && requestContext.getViewScope().contains(name)) {
    			return requestContext.getViewScope();
    		}
    		if (requestContext.getFlowScope().contains(name)) {
    			return requestContext.getFlowScope();
    		}
    		if (requestContext.getConversationScope().contains(name)) {
    			return requestContext.getConversationScope();
    		}
    		return null;
    	}
    Of course this will return null/false, cause without a doubt my variable 'newDocumentation' doesnt exists in any scope. With respect to the PropertyAccessor based implementation, it wouldn't make sense if a the ScopeSearchingPropertyAccessor would fake it could handle this variable and just return a null value at the end. ...there would be still the chance any other Accessor could handle my variable...

    So i think the next question is: Is it somehow possible to use something this way:
    Code:
    <transition on="create" to="editDocumentation">
    			<evaluate expression="DocumentationBB.init(NULL)" result="flowScope.selectedDocumentation"/>
    		</transition>
    create/use NULL variables just within the flow??

    Comment


    • #3
      Hello,

      did you find any solution/workaround for this?

      regards, Bo

      Comment

      Working...
      X