We are customizing the site generation in maven and one of the things that it does is call Visio to have it translate some charts into png. We use a vbs script which calls Visio and that is called from a java class by calling Process proc = Runtime.getRuntime().exec(command); where command is cmd /c "cd "C:\Path\To\Module\site\target\staging"&&exportVisioSvg.vbs "C:\Path\To\inFile.vsd" "C:\Path\To\outFile.png""
Now this code executes on my own machine just fine. Visio is called up and generates a file. When I run it on the server hosting our Jenkins instance it works as well. When I run the command by itself it works just fine. Finally when I goto the Jenkins\workspace and execute the maven build there it works just fine.
However when I run the build in jenkins with exactly the same command (I copied and pasted it) it does not generate the Visio charts. Everything else runs fine and there is no stack trace outside of our own thrown error that goes off when the image is not where it is supposed to be. The exit code from the process is 0 as well and there is no output to either stdout or stderr (the windows equivalent) generated by the process and it has to complete or the exit code would be -1. Timeout isn't a problem as it has 50000 ms to run but always returns within a sec or less (you can see the error get thrown right after the call to the script).
I switched Jenkins to run under the admin account where everything is installed (moving it from SYSTEM) so it should have access to the PATH.
I have no idea what to do at this point.
This sounds like one of the Jenkins FAQs. Check https://wiki.jenkins-ci.org/display/JENKINS/My+software+builds+on+my+computer+but+not+on+Jenkins especially under the section "Desktop access (Windows)"
You're probably hitting http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6468220 and since it can't be fixed in the JDK, you need to finetune it in your code.
The problem is when Visio is started it is started as a child of the Jenkins service which is running without desktop interaction. Microsoft restricts its office product actions where a prompt might be generated which cannot be seen by a user. Even if you add allow interaction with desktop it will not work and in my case returned the following error value 2032466051. The solution was to only run it as a user and manually start the Jenkins instance every time we needed to restart the server.
Related
I'm currently programming a Python script that opens a file in an different directory that the user enters in an input box. Everything runs fine but the jar file I used for testing doesn't run or show up. I'm using the Shimeji-ee.jar in testing, and at one point its tray icon showed up but disappeared immediately.
I tried running it in command prompt(since calling the jar file using the script is similar to running a file in CMD) and discovered that it only runs as long as the CMD window is open. A few searches later, I've found a way to run files in CMD that keeps it running even after closing the CMD. I wrote it in my script, no errors, but the Shimeji nor its tray icon doesn't ever appear anymore.
I've added a line at the end of my script that is also told to be an efficient way of keeping the script running, but it doesn't work either(could be another mistake here):
while True:
keyboard.wait('q')
if keyboard.is_pressed:
sys.exit()
Here's the line of code in my script that does the calling:
subprocess.run(['D:', 'cd', PurePath(fileDirectory), 'START', '""', fileToExecute], cwd=os.getcwd(), shell=True)
The code I learnt that makes a file run in the background(similar to adding & in a Linux terminal):
START "" program
I've had thoughts that the jar file I'm using could be the problem, but I haven't found any answers for hours. Is there anything wrong with the code or am I missing something?
Update:
Code finally worked after the first answer but I received an error that seemed it read the file as a double forward slash like this:
# The network path was not found //
or
# The system could not find the file //
The solution I found was just removing the '""' part of the code, which makes the code look like this:
subprocess.run(['START', fileToExecute], cwd=PurePath(fileDirectory), shell=True)
The problem is that your code:
subprocess.run(['D:', 'cd', PurePath(fileDirectory), 'START', '""', fileToExecute], cwd=os.getcwd(), shell=True)
executes the command D: with the arguments cd somedirectory START "" fileToExecute, which changes the current drive of the shell to the D drive and then terminates.
You probably want to execute
subprocess.run(['START', '""', fileToExecute], cwd=PurePath(fileDirectory), shell=True)
Eclipse froze on me earlier today, so I typed "top" into the command prompt and killed it. Now when I try to run a java application, I get this error:
eclipse\plugins\org.eclipse.jdt.debug_3.7.0.v20110509
That's all that shows up under details.
None of my previously working programs run, and I have no clue what this is. I have Eclipse 1.5.0 running 1.6 and 1.7 Java, depending on what program. Thanks for any help.
It is possible that you killed part of the process but not all of it. It is possible that a java process is running with a reference to this job. I would try restarting your computer to see if it will stop whatever process is referencing that jar.
Aside from a restart, then another option would be to use (in linux) pstree, filtered for your user to see if any other jobs are referencing that jar and/or java.
EDIT:
Another path is to look at log files. On linux they are in /var/log. Here's a link in that direction: http://docs.oracle.com/javase/7/docs/webnotes/tsg/TSG-Desktop/html/felog.html
I am trying to run a simple JAVA program once per day on a Windows 7 machine.
My code runs fine inside NetBeans. If I do a clean and build it suggests this:
C:\Program Files\Java\jdk1.7.0/bin/java -jar "C:\Users\User1\Documents\NetBeansProjects\Facebook\dist\Facebook.jar"
This does not work from the DOS prompt of course because of the space between program and files so I do this:
C:\Program Files\Java\jdk1.7.0/bin/java -jar "C:\Users\User1\Documents\NetBeansProjects\Facebook\dist\Facebook.jar" -jar "C:\Users\User1\Documents\NetBeansProjects\Facebook\dist\Facebook.jar"
This works from the DOS prompt.
I now create a task in Windows Scheduler to run:
C:\Program Files\Java\jdk1.7.0/bin/java
with arguments:
-jar "C:\Users\User1\Documents\NetBeansProjects\Facebook\dist\Facebook.jar"
When I then run it, all I see is a DOS box flashing up for a second. I expect the code to take about 30 secs to run. The code should persist data to a database and no updates happen.
The code also uses java.util.logging so I should see log entries and I don't.
I strongly suspect that I am not running the JAVA command properly or that there's a bad classpath issue that it present when running via Scheduler that isn't there when running from the DOS prompt.
Help would be appreciated. If you've seen this before and can sort it that would be great. If you can tell me how to get a meaningful error trace from Scheduler than that would also be really helpful.
Thanks!
I Think that you could create a simple batch script that will launch your program in this way :
#echo off
REM Eventually change directory to the program directory
cd C:\Users\User1\Documents\NetBeansProjects\Facebook\dist\
REM run the program
"C:\Program Files\Java\jdk1.7.0\bin\java.exe" -jar "C:\Users\User1\Documents\NetBeansProjects\Facebook\dist\Facebook.jar"
Copy it into the notepad and save as java_script.cmd and then schedule this script instead of the program directly.
I solved it after changing all fonts' references to "SansSerif"
I was using Jasper Reports inside Java to create a PDF file. It was working fine when I double click the batch file or Scheduler with Windows Server 2003 but not working with the Scheduler of 2008.
I tried many different things nothing worked so I though Could it be that Windows Server 2008 is blocking the access?.
Now is working perfect. So, if you are having problems check the references to anything you are using.
The scheduler will run under a different user unless you specify what user to run as. If it isn't running as your user then it won't be able to write to your directories.
The real problem to the original question is a java installation issue on Microsoft systems. Java jre installs into Program Files\java. The executable (java.exe) is only installed in that java\bin directory. Running from the command line, the os looks in the proper location for the java.exe. Running from other MS tools (such as VBA Excel or in this case TaskScheduler), it does not!
You can see that TaskScheduler is looking in the wrong place by viewing the tasks history in the TaskScheduler tool. Double click on some of the history events and one will list the action and return code. The action will show that the TaskScheduler is trying to run
"C:\Windows\system32\java.EXE"
So, copy java.exe from the java\bin directory into the place where the scheduler is looking, and now it will work.
Or update your task and provide the full path to java.exe.
You can also update the environment system path to look for java in the java\bin directory, but that has to apply to all users and sometimes this is faulty as well.
I've run into a weird problem today. I'll try to describe the steps I'm making as detailed as possible.
I've created a Java application in NetBeans. The application runs without exceptions when running within NetBeans by clicking Run Main Project. The total duration of a complete run is about 1min.
When building the project I see the following option in the output window of NetBeans:
To run this application from the command line without Ant, try:
java -jar "C:\java_libraries\PrxJobCommunicator\dist\PrxJobCommunicator.jar"
So i open the command prompt (Windows 7), enter this command + supply a mandatory integer argument and press enter
The application starts running, runs for a couple of seconds and exits without any message whatsoever.
the application writes to a text file at different points in the code, so I'm able to trace the output up to the point when it stops running. I've deliberately put some extra calls to the file writer method in order to find where the programme continues/exits but to no avail. Seemingly the programme simply stops running on a certain line and that's it.
I really don't know what the problem can be: the application runs fine in NetBeans and fails without any message whatsoever when starting from the command line.
Shall I check anything special in NetBeans? Do you know of any special technique to debug a jar file if it's started from the command line?
Any clues are welcome.
Thanks, Andras
I suspect that there is a difference in the classpath when the app is run from NetBeans, and when it is run from the command line.
There must be some kind of exception that is being thrown, have you got an outermost
catch (Exception ) block in the main method?
You could try to debug the application using "remote debugging", although you won't be debugging over a network, you can still use this method to catch the breakpoint started at the command line in NetBeans.
Here's an article that explains how to do remote debugging with NetBeans http://manikandanmv.wordpress.com/2009/09/24/debugging-java-applications-with-netbeans/
Netbeans by default uses your project folder as the working folder. It means when you run your program from console you have to CD C:\java_libraries\PrxJobCommunicator
then run java -jar "C:\java_libraries\PrxJobCommunicator\dist\PrxJobCommunicator.jar"
If above fails check the java version used in your command prompt. java -version
It has to be same as the one used by netbeans.
Finally the library path. Are all the dependent jars placed in the dist folder?
I'm setting up my first job in Hudson, and I'm running into some problems. The job monitors two repositories, one containing our DB setup files, the other a bit of code that validates and tests the DB setup files.
Part of the code that runs will throw the validated setup files at PostgreSQL, using the psql command line tool, using Runtime.exec(). This code works perfectly on my machine, but when Hudson executes it (different machine) I get the following error:
java.io.IOException: Cannot run program "psql": CreateProcess error=2, The system cannot find the file specified
psql.exe is on the path, and I can execute it by typing the whole thing at the command line, from the same place Hudson is executing the code. The file that's meant to be passed into psql exists.
Any ideas?
I find that you need to have the programme in the path when you launch hudson or the slave. Despite having the ability to set the path in hudson it doesn't seem to work. You could also put the full path in the command, which is really a good idea from a security perspective anyway.