# StackOverflowError in EclipseWtpPlugin

**URL:** <https://discuss.gradle.org/t/stackoverflowerror-in-eclipsewtpplugin/5744>\
**Category:** Old Forum Archive\
**Created:** [March 14, 2014, 2:49pm UTC](https://discuss.gradle.org/t/stackoverflowerror-in-eclipsewtpplugin/5744 "2014-03-14T14:49:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![carlo\_lf](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/carlo_lf/32/1881_2.png) [@carlo\_lf](https://discuss.gradle.org/u/carlo_lf)\
**Post date:** [March 14, 2014, 2:49pm UTC](https://discuss.gradle.org/t/stackoverflowerror-in-eclipsewtpplugin/5744/1 "2014-03-14T14:49:00Z")

</div>

I don’t know why I suddenly get a StackOverflowError whatever task I’m calling in my multiproject build. The curious thing is: I did not change but removed a dependsOn statement on the WAR task. (the plugin: ‘eclipse-wtp’ is only defined in those projects which produce WAR artifact.)

Now, wenn running with “–stacktrace” I can see Gradle is apparently running in some endless loop:

```gradle
Caused by: java.lang.StackOverflowError
        at org.gradle.plugins.ide.eclipse.EclipseWtpPlugin$this$3$eachDependedUponEclipseProject.callCurrent(Unknown Sou
rce)
        at org.gradle.plugins.ide.eclipse.EclipseWtpPlugin.eachDependedUponEclipseProject(EclipseWtpPlugin.groovy:231)
        at org.gradle.plugins.ide.eclipse.EclipseWtpPlugin.this$3$eachDependedUponEclipseProject(EclipseWtpPlugin.groovy
)
        at org.gradle.plugins.ide.eclipse.EclipseWtpPlugin$this$3$eachDependedUponEclipseProject.callCurrent(Unknown Sou
rce)
        at org.gradle.plugins.ide.eclipse.EclipseWtpPlugin.eachDependedUponEclipseProject(EclipseWtpPlugin.groovy:231)
        at org.gradle.plugins.ide.eclipse.EclipseWtpPlugin.this$3$eachDependedUponEclipseProject(EclipseWtpPlugin.groovy
)
        at org.gradle.plugins.ide.eclipse.EclipseWtpPlugin$this$3$eachDependedUponEclipseProject.callCurrent(Unknown Sou
rce)
        at org.gradle.plugins.ide.eclipse.EclipseWtpPlugin.eachDependedUponEclipseProject(EclipseWtpPlugin.groovy:231)
        at org.gradle.plugins.ide.eclipse.EclipseWtpPlugin.this$3$eachDependedUponEclipseProject(EclipseWtpPlugin.groovy
)
....

```

Any idea what’s going wrong here?

---

<div class="post-metadata">

**Author:** ![carlo\_lf](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/carlo_lf/32/1881_2.png) [@carlo\_lf](https://discuss.gradle.org/u/carlo_lf)\
**Post date:** [March 14, 2014, 4:06pm UTC](https://discuss.gradle.org/t/stackoverflowerror-in-eclipsewtpplugin/5744/2 "2014-03-14T16:06:00Z")

</div>

I could figure out the problematic thing. In the dependencies section of my war project I have a switch statement:

```gradle
switch (customer.toUpperCase()) {
  case 'BGETEM':
      runtime project(':de.uvdms.bgetem.common')
   runtime project(':de.uvdms.bgetem.server')
    break
  case 'BGHW':
   runtime project(':de.uvdms.bghw.common')
   //runtime project(':de.uvdms.bghw.server')
   break
                 case 'BGV':
   runtime project(':de.uvdms.bgv.common')
   runtime project(':de.uvdms.bgv.server')
       break
...
}

```

What is commented out above is the bad boy. But I cannot see WHY there is a problem. The other cases are just constructed the same way.

---

<div class="post-metadata">

**Author:** ![Alexander\_Melnik](https://avatars.discourse-cdn.com/v4/letter/a/a9a28c/32.png) [@Alexander\_Melnik](https://discuss.gradle.org/u/Alexander_Melnik)\
**Post date:** [March 17, 2014, 1:12pm UTC](https://discuss.gradle.org/t/stackoverflowerror-in-eclipsewtpplugin/5744/3 "2014-03-17T13:12:00Z")

</div>

EclipseWtpPlugin.eachDependedUponEclipseProject(EclipseWtpPlugin.groovy:231)

```gradle
def dependedUponProjects = projectDeps*.dependencyProject
           for (dependedUponProject in dependedUponProjects) {
               dependedUponProject.plugins.withType(EclipseWtpPlugin) { action(dependedUponProject) }
               eachDependedUponEclipseProject(dependedUponProject, action)
           }

```

Stackoverflow is a result of the recursion (dependency cycle)

---

<div class="post-metadata">

**Author:** ![carlo\_lf](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/carlo_lf/32/1881_2.png) [@carlo\_lf](https://discuss.gradle.org/u/carlo_lf)\
**Post date:** [March 17, 2014, 3:25pm UTC](https://discuss.gradle.org/t/stackoverflowerror-in-eclipsewtpplugin/5744/4 "2014-03-17T15:25:00Z")

</div>

Yes, Alexander, you’re right. The problem came into the game when I modelled the construction of a tar artifact which has different jars for packaging, depending on the target customer build. There was a cycle in the dependency graph.

Not sure if Gradle should have detected it instead of hanging in this endless loop. Anyway, when I put an apply plugin: ‘eclipse-wtp’ in one those projects, Gradle showed the cycle.
