Spring4 / Java 8 / Weblogic 12 - WorkManagerTaskExecutor.schedule recursive calls causing StackOverFlowError

786 Views Asked by At

We have migrated our enterprise software from Java 7 to Java 8, and along with it updated Spring to version 4.3.4. Since then the deployment is failing as one of the beans cannot be initialized due to a StackOverflowError:

Caused By: java.lang.StackOverflowError
    at org.springframework.scheduling.commonj.WorkManagerTaskExecutor.schedule(WorkManagerTaskExecutor.java:204)
    at org.springframework.scheduling.commonj.WorkManagerTaskExecutor.schedule(WorkManagerTaskExecutor.java:204)
    at org.springframework.scheduling.commonj.WorkManagerTaskExecutor.schedule(WorkManagerTaskExecutor.java:204)
    at org.springframework.scheduling.commonj.WorkManagerTaskExecutor.schedule(WorkManagerTaskExecutor.java:204)
    at org.springframework.scheduling.commonj.WorkManagerTaskExecutor.schedule(WorkManagerTaskExecutor.java:204)
    at org.springframework.scheduling.commonj.WorkManagerTaskExecutor.schedule(WorkManagerTaskExecutor.java:204)
    at org.springframework.scheduling.commonj.WorkManagerTaskExecutor.schedule(WorkManagerTaskExecutor.java:204)
    at org.springframework.scheduling.commonj.WorkManagerTaskExecutor.schedule(WorkManagerTaskExecutor.java:204)
    at org.springframework.scheduling.commonj.WorkManagerTaskExecutor.schedule(WorkManagerTaskExecutor.java:204)
    at org.springframework.scheduling.commonj.WorkManagerTaskExecutor.schedule(WorkManagerTaskExecutor.java:204)
    at org.springframework.scheduling.commonj.WorkManagerTaskExecutor.schedule(WorkManagerTaskExecutor.java:204)
    at org.springframework.scheduling.commonj.WorkManagerTaskExecutor.schedule(WorkManagerTaskExecutor.java:204)

As you can see, the method schedule() is getting called recursively, causing the stack overflow. The application is deployed on Weblogic version 12.1.3; here is the code snippet from WorkManagerTaskExecutor.schedule():

return this.workManager.schedule(work);

So this should delegate the scheduling call to the target WorkManager object. However, based on our debugging analysis the private member workManager inside WorkManagerTaskExecutor has been initialized with an instance of type WorkManagerTaskExecutor, i.e. when this.workManager.schedule(work); is executed, it is calling WorkManagerTaskExecutor.schedule(), leading to the recursive call.

The target WorkManager for Weblogic is set-up in the deployment descriptors as follows: ...

<resource-ref>
            <res-ref-name>wm/MyWorkManager</res-ref-name>
            <res-type>commonj.work.WorkManager</res-type>
            <res-auth>Container</res-auth>
            <res-sharing-scope>Shareable</res-sharing-scope>
        </resource-ref>

...

<work-manager>
    <name>wm/ODSCacheWorkManager</name>
    <max-threads-constraint>
        <name>MaxThreads</name>
        <count>1</count>
    </max-threads-constraint>
    <ignore-stuck-threads>true</ignore-stuck-threads>
</work-manager>

...

And inside Spring application context:

<bean autowire="byType" id="taskExecutor" class="org.springframework.scheduling.commonj.WorkManagerTaskExecutor">
            <property name="workManagerName" value="java:comp/env/wm/MyWorkManager"/>
            <property name="resourceRef" value="true"/>
        </bean> 

We are seriously running out of ideas why workManager inside WorkManagerTaskExecutor is initialized with an instace of WorkManagerTaskExecutor again, leading to the recursion. Can the community help?

0

There are 0 best solutions below