Tomcat won't start (Windows 10) - windows

I´m trying to launch an application (pentaho business intelligence server) but the .bat file won´t run. It doesn´t throw any error or anything, the command prompt pops up and then disappears right after. Then I figured out that it´s tomcat that isn´t running, but no error is being logged in the tomcat logs folder.
This is what shows in the command prompt when I start the bat file (I had to add a pause to see where it goes before exiting)
I also run the catalina.bat file and I also could see that the last thing it tried to run was this CLASSPATH, and seems like it was trying to open this tomcat-juli.jar and bootstrap.jar, but is not working somehow.
I´m not really familiar with any of this, so I´m not sure if this is normal, could you point me to the right direction on how to solve this?
EDIT 1. I was suggested to add the code of the bat file in question, here it is:
#echo off
setlocal
cd /D %~dp0
cscript promptuser.js //nologo //e:jscript
rem errorlevel 0 means user chose "no"
if %errorlevel%==0 goto quit
echo WScript.Quit(1); > promptuser.js
call set-pentaho-env.bat "%~dp0jre"
cd tomcat\bin
set CATALINA_HOME=%~dp0tomcat
SET BITS=64
SET DI_HOME="%~dp0pentaho-solutions\system\kettle"
set CATALINA_OPTS=-Xms2048m -Xmx6144m -XX:MaxPermSize=256m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Dfile.encoding=utf8 -DDI_HOME=%DI_HOME%
rem Make sure we set the appropriate variable so Tomcat can start (e.g. JAVA_HOME iff. _PENTAHO_JAVA_HOME points to a JDK)
if not exist "%_PENTAHO_JAVA_HOME%\bin\jdb.exe" goto noJdk
if not exist "%_PENTAHO_JAVA_HOME%\bin\javac.exe" goto noJdk
set JAVA_HOME=%_PENTAHO_JAVA_HOME%
set JRE_HOME=
goto start
:noJdk
rem If no JDK found at %_PENTAHO_JAVA_HOME% unset JAVA_HOME and set JRE_HOME so Tomcat doesn't misinterpret JAVA_HOME == JDK_HOME
set JAVA_HOME=
set JRE_HOME=%_PENTAHO_JAVA_HOME%
:start
call startup
:quit
endlocal
pause
EDIT 2. After some research I'm sure the problem is that tomcat doesn't start, changing the title of the question.
Things that I've already tried:
Changing the port from 8080 to 8081.
Setting _PENTAHO_JAVA_HOME environment.
Opening tomcat (startup.bat) and catalina.bat from the command prompt, it just tells me it runs it but exits after CLASSPATH (exactly the same as the screenshot provided).
Checking the logs file in tomcat, it's empty

I managed to make it work, I uninstalled java 11 and installed java 8 (this version is compatible with pentaho), then I changed the environment _PENTAHO_JAVA_HOME to this java 8, that made it work. But now I can only make it work from the tomcat startup.bat and not from the file start-pentaho.bat, so I guess there is still a way to make it work as it was meant to.

Related

Getting a Windows batch file to execute an application in background and then execute the next statement

I am having issue trying to get my Windows batch file to launch the Jetty web server in the background and then launch IE. The current behavior is that after it started my Jetty web server, it doesn't return to launch IE. It simply stuck there until I terminate the web server and then batch script will then proceed and launch IE.
Here's my batch script
SET JAVA_HOME=".\openjdk-1.8.0.141"
SET JETTY_HOME=".\jetty-distribution-9.4.6.v20170531"
start /B cd /d "%~dp0" & %JAVA_HOME%\bin\javaw -DSTOP.PORT=8081 -DSTOP.KEY=stop_jetty -Djetty.base=%JETTY_HOME% -jar %JETTY_HOME%\start.jar
"C:\Program Files\Internet Explorer\iexplore.exe" http://localhost:8080/foo-tools
Can you spot anything obvious here? I already used the 'start /B' to attempt to launch it in the background. I have to change directory back to the current working directory, otherwise the variable that I set will not work.
Thanks in advance!
Why not simplify things and stipulate the script path with the START's /D <Path> parameter?
SET "JAVA_HOME=openjdk-1.8.0.141"
SET "JETTY_HOME=jetty-distribution-9.4.6.v20170531"
START "" /D "%~dp0" "%JAVA_HOME%\bin\javaw" -DSTOP.PORT=8081 -DSTOP.KEY=stop_jetty -Djetty.base="%JETTY_HOME%" -jar "%JETTY_HOME%\start.jar"
START "" "%PROGRAMFILES%\Internet Explorer\iexplore.exe" http://localhost:8080/foo-tools
I missed off START's /B parameter because it was my understanding that javaw.exe doesn't open a CMD window anyhow. If my understanding is incorrect then please add it back just before "%JAVA_HOME%.
The START command for IE is only really necessary if you need the script again or don't want the cmd window to remain open.

Stuck in cmd script loop

I'm using a script that, upon logging in, loads Remote Desktop Protocol (RDP) and pushes the user to a Virtual Desktop Environment (VDI), along with their credentials. The script does not allow the next command 'Shutdown /l' to run until it is finished running.
The problem I'm having is that once in the VDI, RDP tries to load up again. How do I prevent this from happening? Thank you in advanced.
start /wait \\ph-vda\C$\VDI_Users_RDP\%username%.rdp /multimon /noConsentPrompt
Shutdown /l
I think what you're describing is that the same script is running when the user logs in, even when they log into the VDI. You don't want the script to run in the VDI. If that's right, here's one idea.
#echo off
if exist "%userprofile%\in_vdi" goto :eof
type nul >"%userprofile%\in_vdi"
start /wait \\ph-vda\C$\VDI_Users_RDP\%username%.rdp /multimon /noConsentPrompt
del "%userprofile%\in_vdi"
Shutdown /l

How to close Windows console automatically (send CTRL+C to console programatically)?

I have two windows batch scripts, script1.bat and script2.bat. script2.bat is launched from script1.bat.
script1.bat:
...
start call script2.bat
...
script2.bat has to be closed when user closes script1.bat's console (in another words, script2.bat and its console should be closed automatically when script1.bat is closed). But script2.bat should not be killed, It should be terminated because script2.bat has to release database connection. I mean unix signal teminology by using kill and terminate words. So scrip2.bat should not be killed immediately, it should be terminated in way that allows the process to perform nice termination releasing resources and saving state if appropriate.
I made it for unix system and I resolved it as following.
script1.sh:
...
sh script2.sh > /dev/null 2>&1 &
script2_pid="$!"
trap 'kill -15 $script2_pid' EXIT HUP TERM INT KILL
...
How to make it on Windows?
====EDIT====
I think that my question is not entirely clear for everyone so I would like to clarify it.
I have java application which connects to JBoss application server. It is tested now and I need to launch both in very convenient way. I prepared batch script (script1.bat)which starts both, client application and JBoss application. This script also do another things like setting environment variables. So script2.bat is a Jboss standalone.bat file in fact. I wouldn't like to edit this file.
script1.bat is my script, it sets environment variables, start JBoss and start my java application.
My script (script1.bat):
...
set environment variable
...
REM start jboss
start standalone.bat
REM start my java application
java ...
When user closes Java application, JBoss should also be closed. I need it only for tester's convenient and I know that in production environmnet it should work in another way.
I don't know how to terminate JBoss automatically after user closes my java client application. JBoss connects to H2 database and creates lock on it so if JBoss will be killed immediately then database lock is still there. If JBoss process receives CTRL+C it terminates properly (removes database lock). I want to make it automatically, After user closes java client application, JBoss has to be closed as it receives CTRL+C.
I have no idea how to do it on Windows. But I did it on linux and I added my code to this question.
Sorry, but your script makes no sense. start call script2.bat?? The combination of start and call is nonsense. You use either one or the other but not both.
Further I have to disappiont you. There is no way to close a console but keep the code running. You can't even start a hidden console in Windows. Closing the console will instantly stop the execution of the code.
EDIT:
Now I understand what you are asking. Start your first script using
start "somename" script1.bat
This will start script1 in a console with "somename" as window title.
In the second script you can use this:
:WORKING
REM Do some stuff here
REM and here
REM and here
FOR /f "tokens=*" %%A IN ('tasklist^ /v^| findstr /i /c:"somename"') DO GOTO WORKING
REM shutdown part
REM close db connections
REM exit script2
This part will check if the a console with "somename" in the title is running and if yes reenter the loop. At the end of the loop it alway checks whether script1 is still active. As soon as it's not found the code goes on to the shutdown part.
If you only want to wait for script1 to terminate you can use PING -n 5 127.0.0.1 > NUL as a 5 (or longer, just replace the 5 ^^) second timeout to avoid busy-waiting:
:WORKING
PING -n 5 127.0.0.1 > NUL
FOR /f "tokens=*" %%A IN ('tasklist^ /v^| findstr /i /c:"somename"') DO GOTO WORKING
REM shutdown part
REM close db connections etc.
REM exit script2
If CLI is enabled in JBoss then JBoss can be shutdowned by CLI. Following batch shows how to shutdown JBoss
...
set environment variable
...
REM start jboss
start "UNIQUE_NAME" path_to_JBoss\bin\standalone.bat -c standalone.xml
REM start java application
java ...
REM shutdown JBoss by CLI
call path_to_JBoss\bin\jboss-cli.bat --connect ":shutdown"
REM it is just in case. If CLI did not shutdown JBoss, then following line kills JBoss without release of resource.
FOR /f "TOKENS=1,2,*" %%a IN ('tasklist^ /FI "WINDOWTITLE eq UNIQUE_NAME*" /nh') DO taskkill /pid %%b

batch ftp script with DATE command not working

I am uploading a running a simple batch script which downloads a file from one server and uploads it to another. The file name is based on the previous day ie. 20111124.zip (YYYYMMDD). The script works fine on all the boxes I have tried it on, however when it is run on a colleagues windows 7 box it fails. The DATE command returns a zero. I have already tried setting the UAC to off but that did not resolve the issue. Any help would be greatly appreciated.
SETLOCAL
SET dwMONTH=%DATE:~4,2%
SET /A dwDAY=%DATE:~7,2%-1
IF %dwDAY% LSS 10 (SET dwDay=0%dwDay%)
SET dwYEAR=%DATE:~10,4%
SET dwDate=%dwYEAR%-%dwMONTH%-%dwDAY%
SET mydate=%dwYEAR%%dwMONTH%%dwDAY%
echo %mydate%
Windows 7 doesnt include a day name,
e.g. on windows XP %date% contains "Di 25.10.2011" (im on a german computer system)
and Win7 only "25.10.2011",
so your offset (7) is pointing to the wrong spot

Can I set an environment variable for an application using a shortcut in Windows?

I have a feeling I should be able add a directory to the PATH environment variable on an application-lifetime basis, but I can't find out how to do this. Is it possible to add a parameter to a Windows shortcut that appends a directory to the current value of PATH for use by the application being linked?
As explained here: http://www.labs64.com/blog/2012/06/set-environment-variables-in-windows-shortcut/
you can do it without a bat file too.
Set Target to e.g.:
C:\Windows\System32\cmd.exe /c "SET path=%path%&& START /D ^"C:\Program Files (x86)\Notepad++^" notepad++.exe"
To avoid see the command prompt for a split second before it close again, you should set
Run: Minimized
on the Shortcut tab
(Tested on Windows 7, Windows 10)
Let the shortcut execute a batch file (.cmd), that
Sets the environment variable
execute the app
You use "START" to execute the app, this will start the app in another process, but it will copy the environment. You do not wait for the app to finish.
Now you can exit the batch file.
Should look like this:
#echo off
set path=%path%;C:\My Folder
start "Window Title" "Path to my exe"
Linking directly to a batch file spawns an annoying console that you probably want to avoid. Here's a work-around. The simpler solution is to use the "Start Minimized" option in your link, but on Windows 7 you'll see a momentary console light up your task bar.
start.bat:
#echo off
IF "%1" == "" GOTO Error
IF "%2" == "" GOTO Error
IF NOT EXIST %2 GOTO Error
SET PATH=%1;%PATH%
start %2
GOTO End
:Error
echo Problem!
pause
:End
shortcut target:
MyPath = "C:\MyApp"
Set shell = WScript.CreateObject("WScript.Shell")
cmd = "start.bat " & MyPath & " MyApp.exe"
shell.Run cmd, 0, false
Set env = Nothing
Set shell = Nothing
You can do this with PowerShell easily. PowerShell exposes environment variables using the $env: prefix. For example, I wanted to launch TeamSQL with custom JAVA_HOME and PATH environment variables, so I could connect to a PostgreSQL database. TeamSQL depends on JDK / OpenJDK for this purpose.
First, I downloaded pre-built OpenJDK and extracted the ZIP archive with 7-Zip.
Next, in PowerShell, I ran the following:
$env:JAVA_HOME='C:\Users\TrevorSullivan\Downloads\openjdk\jdk-11.0.2\'
$env:PATH += ';%JAVA_HOME%\bin'
# Launch TeamSQL
& C:\Users\TrevorSullivan\AppData\Local\Programs\TeamSQL\TeamSQL.exe
Store that PowerShell code in a .ps1 file, and you can run it with PowerShell. Because child processes inherit the environment variables from the PowerShell session, your program is good to go.

Resources