You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
we are experiencing such a strange behavior with our thymeleaf templates using SPEL T() operator to get references to custom enums or types: everything goes straight till we get random failures in resolving our custom types.
"random" means that same template sometimes get parsed properly and sometimes don't.
It looks like failures occur only in asynch context (StreamingResponseBody's callbacks and @Asynch annotated methods)
org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "myVar == T(my.custom.TypeEnum).VALUE)" (template: "myTemplate" - line xx, col yy)
at org.thymeleaf.spring4.expression.SPELVariableExpressionEvaluator.evaluate(SPELVariableExpressionEvaluator.java:290) ~[thymeleaf-spring4-3.0.11.RELEASE.jar:3.0.11.RELEASE]
at org.thymeleaf.standard.expression.VariableExpression.executeVariableExpression(VariableExpression.java:166) ~[thymeleaf-3.0.11.RELEASE.jar:3.0.11.RELEASE]
at org.thymeleaf.standard.expression.SimpleExpression.executeSimple(SimpleExpression.java:66) ~[thymeleaf-3.0.11.RELEASE.jar:3.0.11.RELEASE]
...
at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:592) ~[thymeleaf-3.0.11.RELEASE.jar:3.0.11.RELEASE]
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1098) [thymeleaf-3.0.11.RELEASE.jar:3.0.11.RELEASE]
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1059) [thymeleaf-3.0.11.RELEASE.jar:3.0.11.RELEASE]
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1048) [thymeleaf-3.0.11.RELEASE.jar:3.0.11.RELEASE]
...
at org.springframework.aop.interceptor.AsyncExecutionInterceptor$1.call(AsyncExecutionInterceptor.java:115) [spring-aop-4.3.29.RELEASE.jar:4.3.29.RELEASE]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_201]
Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1005E: Type cannot be found 'my.custom.TypeEnum'
at org.springframework.expression.spel.support.StandardTypeLocator.findType(StandardTypeLocator.java:115) ~[spring-expression-4.3.29.RELEASE.jar:4.3.29.RELEASE]
at org.springframework.expression.spel.ExpressionState.findType(ExpressionState.java:154) ~[spring-expression-4.3.29.RELEASE.jar:4.3.29.RELEASE]
at org.springframework.expression.spel.ast.TypeReference.getValueInternal(TypeReference.java:64) ~[spring-expression-4.3.29.RELEASE.jar:4.3.29.RELEASE]
at org.springframework.expression.spel.ast.CompoundExpression.getValueRef(CompoundExpression.java:52) ~[spring-expression-4.3.29.RELEASE.jar:4.3.29.RELEASE]
at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:88) ~[spring-expression-4.3.29.RELEASE.jar:4.3.29.RELEASE]
at org.springframework.expression.spel.ast.OpEQ.getValueInternal(OpEQ.java:43) ~[spring-expression-4.3.29.RELEASE.jar:4.3.29.RELEASE]
at org.springframework.expression.spel.ast.OpEQ.getValueInternal(OpEQ.java:32) ~[spring-expression-4.3.29.RELEASE.jar:4.3.29.RELEASE]
at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:169) ~[spring-expression-4.3.29.RELEASE.jar:4.3.29.RELEASE]
at org.springframework.expression.spel.ast.OpAnd.getBooleanValue(OpAnd.java:56) ~[spring-expression-4.3.29.RELEASE.jar:4.3.29.RELEASE]
at org.springframework.expression.spel.ast.OpAnd.getValueInternal(OpAnd.java:51) ~[spring-expression-4.3.29.RELEASE.jar:4.3.29.RELEASE]
at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:169) ~[spring-expression-4.3.29.RELEASE.jar:4.3.29.RELEASE]
at org.springframework.expression.spel.ast.Ternary.getValueInternal(Ternary.java:51) ~[spring-expression-4.3.29.RELEASE.jar:4.3.29.RELEASE]
at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:119) ~[spring-expression-4.3.29.RELEASE.jar:4.3.29.RELEASE]
at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:327) ~[spring-expression-4.3.29.RELEASE.jar:4.3.29.RELEASE]
at org.thymeleaf.spring4.expression.SPELVariableExpressionEvaluator.evaluate(SPELVariableExpressionEvaluator.java:263) ~[thymeleaf-spring4-3.0.11.RELEASE.jar:3.0.11.RELEASE]
... 53 more
Due to the nature of the issue, I would be more inclined to see this as a possible Spring (SpEL) issue, not Thymeleaf. Thymeleaf should have no influence in SpEL being able to identify (or not) a type in a class loader. Could you please verify if maybe this is a known Spring issue, or whether this happens to you using more modern major versions of Spring? (I mean one of the latest 5.x)
I've been exploring all uses of StandardEvaluationContext and its subclass ThymeleafEvaluationContext in Thymeleaf and the referenced StandardTypeLocator is never set nor used directly, and the only constructor used for StandardEvaluationContextis the default one, so I'm assuming it's not Thymeleaf who's making this locator reference different class loaders among executions…
Regarding spring-projects/spring-framework#26253, we turned that into a documentation issue to raise awareness of the need to configure a suitable ClassLoader for the SpEL expression parser.
If your application or framework manages its own EvaluationContext, you may need to manually configure a StandardTypeLocator with a specific ClassLoader to ensure that the SpEL expression parser is able to reliably locate user types.
For example, the StandardBeanExpressionResolver in the spring-context module configures a StandardTypeLocator using the bean ClassLoader of the corresponding BeanFactory.
In light of that, you may also consider reopening this issue to see if you can address this in Thymeleaf.
Hi,
we are experiencing such a strange behavior with our thymeleaf templates using SPEL T() operator to get references to custom enums or types: everything goes straight till we get random failures in resolving our custom types.
"random" means that same template sometimes get parsed properly and sometimes don't.
It looks like failures occur only in asynch context (StreamingResponseBody's callbacks and @Asynch annotated methods)
see full stack trace
Thymeleaf
Environment
The text was updated successfully, but these errors were encountered: