Not able to run batch script(.bat file) in Jenkins client machine - java

In my Java program I am launching batch script(.bat file).
I am facing following error:
FATAL: command execution failed
java.io.IOException: Cannot run program "cmd" (in directory "C:\..\Project_Name"): CreateProcess error=87, The parameter is incorrect
at java.lang.ProcessBuilder.start(Unknown Source)
at hudson.Proc$LocalProc.<init>(Proc.java:244)
at hudson.Proc$LocalProc.<init>(Proc.java:216)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:815)
at hudson.Launcher$ProcStarter.start(Launcher.java:381)
at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:1148)
at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:1113)
at hudson.remoting.UserRequest.perform(UserRequest.java:120)
at hudson.remoting.UserRequest.perform(UserRequest.java:48)
at hudson.remoting.Request$2.run(Request.java:326)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at hudson.remoting.Engine$1$1.run(Engine.java:62)
at java.lang.Thread.run(Unknown Source)
at ......remote call to VM1(Native Method)
at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1416)
at hudson.remoting.UserResponse.retrieve(UserRequest.java:220)
at hudson.remoting.Channel.call(Channel.java:781)
at hudson.Launcher$RemoteLauncher.launch(Launcher.java:928)
at hudson.Launcher$ProcStarter.start(Launcher.java:381)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:95)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:64)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:782)
at hudson.model.Build$BuildExecution.build(Build.java:205)
at hudson.model.Build$BuildExecution.doRun(Build.java:162)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
at hudson.model.Run.execute(Run.java:1738)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:410)
Caused by: java.io.IOException: CreateProcess error=87, The parameter is incorrect
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
at java.lang.ProcessBuilder.start(Unknown Source)
at hudson.Proc$LocalProc.<init>(Proc.java:244)
at hudson.Proc$LocalProc.<init>(Proc.java:216)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:815)
at hudson.Launcher$ProcStarter.start(Launcher.java:381)
at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:1148)
at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:1113)
at hudson.remoting.UserRequest.perform(UserRequest.java:120)
at hudson.remoting.UserRequest.perform(UserRequest.java:48)
at hudson.remoting.Request$2.run(Request.java:326)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at hudson.remoting.Engine$1$1.run(Engine.java:62)
at java.lang.Thread.run(Unknown Source)
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE
I have made Jenkins service as Windows service and tried with providing administrator privileges to the service. I have changed Jenkins Client service properties But I am facing the same error.
Following are the ways I am launching my batch script:
Desktop.getDesktop().open(new File("C:\\file1.bat"));
and
Runtime.getRuntime().exec("cmd /c C:\\file1.bat");
or
Runtime.getRuntime().exec("C:\\file1.bat");
In my case all client machines are windows machies.
Please anyone tell me how to solve this.

Check the log
"C:\..\Project_Name"
This directory is invalid...
So in addition you should avoid the root directory "C:\" wich is protected by windows.
Try to work with the current directory (should be the job workspace).

Related

exe file generated from jar not running in windows [duplicate]

This question already has an answer here:
executable created with "jpackage"silently fails if jar is missing
(1 answer)
Closed 1 year ago.
I have generated an exe file using jpackager in windows, when I install it and try to run, this error is generated.
Device initialization failed for : d3d, sw
Error initializing QuantumRenderer: no suitable pipeline found
java.lang.RuntimeException: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer.getInstance(Unknown Source)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.init(Unknown Source)
at javafx.graphics/com.sun.javafx.tk.Toolkit.getToolkit(Unknown Source)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(Unknown Source)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(Unknown Source)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.startToolkit(Unknown Source)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(Unknown Source)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at java.base/sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
Caused by: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(Unknown Source)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Exception in thread "main" java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at java.base/sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
Caused by: java.lang.RuntimeException: No toolkit found
at javafx.graphics/com.sun.javafx.tk.Toolkit.getToolkit(Unknown Source)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(Unknown Source)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(Unknown Source)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.startToolkit(Unknown Source)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(Unknown Source)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(Unknown Source)
... 5 more
Any ideas on how to solve this will be really appreciated
This is how I generated the exe file
jpackage -t exe --name "wetu" --app-version 1.0 --input "C:\Users\home\Documents\Andrew\Projects\Java\WetuLantern\dist" --dest "C:\Users\home\Documents\Andrew\wetu-exe" --main-jar "WetuLantern.jar" --icon "C:\Users\home\Documents\Andrew\icon.ico" --module-path "C:\Users\home\Downloads\Compressed\javafx-jmods-16" --add-modules javafx.controls,javafx.graphics,javafx.fxml,javafx.base --win-shortcut --win-menu --win-console
Activate Windows console with --win-console as outlined in this answer. This allow you to identify the error message.
Secondly, the installer does not upgrade the previous installation after each build unless you increase the --app-version each time or un-install the previous copy before installing new copy.

Embedded Tomcat failed to scan

I work on Eclipse with an embedded Tomcat (8.0.24). I ran mvn clean package install and got a build success.
However, when I start tomcat by running a main method in Eclipse (as it's an embedded Tomcat), I got lots of error like :
mai 11, 2018 3:26:20 PM org.apache.tomcat.util.scan.StandardJarScanner processURLs
WARNING: Failed to scan [file:/C:/Users/username/.m2/repository/com/sun/xml/ws/jaxws-rt/2.1.7/saaj-impl.jar] from classloader hierarchy
java.io.FileNotFoundException: C:\Users\username\.m2\repository\com\sun\xml\ws\jaxws-rt\2.1.7\saaj-impl.jar (The system cannot find the file specified)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(Unknown Source)
at java.util.zip.ZipFile.<init>(Unknown Source)
at java.util.jar.JarFile.<init>(Unknown Source)
at java.util.jar.JarFile.<init>(Unknown Source)
at org.apache.tomcat.util.compat.JreCompat.jarFileNewInstance(JreCompat.java:188)
at org.apache.tomcat.util.scan.JarFileUrlJar.<init>(JarFileUrlJar.java:65)
at org.apache.tomcat.util.scan.JarFactory.newInstance(JarFactory.java:49)
at org.apache.tomcat.util.scan.StandardJarScanner.process(StandardJarScanner.java:374)
at org.apache.tomcat.util.scan.StandardJarScanner.processURLs(StandardJarScanner.java:309)
at org.apache.tomcat.util.scan.StandardJarScanner.doScanClassPath(StandardJarScanner.java:266)
at org.apache.tomcat.util.scan.StandardJarScanner.scan(StandardJarScanner.java:229)
at org.apache.catalina.startup.ContextConfig.processJarsForWebFragments(ContextConfig.java:1888)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1116)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:765)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:299)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:94)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5138)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1421)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1411)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
I listed some of the concerned .jar :
com\sun\xml\bind\jaxb-xjc\2.1.7\jsr173_1.0_api.jar
com\sun\xml\bind\jaxb-xjc\2.1.7\activation.jar
com\sun\xml\bind\jaxb-xjc\2.1.7\jaxb-impl.jar
com\sun\xml\bind\jaxb-xjc\2.1.7\jaxb-api.jar
com\sun\xml\bind\jaxb-xjc\2.1.7\activation.jar
com\sun\xml\bind\jaxb-impl\2.1.7\jaxb1-impl.jar
com\sun\xml\bind\jaxb-impl\2.1.7\jsr173_1.0_api.jar
com\sun\xml\bind\jaxb-impl\2.1.7\activation.jar
com\sun\xml\bind\jaxb-impl\2.1.7\jaxb-api.jar
com\sun\xml\messaging\saaj\saaj-impl\1.3.3\activation.jar
com\sun\xml\messaging\saaj\saaj-impl\1.3.3\saaj-api.jar
com\sun\xml\ws\jaxws-rt\2.1.7\stax-utils.jar
com\sun\xml\ws\jaxws-rt\2.1.7\streambuffer.jar
com\sun\xml\ws\jaxws-rt\2.1.7\stax-ex.jar
com\sun\xml\ws\jaxws-rt\2.1.7\activation.jar
com\sun\xml\ws\jaxws-rt\2.1.7\jaxb-impl.jar
com\sun\xml\ws\jaxws-rt\2.1.7\jaxb-api.jar
com\sun\xml\ws\jaxws-rt\2.1.7\resolver.jar
com\sun\xml\ws\jaxws-rt\2.1.7\woodstox.jar
com\sun\xml\ws\jaxws-rt\2.1.7\sjsxp.jar
com\sun\xml\ws\jaxws-rt\2.1.7\jsr173_api.jar
com\sun\xml\ws\jaxws-rt\2.1.7\saaj-impl.jar
com\sun\xml\ws\jaxws-rt\2.1.7\saaj-api.jar
com\sun\xml\ws\jaxws-rt\2.1.7\jsr250-api.jar
com\sun\xml\ws\jaxws-rt\2.1.7\jsr181-api.jar
com\sun\xml\ws\jaxws-rt\2.1.7\jaxws-api.jar
javax\xml\soap\saaj-api\1.3\servlet.jar
javax\xml\soap\saaj-api\1.3\jax-qname.jar
javax\xml\soap\saaj-api\1.3\activation.jar
javax\xml\soap\saaj-api\1.3\jaxp-api.jar
I already deleted the content of repository in .m2 and eclipse->project->maven->update project->update project (and force update of snapshot/release).
I checked in the indicated locations and indeed those .jar don't exist. I am a maven's beginner so maybe my error is stupid...

java.io.IOException: Cannot run program java.exe (in directory "src") - error from Executable Jar

My code is working fine in Eclipse but when I am exporting from eclipse in executable jar format or by using maven, I am getting the below error:
Full error :
java.io.IOException: Cannot run program "C:\myPrograms\jdk1.7.0_79\bin\java.exe" (in directory "src"): CreateProcess error=267, The directory name is invalid
at java.lang.ProcessBuilder.start(Unknown Source)
at TestAuomation.Jobs.execJob(Jobs.java:154)
at TestAuomation.Jobs$Build_JobParams.runJob(Jobs.java:67)
at TestAuomation.intelliPerf$BackgroundTask.doInBackground(intelliPerf.java:849)
at TestAuomation.intelliPerf$BackgroundTask.doInBackground(intelliPerf.java:845)
at javax.swing.SwingWorker$1.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at javax.swing.SwingWorker.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: CreateProcess error=267, The directory name is invalid
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 11 more
I am able to launch the program from jar but getting this error when trying do to some operation which invokes java -jar .... I am running this inside my program using process builder
Please suggest what I am doing wrong

Jenkins cannot start process on Windows Slave

Jenkins build running on Windows slave throws following error when build starts:
Java.io.IOException: Cannot run program "tf" (in directory "c:\Jenkins\workspace\ProjectName-WindowsPhone"): CreateProcess error=87, The parameter is incorrect
at java.lang.ProcessBuilder.start(Unknown Source)
What I tried:
1. specifying full path to the TF.exe
2. specifying path to the TF.exe in the PATH variable
3. setting PATH=. at the build process init stage
4. settings CLASSPATH=. at the build process init stage
5. setting CLASSPATH=. as environment variable on the slave.
TF.exe is resolved under Jenkins Slave service user in any directory, so it's not a problem of path to the TF.exe
Appreciate any help or thoughts on configuring Jenkins with Windows Slave and TFS.
Full error log is below (yes, it's Java stack trace ;))
$ tf workspaces -format:brief -server:https://cloudtfsname.visualstudio.com/DefaultCollection/ ********
java.io.IOException: Cannot run program "tf" (in directory "c:\Jenkins\workspace\ProjectName-WindowsPhone"): CreateProcess error=87, The parameter is incorrect
at java.lang.ProcessBuilder.start(Unknown Source)
at hudson.Proc$LocalProc.<init>(Proc.java:244)
at hudson.Proc$LocalProc.<init>(Proc.java:216)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:803)
at hudson.Launcher$ProcStarter.start(Launcher.java:381)
at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:1136)
at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:1101)
at hudson.remoting.UserRequest.perform(UserRequest.java:118)
at hudson.remoting.UserRequest.perform(UserRequest.java:48)
at hudson.remoting.Request$2.run(Request.java:328)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at hudson.remoting.Engine$1$1.run(Engine.java:63)
at java.lang.Thread.run(Unknown Source)
at ......remote call to WindowsSlave(Native Method)
at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1356)
at hudson.remoting.UserResponse.retrieve(UserRequest.java:221)
at hudson.remoting.Channel.call(Channel.java:752)
at hudson.Launcher$RemoteLauncher.launch(Launcher.java:916)
at hudson.Launcher$ProcStarter.start(Launcher.java:381)
at hudson.plugins.tfs.TfTool.execute(TfTool.java:99)
at hudson.plugins.tfs.model.Server.execute(Server.java:120)
at hudson.plugins.tfs.model.Workspaces.getListFromServer(Workspaces.java:38)
at hudson.plugins.tfs.model.Workspaces.populateMapFromServer(Workspaces.java:50)
at hudson.plugins.tfs.model.Workspaces.exists(Workspaces.java:76)
at hudson.plugins.tfs.actions.CheckoutAction.checkout(CheckoutAction.java:36)
at hudson.plugins.tfs.TeamFoundationServerScm.checkout(TeamFoundationServerScm.java:176)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1270)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:609)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:531)
at hudson.model.Run.execute(Run.java:1750)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:89)
at hudson.model.Executor.run(Executor.java:240)
Caused by: java.io.IOException: CreateProcess error=87, The parameter is incorrect
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
at java.lang.ProcessBuilder.start(Unknown Source)
at hudson.Proc$LocalProc.<init>(Proc.java:244)
at hudson.Proc$LocalProc.<init>(Proc.java:216)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:803)
at hudson.Launcher$ProcStarter.start(Launcher.java:381)
at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:1136)
at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:1101)
at hudson.remoting.UserRequest.perform(UserRequest.java:118)
at hudson.remoting.UserRequest.perform(UserRequest.java:48)
at hudson.remoting.Request$2.run(Request.java:328)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at hudson.remoting.Engine$1$1.run(Engine.java:63)
at java.lang.Thread.run(Unknown Source)
"TF.exe is resolved under Jenkins Slave service user in any directory, so it's not a problem of path to the TF.exe"
You are not fully understanding how jenkins works. In fact the only env variables that are understanded are the global ones and the user one are not considered for clean builds.
There is no any magic in Jenkins You should have tried to set the PATH as a build stage, RESTART slave and then run the task.
another hint for anyone who comes across this:there are some known issues with jenkins plugins causing this.see JENKINS-22183, JENKINS-45128 or JENKINS-33159 for example...
or try Jenkins issue search

help for solving problems in a java rmi assignment

Hi I want to write a client/server application with java rmi, that the client has the ability to run the window media player in the server side. I have used the ProcessBuilder class like this:
ProcessBuilder process= new ProcessBuilder(“mwplayer”).start();
but it doesn’t work. It cause these exceptions:
java.io.IOException: Cannot run program "mwplayer": CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(Unknown Source)
at server.ServerFrame.mediaPlayer(ServerFrame.java:135)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 16 more
How can I solve this problem? Can you help me with it?
Thanks a lot
The error message is telling you that the ProcessBuilder can't see a file named mwplayer.
Maybe try specifying the full path to mwplayer, instead of just the binary name. I would imagine there aren't any environment variables set in the context of your call.
Isn't it called 'wmplayer', with the m and the w swapped?

Categories