Coder Social home page Coder Social logo

Comments (23)

bmuschko avatar bmuschko commented on June 13, 2024

You got to assign a stop key in your build script as well. Here's one example:

[tomcatRun, tomcatRunWar, tomcatStop]*.stopPort = 8090
[tomcatRun, tomcatRunWar, tomcatStop]*.stopKey = 'foo'

from gradle-tomcat-plugin.

303devworks avatar 303devworks commented on June 13, 2024

Thanks.... but I still have an issue.

If I use this:

[tomcatRun, tomcatRunWar, tomcatStop]*.stopPort = 8090
[tomcatRun, tomcatRunWar, tomcatStop]*.stopKey = 'foo'
tomcatRun {
    httpPort = 8080
    daemon = true
}

The stop no longer errors out but tomcat is still running.

When I type "gradle tomcatRun", then "gradle tomcatStop", then "gradle tomcatRun" - I get a bind exception.

Ideas?

from gradle-tomcat-plugin.

bmuschko avatar bmuschko commented on June 13, 2024

Are you sure you want to run your Tomcat with the daemon option? Actually, the Gradle process would have stopped in between each of your calls. What's the exception you get?

from gradle-tomcat-plugin.

303devworks avatar 303devworks commented on June 13, 2024

here is the output: https://gist.github.com/2148dc16a48d8b754b2d

The initial reason I use the daemon is here: http://forums.gradle.org/gradle/topics/cache_locking_error_gradle_m6

but even if that wasn't an issue, I'd like the option of a daemon.

from gradle-tomcat-plugin.

bmuschko avatar bmuschko commented on June 13, 2024

I see. You are running Gradle in daemon mode as well. It looks to me like you want to run in-container integration tests and then simply stop the Tomcat container. In that case I'd probably create a specific task to start up Tomcat, run the tests and then stop the container. Unfortunately, I don't have example code with me atm as I am traveling. I wanted to add that to the FAQ section at some point of time anyway. Have a look at this posting. It describes how you can set this up using the Jetty plugin. You can adept the code to make it work with the Tomcat plugin as well.

I'd have to have a look at why the container doesn't stop in Gradle daemon mode. It might be a bug.

from gradle-tomcat-plugin.

bmuschko avatar bmuschko commented on June 13, 2024

I am not quite sure why Gradle is behaving like this if you call gradle tomcatRun --daemon but the problem does not occur if you run gradle --daemon first before you run any other command. As the Gradle daemon feature is still an experimental feature it's still possible that it is buggy. Keep in mind that the Gradle daemon feature and the plugin daemon feature are two different things. You do not need to run Gradle in daemon mode for your in-container integration tests to work as you expect. I am going to close this issue for now. If you need further assistance please let me know. I will add an example on how to run integration tests using the Tomcat plugin in the FAQ section of the documentation soon.

from gradle-tomcat-plugin.

moritzp82 avatar moritzp82 commented on June 13, 2024

Hey Benjamin,

I'm currently experiencing the same issue: running gradle in daemon mode before starting a tomcat in a task lets the gradle-daemon bind the port but not releasing it after the task is done. I also posted in the gradle forum about it:
http://forums.gradle.org/gradle/topics/gradle_daemon_process_binds_port_but_never_releases_it

Cheers, Moritz

from gradle-tomcat-plugin.

bmuschko avatar bmuschko commented on June 13, 2024

Thanks for reporting this issue again I reopened the ticket and will have deeper look at it. Can you tell me which version of Gradle you are using?

from gradle-tomcat-plugin.

moritzp82 avatar moritzp82 commented on June 13, 2024

We're currently using version 1.1.

from gradle-tomcat-plugin.

ldaley avatar ldaley commented on June 13, 2024

Can someone please provide some steps to reproduce this.

from gradle-tomcat-plugin.

moritzp82 avatar moritzp82 commented on June 13, 2024

Sure.

  1. Add this line to the gradle.properties to enable the daemon:
    org.gradle.daemon=true
  2. Start task tomcatRunWar
  3. Check the port is being bind to the gradle process:
    netstat -tulpn
  4. When the gradle task is finished and the tomcat shutdown again, run the command from 3. again.

from gradle-tomcat-plugin.

ldaley avatar ldaley commented on June 13, 2024

How does the Gradle task “finish”? Does the user ctrl-c the build process?

from gradle-tomcat-plugin.

moritzp82 avatar moritzp82 commented on June 13, 2024

No, the task is done, therefore it finishes.

from gradle-tomcat-plugin.

ldaley avatar ldaley commented on June 13, 2024

How does tomcatRunWar know when to stop?

from gradle-tomcat-plugin.

moritzp82 avatar moritzp82 commented on June 13, 2024

E.g. the tests run against the tomcat are done and are calling tomcatStop.

from gradle-tomcat-plugin.

ldaley avatar ldaley commented on June 13, 2024

tomcatRunWar starts the tests?

from gradle-tomcat-plugin.

bmuschko avatar bmuschko commented on June 13, 2024

@moritzp82: Can you post your full build script or at least the relevant parts so we can get a good understanding of your the problem?

from gradle-tomcat-plugin.

moritzp82 avatar moritzp82 commented on June 13, 2024

Well, I can't post the full script but here is one task that's starting the tomcat

 tomcatRunWar {
     contextPath = '' 

     def testPort = System.properties['test.port']
     if (testPort == null) {
         testPort = '8080'
     }

     httpPort = testPort.toInteger()
     stopPort = testPort.toInteger() + 1

     tomcatStop.stopPort = stopPort
 }


 task webTests(type: Test, dependsOn: war) {
     include '**/WebSuite.class'
     doFirst {
         systemProperties['webdriver.firefox.profile'] = System.properties['webdriver.firefox.profile']
         if (systemProperties['webdriver.firefox.profile'] == null) {
             systemProperties['webdriver.firefox.profile'] = 'default'
         }
         tomcatRunWar.daemon = true
         tomcatRunWar.execute()
     }
     doLast {tomcatStop}
 } 

from gradle-tomcat-plugin.

bmuschko avatar bmuschko commented on June 13, 2024

@moritzp82: You are not executing the tomcatStop task via tomcatStop.execute() in the doLast action.

from gradle-tomcat-plugin.

moritzp82 avatar moritzp82 commented on June 13, 2024

That's right. I fixed that but it does not fix the issue. The task is done:

Total time: 1 mins 36.272 secs

and the output of sudo lsof -i -n -P | grep LISTEN | grep java still says the gradle process (daemon = true) is listening on port 8080:

java      3969    moritzprinz   61u  IPv6 0xdf762f340bf6dc7b      0t0    TCP *:51069 (LISTEN)
java      3969    moritzprinz  266u  IPv6 0xdf762f34119b5c7b      0t0    TCP *:8080 (LISTEN)
java      3969    moritzprinz  268u  IPv6 0xdf762f34119b905b      0t0    TCP 127.0.0.1:8081 (LISTEN)
java      3969    moritzprinz  269u  IPv6 0xdf762f34119b2c7b      0t0    TCP *:51189 (LISTEN)
java      3969    moritzprinz  369u  IPv6 0xdf762f34119b305b      0t0    TCP *:2048 (LISTEN)

Just to show you that 3969 really is gradle:

hcpc2:~ moritzprinz$ ps aux | grep gradle
moritzprinz     4105   0.9  0.0  2432768    504 s003  R+    9:17AM   0:00.00 grep gradle
moritzprinz     3969   0.0  3.6  4244008 596880 s003  S     9:13AM   2:38.98 /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java -XX:MaxPermSize=256m -XX:+HeapDumpOnOutOfMemoryError -Xmx1024m -Dfile.encoding=MacRoman -cp /Users/moritzprinz/gradle-1.1/lib/gradle-launcher-1.1.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 1.1 /Users/moritzprinz/.gradle/daemon 10800000 1de8281e-fcab-41f1-88e7-d09abb7615c3 -XX:MaxPermSize=256m -XX:+HeapDumpOnOutOfMemoryError -Xmx1024m -Dfile.encoding=MacRoman

from gradle-tomcat-plugin.

tddmonkey avatar tddmonkey commented on June 13, 2024

Has there been any update on this? I have just come across the same problem. I'm using gradle-tomcat-plugin:0.9.5 and gradle 1.3. Is there a workaround at all?

from gradle-tomcat-plugin.

bmuschko avatar bmuschko commented on June 13, 2024

Sorry, I haven't found any time to look into this in the meantime. Thanks for providing the information.

from gradle-tomcat-plugin.

bmuschko avatar bmuschko commented on June 13, 2024

This should be fixed by pull request #42.

from gradle-tomcat-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.