I am trying to run a command in Jenkins under build step of running commands in Execute windows batch command.
I wrote dir to run as a command
and when the job runs in Jenkins which is triggered by a change in content of a file following error is shown
[FSTrigger] Triggered by a change to a file (log)
Building in workspace C:\Users\Pankaj\.jenkins\jobs\convert File to text form\workspace
FATAL: null
java.util.NoSuchElementException
at java.util.TreeMap$PrivateEntryIterator.nextEntry(Unknown Source)
at java.util.TreeMap$EntryIterator.next(Unknown Source)
at java.util.TreeMap$EntryIterator.next(Unknown Source)
at java.util.TreeMap.buildFromSorted(Unknown Source)
at java.util.TreeMap.buildFromSorted(Unknown Source)
at java.util.TreeMap.buildFromSorted(Unknown Source)
at java.util.TreeMap.buildFromSorted(Unknown Source)
at java.util.TreeMap.buildFromSorted(Unknown Source)
at java.util.TreeMap.buildFromSorted(Unknown Source)
at java.util.TreeMap.putAll(Unknown Source)
at hudson.EnvVars.<init>(EnvVars.java:82)
at hudson.EnvVars$GetEnvVars.call(EnvVars.java:207)
at hudson.EnvVars$GetEnvVars.call(EnvVars.java:205)
at hudson.remoting.LocalChannel.call(LocalChannel.java:45)
at hudson.EnvVars.getRemote(EnvVars.java:202)
at hudson.model.Computer.getEnvironment(Computer.java:837)
at hudson.model.Run.getEnvironment(Run.java:1883)
at hudson.model.AbstractBuild.getEnvironment(AbstractBuild.java:836)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:75)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:58)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19)
at hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:710)
at hudson.model.Build$RunnerImpl.build(Build.java:178)
at hudson.model.Build$RunnerImpl.doRun(Build.java:139)
at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:480)
at hudson.model.Run.run(Run.java:1434)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:239)
Please see to this issue.
I don't think that you need to install Jenkins as a Windows service to execute a batch command as a build step. What might be an issue is that on Windows, commands such as dir are internal to the command interpreter (i.e. cmd.exe). In short, it means that in a Java program you cannot simply run the internal dir command using the java.lang.Runtime.exec("dir") method because there is no such a program as dir.exe (on your PATH). What you should do is execute the command interpreter itself and specify the internal command as a parameter, i.e. java.lang.Runtime.exec("cmd /C dir").
Having that said and being aware that Jenkins is a Java application, it's better to use cmd /C dir instead of just typing dir in Jenkins' job configuration. Internally, Jenkins might use some 3rd pary libraries for executing external processes, such as Apache Commons Exec (see http://commons.apache.org/exec/), which hide the details between internal command(s) and "normal" commands, but from my experience it's not the case for all releases - especially the old ones.
Answer to this question:
Actually i haven't installed Windows as a service in Jenkins. So for this we need to go to "manage Jenkins" and then click on "windows as a service".I.e Installing Jenkins as a windows service.
Related
I have a program in Apache Flink. I tested and ran it on the local machine and every thing works fine. To run the program on a remote cluster, I did necessary changes as mentioned in Apache Flink Official Website.
I did the following changes:
The two points below
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
ExecutionEnvironment env = ExecutionEnvironment.createRemoteEnvironment("taskManagerName",
portNo,paralelismNo);
Fixing the necessary paths to read input files and write outputs.
Generate a thin jar out of the program and put the necessary jar
libraries into a folder besides my project jar file called
myproj.jar.
copying the data and the jar library and myproj.jar into the cluster
and run the following command remotely on the cluster:
java -cp pathToJarLib \\* -jar myproj.jar
But, I get the below error and I don't have any clue to fix the issue. There are no relevant log files which can aid me in fixing this issue.
Error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/flink/api/common/functions/MapFunction
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2570)
at java.lang.Class.getMethod0(Class.java:2813)
at java.lang.Class.getMethod(Class.java:1663)
at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
Caused by: java.lang.ClassNotFoundException: org.apache.flink.api.common.functions.MapFunction
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 6 more
Your classpath is obviously not complete. Try to submit via bin/flink run myproj.jar. This sets up the classpath correctly.
I have a big application that worked perfect inside eclipse, I create an executable jar file for my application, My application use jython to define some resources. Also I create `the following .bat file to run the file:
# echo off
java -Xms64m -Xmx512m -Xincgc -Dpython.home=jython-2.1 -Dpython.path=jython-2.1/Lib/alice -Djava.library.path=lib/win32;externalLib/win32; -jar MyProg23.jar
When execute the .bat file an exception appeared, this is a part of this exception:
java.lang.ExceptionInInitializerError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at edu.cmu.cs.stage3.alice.authoringtool.JAlice.main(JAlice.java:163)
Caused by: Traceback (innermost last):
File "C:\MyWork\AliceDev\Alice test\resources\Alice Style.py", line 23, in ?
File "C:\MyWork\AliceDev\Alice test\resources\common\StandardResources.py", li
ne 181, in ?
AttributeError: java package 'javax' has no attribute 'vecmath'
at org.python.core.Py.AttributeError(Py.java)
at org.python.core.PyObject.__getattr__(PyObject.java)
at org.python.pycode._pyx1.f$0(C:\MyWork\AliceDev\Alice test\resources\c
ommon\StandardResources.py:181)
at org.python.pycode._pyx1.call_function(C:\MyWork\AliceDev\Alice test\r
esources\common\StandardResources.py)
at org.python.core.PyTableCode.call(PyTableCode.java)
at org.python.core.PyCode.call(PyCode.java)
at org.python.core.Py.runCode(Py.java)
at org.python.core.__builtin__.execfile_flags(__builtin__.java)
at org.python.core.__builtin__.execfile(__builtin__.java)
at org.python.core.__builtin__.execfile(__builtin__.java)
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 org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java
)
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java
)
at org.python.core.PyObject.__call__(PyObject.java)
at org.python.pycode._pyx0.f$0(C:\MyWork\AliceDev\Alice test\resources\A
lice Style.py:23)
at org.python.pycode._pyx0.call_function(C:\MyWork\AliceDev\Alice test\r
esources\Alice Style.py)
at org.python.core.PyTableCode.call(PyTableCode.java)
at org.python.core.PyCode.call(PyCode.java)
at org.python.core.Py.runCode(Py.java)
at org.python.core.__builtin__.execfile_flags(__builtin__.java)
at org.python.core.__builtin__.execfile(__builtin__.java)
at edu.cmu.cs.stage3.alice.authoringtool.AuthoringToolResources.loadReso
urcesPy(AuthoringToolResources.java:199)
at edu.cmu.cs.stage3.alice.authoringtool.AuthoringToolResources.<clinit>
(AuthoringToolResources.java:108)
... 3 more
The vecmath.jar file and other external lib are founded inside a folder called externalLib which in the same folder of the Myprog23.jar and .bat files
How to solve the problem and what is need to be set?
You need to add all jars used in program to classpath. So, in your case all jars present in externalLib directory should be added in classpath.
For adding jars in classpath you may refer Setting multiple jars in java classpath
I am assuming that you have correctly set your CLASSPATH variable. Also assuming you have correctly installed JyThon. You should really make sure to TEST JyThon hello world OUTSIDE of your application environment as well. You need to take this step by step, Alice is a complex system, and so it is difficult to debug your issue without making sure basic structure of libraries is in place.
With these assumptions, you can proceed with JyThon documentation FAQ:
Jython cannot find your Java class, even though it exists in the class path.
Jython cannot find your Java class, even though it exists in the class
path. This shows up as "ImportError: cannot import name xxx" or
"AttributeError: java package xxx' has no attribute 'yyy'"
This happens when Jython is installed as a Java extension (i.e. when
jython.jar is installed in java\jre\lib\ext) and your classes are
installed in the classpath.
The reason is Java extensions can only see other extensions, not other
classes defined in the CLASSPATH or passed in to java using the
--classpath option.
There are two ways to fix this:
Move your classes to the java\jre\lib\ext directory.
Remove jython.jar from the java\jre\lib\ext directory and put
jython.jar in the CLASSPATH or use the java --classpath option.
I generated the script using Gradle. After i am running script in gradle. it throwing error
org.gradle.tooling.BuildException: Could not execute build using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.10-bin.zip'.
at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:53)
at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:57)
at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
Anyone can u give me any solutions with clear steps.
My scenario is the stop and start message flows using batch file, where I have mqsi commands. When I execute the batch file manually, I am able to stop and start the flow. When I try to execute the batch file using the trigger enabled on one particular queue, I get the following error,
C:\Program Files\IBM\MQSI\7.0\bin>mqsistopmsgflow DISSERTATION_MS -e WITH_WATCHDOG -m WITH_WATCHDOG.MainFlow_Webservice_With_WatchDog Exception in thread "main" java.lang.NoClassDefFoundError: com.ibm.broker.config.util.MessageFlowControl
Caused by: java.lang.ClassNotFoundException: com.ibm.broker.config.util.MessageFlowControl
at java.net.URLClassLoader.findClass(URLClassLoader.java:434)
at java.lang.ClassLoader.loadClass(ClassLoader.java:653)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:358)
at java.lang.ClassLoader.loadClass(ClassLoader.java:619)
Could not find the main class: com.ibm.broker.config.util.MessageFlowControl. Program will exit.
I am not sure, where I am doing mistake. Request your help on this. Thanks.
Regards,
Jeevan
My intent is to give a batch file that executes a jar of a java application/tool to functional analysts team who do not know java. When I execute the batch file, I get the below error.
Any help is highly appreciated.
How to debug to find out if the issues is in main() which takes care of loading log4j and config files?
Exception in thread "main" java.lang.NoClassDefFoundError: x.y.XYZClass Caused by: java.lang.ClassNotFoundException: x.y.XYZClass at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: x.y.XYZClass
. Program will exit.
This what I did so far:
I packaged an application using Maven with the following directory structure:
bin/run.bat
lib/application.jar and other jars that it depends on
config.properties
log4j.xml
jar manifest file content:
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By:
Build-Jdk: 1.6.0_20
Main-Class: x.y.XYZClass
Class-Path: vn.jar pn.jar
run.bat content:
java -cp .;../lib/application.jar x.y.XYZClass -Dconfig.properties.name=../config.properties -Dlog4j.configuration=../log4j.xml
I execute run.bat from command line from bin folder.
XYZClass main() does the following:
loads log4j.xml and config.properties and does other stuff.
Verify that the XYZClass exists inside application.jar, in the correct directory. From the bin directory, run the command:
jar tvf ../lib/application.jar.
The output should resemble:
META-INF/
META-INF/MANIFEST.MF
x/
x/y/
x/y/XYZClass.class
Also, since you've created an executable jar (by specifying Main-Class in your manifest), you should be able to run it with: java -jar ..\lib\application.jar