<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=derenbacha" rel="nofollow">Alexander Derenbach</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-8873?redirect=false" rel="nofollow">SPR-8873</a></strong> and commented</p>
<p dir="auto">I want to have a cache class which clears itself. Since the both annotations are not working together I have to create a special task class.<br>
The problem is that the cache class is a proxy and then the scheduler runs into a ClassCastException.</p>
<p dir="auto">Perhaps it is no real bug. For me it is.<br>
It is also possible that is already a known issue without any possible solution.</p>
<p dir="auto">Desired syntax would be something like that:</p>
<p dir="auto"><code class="notranslate">@Scheduled</code>(fixedDelay=50000)<br>
<code class="notranslate">@CacheEvict</code>(value = "country", allEntries=true)<br>
public void clearCache() {<br>
//only clear cache;<br>
}</p>
<p dir="auto">greets Alex</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 3.1 RC1</p>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398114271" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/13293" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/13293/hovercard" href="https://github.com/spring-projects/spring-framework/issues/13293">#13293</a> <code class="notranslate">@Scheduled</code> doesn't work with well with proxies (<em><strong>"duplicates"</strong></em>)</li>
</ul>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=paulm" rel="nofollow">Paul Middelkoop</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-8651?redirect=false" rel="nofollow">SPR-8651</a></strong> and commented</p>
<p dir="auto">Tested on nightly build of August 29th 2011:</p>
<p dir="auto">public interface MyRepository {<br>
}</p>
<p dir="auto"><code class="notranslate">@Component</code><br>
public class MyRepositoryImpl implements MyRepository {<br>
<code class="notranslate">@Scheduled</code>(fixedDelay = 5)<br>
public void initCache() {}<br>
}</p>
<p dir="auto">This works. But when I change from <code class="notranslate">@Component</code> to <code class="notranslate">@Repository</code> I get this exception:</p>
<p dir="auto">java.lang.IllegalArgumentException: object is not an instance of declaring class<br>
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br>
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)<br>
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br>
at java.lang.reflect.Method.invoke(Method.java:597)<br>
at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:64)<br>
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:53)<br>
at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81)<br>
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)<br>
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)<br>
at java.util.concurrent.FutureTask.run(FutureTask.java:138)<br>
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)<br>
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)<br>
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)<br>
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)<br>
at java.lang.Thread.run(Thread.java:662)</p>
<p dir="auto">Adding the <code class="notranslate">@Scheduled</code> method to the interface doesn't help also.</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 3.1 M2</p>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398115736" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/13514" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/13514/hovercard" href="https://github.com/spring-projects/spring-framework/issues/13514">#13514</a> <code class="notranslate">@Scheduled</code> does not work in classes annotated with <code class="notranslate">@Cacheable</code> (<em><strong>"is duplicated by"</strong></em>)</li>
</ul>
<p dir="auto"><strong>Referenced from:</strong> commits <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/spring-projects/spring-framework/commit/d4123d06379fadc0b05043f5ab5a1a2cb264314b/hovercard" href="https://github.com/spring-projects/spring-framework/commit/d4123d06379fadc0b05043f5ab5a1a2cb264314b"><tt>d4123d0</tt></a></p>
<p dir="auto">2 votes, 3 watchers</p>