Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows: Does not spawn process to start server on windows #9

Open
Vishal-Joshi opened this issue Feb 7, 2016 · 11 comments
Open

Windows: Does not spawn process to start server on windows #9

Vishal-Joshi opened this issue Feb 7, 2016 · 11 comments

Comments

@Vishal-Joshi
Copy link

I am using SpawnProcessTask to start embedded server in my application. Following is the gradle task:-

task startServer(group: "Exec", description: 'Starts the service in the background', type: SpawnProcessTask, dependsOn: 'createCapsule') {
command "java -jar ${projectDir}/build/libs/capsule.jar server ${projectDir}/config/local.yml"
ready 'org.eclipse.jetty.server.Server: Started'
directory "."
}

The above task performs perfectly fine on linux but fails on windows. Following is the exception I am getting:-


FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':startServer'.

    java.lang.NoSuchFieldException: pid

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED


@storytime
Copy link

The same issue, @Vishal-Joshi have you fix this issue?

@Vishal-Joshi
Copy link
Author

Hi @storytime, I could not find a fix for it :(. The only way I temporarily made it working is to run the jar through terminal which of course, consumes the terminal.

@wenslayer
Copy link

I see I'm not the only one experiencing this issue. I've got it working successfully on Linux and Mac for controlling the PhantomJS webdriver, but I get the same error above when trying to run it on Windows.

@ghost
Copy link

ghost commented Aug 19, 2016

The problem is in this part of code:

def pidField = process.class.getDeclaredField('pid')

In Windows would be necessary change to:

def pidField = process.class.getDeclaredField('handle')

https://github.com/marc0der/gradle-spawn-plugin/blob/master/src/main/groovy/com/wiredforcode/gradle/spawn/SpawnProcessTask.groovy#L94

@sachinkshetty
Copy link

@paulocardoso can you please tell me in which file should i change the pidField declaration in windows

echovue added a commit to echovue/gradle-spawn-plugin that referenced this issue Nov 30, 2016
@aaronbond
Copy link

I also would like this to be fixed.

@coderdude1
Copy link

I noticed @echovue appears to have implemented a fix for this, I'm hoping he will submit a pull request for his fix

@eskatos
Copy link

eskatos commented Jan 11, 2017

👍 to fix this, faced the issue too

@echovue
Copy link

echovue commented Jan 11, 2017

I'm still working on the fix... Seems like I get close, and then run into something else. Right now, I'm buried in the bowels of trying to use JNA to retrieve the Windows PID. Hopefully I'll have that figured out soon though.

@tmeltser
Copy link

tmeltser commented Jun 3, 2019

Hi,
I also just came across the same exact problem with the same stack trace (using the 0.8.2 release), and this prevents using it all together (and it is a very useful plugin).

Any update on the issue?

abarsov added a commit to abarsov/gradle-spawn-plugin that referenced this issue Jul 4, 2019
abarsov added a commit to abarsov/gradle-spawn-plugin that referenced this issue Jul 4, 2019
@abarsov
Copy link

abarsov commented Jul 4, 2019

I have implemented starting/killing process on Windows.
This would work with Java 9 and higher (since public method Process.pid() was added there).

Could someone with write access review and merge the pull request, please?

I could also update gradle version in a project to at list 4.8.1 if nobody would argue against that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants