Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Make sure that you don't have exact duplicate <code>&lt;context:component-scan .../&gt;</code> elements in both xml configurations. If you have this you are basically duplicating all your bean instances. What you initially had was all beans get loaded by the <code>ContextLoaderListener</code> and those are proxied due to the existence of <code>&lt;tx:annotation-driven /&gt;</code>.</p> <p>Now if you have the same <code>&lt;context:component-scan .../&gt;</code> in your payment-servlet.xml this is going to scan again for all beans creating another instance, however due to the fact that there is no <code>&lt;tx:annotation-driven /&gt;</code> it will not be proxied and no transactions applied.</p> <p>What now happens is that as soon as you need one of your <code>@Service</code> annotated beans the <code>DispatcherServlet</code> looks first in its own <code>ApplicationContext</code> to see if there is bean to satisfy its needs. If there is it is going to be used (your current case) if there isn't it will consult the parent context (the one loaded by the <code>ContextLoaderListener</code>).</p> <p>What you need to do is configure the <code>ContextLoaderListener</code> to scan for everything <strong>BUT</strong> <code>@Controller</code> annotated beans and the <code>DispatcherServlet</code> to scan <strong>ONLY</strong> for <code>@Controller</code> annotated beans. This can be done by configuring the <code>&lt;context:component-scan .../&gt;</code> correctly.</p> <p>applicationContext.xml</p> <pre><code>&lt;context:component-scan base-package="com.appn.payment"&gt; &lt;context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" /&gt; &lt;/context:component-scan&gt; </code></pre> <p>payment-servlet.xml</p> <pre><code>&lt;context:component-scan base-package="com.appn.payment" use-default-filters="false"&gt; &lt;context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" /&gt; &lt;/context:component-scan&gt; </code></pre> <p>This will give you transactions and only single instances of your beans. You should remove the <code>&lt;tx:annotation-driven /&gt;</code> from the payment-servlet.xml file. </p> <p>There is still an open <a href="https://jira.springsource.org/browse/SPR-6803?page=com.googlecode.jira-suite-utilities%3atransitions-summary-tabpanel" rel="nofollow">JIRA issue</a> to have this included in the reference guide. Also a thread in the <a href="http://forum.springsource.org/showthread.php?84265-Why-is-TransactionSynchronizationManager-not-being-activited&amp;p=282436#post282436" rel="nofollow">Spring Community Forums</a> explaining this.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload