<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Spring bean not found in expressions (JavaConfig issue) in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/spring-bean-not-found-in-expressions-javaconfig-issue/m-p/115913#M81745</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thought I would post this issue and solution should someone else run into similar problem in the future…&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I fought for many hours with a problem where Activiti would not be able to find Spring beans when used in expressions like&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;activiti:expression="#{processingOrderTask.validateOrder(execution)}"&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;where the bean was defined as&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;@Service("processingOrderTask")&lt;BR /&gt;public class ProcessingOrderTask {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private static final Logger log = LoggerFactory.getLogger(ProcessingOrderTask.class);&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void validateOrder(DelegateExecution execution) throws Exception {&lt;BR /&gt;…&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried all kinds of tricks and solution suggestions that I could find in forums and even debugged through the expression evaluation code to understand what was wrong.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Finally I looked at Activiti code base and noticed that there was a SpringExpressionManager class that didn't show up in my expression evaluation phase. Turns out this was never instantiated due to missing applicationContext in the process engine factory.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The reason why it was missing is that I'm using Spring Java Config instead of XML config to initialize beans. ProcessEngineFactory indicates that it requires application context through implementing ApplicationContextAware interface, which is automatically called when the bean is created via XML definition. But not so when using Java Config!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I had to manually call setApplicationContext to get things working. Now the expressions are evaluated nicely.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;–&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Otto Chrons, CTO, Microtask Ltd.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 24 Apr 2012 12:42:03 GMT</pubDate>
    <dc:creator>ochrons</dc:creator>
    <dc:date>2012-04-24T12:42:03Z</dc:date>
    <item>
      <title>Spring bean not found in expressions (JavaConfig issue)</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/spring-bean-not-found-in-expressions-javaconfig-issue/m-p/115913#M81745</link>
      <description>Thought I would post this issue and solution should someone else run into similar problem in the future…I fought for many hours with a problem where Activiti would not be able to find Spring beans when used in expressions likeactiviti:expression="#{processingOrderTask.validateOrder(execution)}"‍wher</description>
      <pubDate>Tue, 24 Apr 2012 12:42:03 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/spring-bean-not-found-in-expressions-javaconfig-issue/m-p/115913#M81745</guid>
      <dc:creator>ochrons</dc:creator>
      <dc:date>2012-04-24T12:42:03Z</dc:date>
    </item>
    <item>
      <title>Re: Spring bean not found in expressions (JavaConfig issue)</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/spring-bean-not-found-in-expressions-javaconfig-issue/m-p/115914#M81746</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks… Constructive feedback!!!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Apr 2012 19:53:19 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/spring-bean-not-found-in-expressions-javaconfig-issue/m-p/115914#M81746</guid>
      <dc:creator>ronald_van_kuij</dc:creator>
      <dc:date>2012-04-24T19:53:19Z</dc:date>
    </item>
  </channel>
</rss>

