I installed postgreSQL binaries in windows 7 32bit operating system; I can start the server from cmd but I cant run it as a windows service.
This is the error that I'm getting when I try to start the service manually:
"The postgreSQL service on local computer started and then stopped. some services stop automatically if they are not in use by other servces or programs"
All I need to do is; after booting to windows when I double clicked my java application I need to run my app smoothly without any database errors. I cannot do this because postgreSQL is not running as a windows service.
I found this in windows event viewer:
The description for Event ID 0 from source PostgreSQL cannot be found.
Either the component that raises this event is not installed on your local computer or the installation is corrupted.
You can install or repair the component on the local computer.
If the event originated on another computer, the display information had to be saved with the event.
The following information was included with the event:
postgres cannot access the server configuration file
"C:/Windows/system32/pgsql/data/postgresql.conf": No such file or directory
I googled about it but I was not able to find an answer.
Problem was solved
path to the data directory was wrong in windows service file.
So I delete the service file from this method:
1)Run Regedit or Regedt32.
2)Go to the registry entry "HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services"
3)Look for the postgreSQL service that you want delete and delete it.
4)reboot the computer.
After that open the cmd (Run as administrator) Go to the postgreSQL bin directory and run this command to create a new windows service:
pg_ctl.exe register -N "PostgreSQL" -U "NT AUTHORITY\NetworkService" -D "C:/Program Files/postgresql/pgsql/bin/pgsql/data" -w
This worked for me. Hope this will help.
This is a note for a normal user. If using an official installer it should has a build-in service,
Win+R and type services.msc
Search Postgres service based on the version installed,
e.g., "postgresql-x64-13 - PostgreSQL Server 13"
Click stop, start, or restart the service option
postgres cannot access the server configuration file
"C:/Windows/system32/pgsql/data/postgresql.conf": No such file or
directory
This looks like your working directory is C:\Windows\system32 and you are running postgres there and it looks for data/postgresql.conf.
Try changing the working directory or specifying -D C:\path\to\my\data.
Related
How to deploy the jar/war file in unix box and it should not stop after closing putty.
Steps tried:
Created jar/war file from Springboot project
Login to Unix box with root user
Created a Project folder in /opt path
Copied the jar/war file in Project folder
Executed below command to run the application in putty:
Command: java -jar myapplication.jar
Application is running fine but issue comes when i close my putty. Application shutdowns.
Any suggestions...
you need to create your custom service in your machine
EX: In Linux we use sudo systemctl start MySQL like that you have to create,
Please refer to this documentation which will help you to create your own.
EX: sudo systemctl start my_java_spring_service
I hope it helps!
I've been looking at different articles, examples for hours and have successfully completely confused myself. I am trying to use YAJSW as a service wrapper and install my Executable JAR file as a windows service. I used to use Tanukisoft's community edition wrapper and it worked wonderfully, but the 64-bit Windows version isn't available in CE.
I suppose I have a few questions.
In the old software, I didn't need to Implement WrapperListener. Is this necessary for YAJSW?
If so, are there any good examples? I've seen a few, but my application doesn't return anything from the main class. It's main class is a constant running URL connection reading input from a REST API and spawning a thread to process the information received. It does have a shutdown hook for a clean exit.
Is there an easy way to translate Tanukis' configuration (below) into YAJSW's keeping the same functionality?
set.JAVA_HOME=C:/Program Files/Java/jre1.8.0_181
set.APP_HOME=G:/ProgFolder
wrapper.lang.folder=%APP_HOME%/lang
wrapper.java.command=java
wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp
# Java Classpath (include wrapper.jar) Add class path elements as
# needed starting from 1
#wrapper.java.classpath.1=../lib/wrappertest.jar
wrapper.java.classpath.1=%APP_HOME%/lib/wrapper.jar
wrapper.java.classpath.2=%APP_HOME%/RESTReader.jar
wrapper.java.classpath.3=%APP_HOME%/lib/javax.mail.jar
wrapper.java.classpath.4=%APP_HOME%
# Java Library Path (location of Wrapper.DLL or libwrapper.so)
wrapper.java.library.path.1=%APP_HOME%/lib
# Java Bits. On applicable platforms, tells the JVM to run in 32 or 64-bit mode.
wrapper.java.additional.auto_bits=TRUE
# Java Additional Parameters
wrapper.java.additional.1=-Dlog4j.configurationFile=file:/%APP_HOME%/conf/log4j2.xml
wrapper.java.additional.2=-Dorg.tanukisoftware.wrapper.WrapperSimpleApp.waitForStartMain=FALSE
# Application parameters. Add parameters as needed starting from 1
#wrapper.app.parameter.1=
wrapper.app.parameter.1=com.my.org.RESTReader.EventReg
wrapper.jvm_exit.timeout=120
wrapper.shutdown.timeout=120
# Name of the service
wrapper.name=RESTReader
# Display name of the service
wrapper.displayname=REST Alarm Manager
# Description of the service
wrapper.description=REST Alarm Manager
# Mode in which the service is installed. AUTO_START, DELAY_START or DEMAND_START
wrapper.ntservice.starttype=DELAY_START
# Allow the service to interact with the desktop.
wrapper.ntservice.interactive=false
First Time Install (i.e. no existing service installed on host)
build executable jar file for your app
copy jar file to target windows machine / target directory
copy yajsw.zip to target machine / target directory
On target windows machine / target directory:
Unzip contents of yajsw.zip. Once this is completed, the yajsw.zip file can be deleted.
Open Windows command prompt in target machine / target directory and run: java -jar yourExecutableJar.jar
Get Process ID for the java process that you just started using Windows Task Manager.
Open new command window at target-dir\yajsw\yajsw-stable-majorversion.minorversion\bat.
Run as admin
genConfig [processId]
where processID is the one you determined before
Stop java process started previously
Open wrapper.conf in target-dir\yajsw\yajsw-stable-majorversion.minorversion\conf
Edit the fields in wrapper.conf: wrapper.ntservice.name=YourServiceName;
wrapper.ntservice.displayname=YourServiceDisplayName;wrapper.ntservice.description=YourServiceDescription
Save your changes and close wrapper.conf
Run as admin
installService in target-dir\yajsw\yajsw-stable-majorversion.minorversion\bat
Run as admin
startService in target-dir\yajsw\yajsw-stable-majorversion.minorversion\bat
Update Instructions
Stop the service using Windows Task Manager or Services Manager
In installed directory, delete the existing jar file for the project
copy new jar file to installed directory
Restart the service.
How do I run a Java .jar file as a Windows service on a Windows 2008 server? I have a jar file called SomeJavaFile.jar located under the C:\SomeDirectory directory on a Windows Server 2008 box. I usually just run this jar manually in the command line with: java –cp SomeJavaFile.jar com.ctg.SomeJavaFile and I let it run 24/7.
The problem with our Windows Server is if it restarts I need to run it as a service so it will automatically start as a service upon startup, because our processing for Vistakon runs 24/7. I have Googled around and tried to use a service wrapper and the sc.exe command to create the service.
I put the wrapper service.exe in the C:\SomeDirectory\. I use the following command to create it: sc.exe SomeJavaService binPath= “C:\SomeDirectory\service.exe \”java –jar C:\SomeDirectory\SomeJavaFile.jar\”” type= own start= auto error= ignore. This creates the SomeJavaService service correctly but when I try to start it I get an error that says the service on Local Computer started then stopped.
Some services stop automatically if they are not in use by other services or programs. Do I need to alter my sc.exe command to have the exact previous working command line maybe, by adding in the com.ctg.SomeJavaFile? So should I change This jar should just run in the background and constantly poll/ping the C:/poll directory then if there is data present it processes the data and sends an export file to another directory.
I have used this same .jar file for years successfully and it hasn't changed, but I cannot get it to run as a Windows service. This is the site I use to get the service wrapper http://code.google.com/p/simple-service-wrapper/. Any help would be greatly appreciated!
"winsw" is the standalone version of the Windows Service installer shipping with the Glassfish Java EE reference implementation.
Works well, but is not a fully polished product - I have used it for exactly this purpose for a couple of years. Requires .NET in some recent version on the Windows machine.
https://github.com/kohsuke/winsw
I think that the best bet would be wrap your java app with Procrun of Apache Commons Daemon .
Procrun is a set of applications that allow Windows users to wrap
(mostly) Java applications (e.g. Tomcat) as a Windows service.
The service can be set to automatically start when the machine boots
and will continue to run with no user logged onto the machine.
As per my analysis,
The Idle Solution will be writing a VC++ (.net) Windows Service creation program to launch the .bat (that triggers the jar file)/.exe as a System service with all the required call back methods to SCM.
Note : 1. Wrapping the process with sc.exe / srvany.exe would not work as it does not have any call back process to the SCM (Service Control Manager). 2. And java service Wrapper is a third party API (many are LGPL licensed).
If you start your Java code from commandline by using java -j some.jar does it run until you terminate the program, or does it stop by itself?
There needs to be a NON-Deamon Thread, that is running all the time. A JVM will terminate, if there is no thread running, that is not flagged as daemon.
If you have a little budget, buy an installer tool. I use instll4j. With that tool, you can create service launcher and install them during instllation.
The following solution is working fine for me having OpenFire Connection Manager (which is a jar file) running as service on Windows Server.
Download and install the Non-Sucking Service Manager
I didn't use the batch made by OpenFire team, because it didn't work for me (dependencies not found error...) So, make a batch file with the following code :
#ECHO OFF
cd /D "E:\connection_manager\lib"
java -jar startup.jar
and save it as cm_startup.bat in the bin folder of connection manager.
After that you can create the service with NSSM.
So, open a cmd.exe and run the following command :
nssm install ConnManager "E:\connection_manager\lib\cm_startup.bat"
.
Doc & examples
More documentation and examples for the Non-Sucking Service Manager here : https://nssm.cc/usage Actually NSSM as a lot of options available.
Here is a more complexe example :
nssm install solr "%JavaExe%" -Dsolr.solr.home="\"%CD%\solr"\"
-Djetty.home="\"%CD%"\" -Djetty.logs="\"%CD%\logs"\" -cp
"\"%CD%\lib\*.jar"\";"\"%CD%\start.jar"\" -jar "\"%CD%\start.jar"\"
I am trying to run psservice.exe and plink.exe from servlet using runtime exec. It will be used for starting or stopping services on remote computer running windows and unix aix.
I have set system variables so that i am able to run them from command prompt. These commands are running perfectly from command prompt and java program
I am using below code in Servlets for remote windows machine
Runtime.getRuntime().exec(serverPropLoader.getServerProperties("psservice \\\\172.xx.xx.xx -u username -p password stop MySQL"));
I am using below code in Servlets for remote unix aix 5.3 machine
Runtime.getRuntime().exec(serverPropLoader.getServerProperties("PLINK.exe -ssh -pw "password" username#172.xx.xx.xx /home/mysql/stopservice.sh"));
Below are my observations :
If i run above statement from Eclipse (ver 3.4.2) using Tomcat6 it runs perfectly fine, but if export my web app as WAR and deploy it in Tomcat6 mannually it dosen't run. ( i have tried deploying it in mine and other system)
I have tried puting these command in Batch file and calling it from servlet but no success. From Batch file "net" and "sc" command are working but i am not able to run pservice and plink command. also "sc" command is working for local processes only.
After execution of servlet i am able to see psservice.exe and plink.exe in windows task manager but required services on local and remote system is not starting / stopping
The problem here is, you need to add admin previladges for the tomcat user.
Because this Apache Tomcat Monitor program requires permission to interact with system services, it cannot be executed as a standard user.
Do following tasks, you will be fine
Locate the tomcat7w.exe program in Windows Explorer (the default directory is C:\Program Files\Apache Software Foundation\Tomcat 7.0\bin).
Right-click the name of this file and select the Properties context menu item.
The tomcat7w Properties dialog displays.
Select the Compatibility tab and click either the "Show settings for all users" button or the "Change settings for all users" button at the bottom of the dialog.
A new tomcat7w.exe Properties dialog displays with a single tab entitled Compatibility for all users.
At the bottom of this dialog, in the Privilege Level group box, select the Run this program as an administrator.
The Apache Tomcat Monitor executable will now execute with the required privileges when run from a standard user account.
for more information pls refer
https://supportcontent.ca.com/cadocs/0/CA%20Automation%20Point%20Base%2011%204-ENU/Bookshelf_Files/HTML/AP--RelNotes/index.htm?toc.htm?2009998.html
I am running GlassFish 3.0.1 as a windows service under Windows Server 2003 with Java 1.6 u 20, and am generally happy.
I would like to be able to use VisualVM on this JVM and used Unable to use JConsole with Tomcat running as windows service as a starting point, but starting with
PsTools\PsExec.exe -i -s "C:\Program Files\Java\jdk1.6.0_20\bin\jvisualvm.exe"
results in a jvisualvm.exe and a nbexec.exe process showing up in Task Manager with SYSTEM as the user but I do not see any GUI from the program as I do when I run it manually as myself. I am logged in with Remote Desktop from Windows 7 in case that makes any difference.
Other interesting points:
at 10:55 /interactive cmd.exe
reports a new job has been added, but does not open a CMD window at 10.55.
The description of how to register VisualVM as a service reports the service to start but no GUI shows up. http://blogs.oracle.com/nbprofiler/entry/monitoring_java_processes_running_as
Have anybody gotten this to run under Windows Server 2003?
The way I'm able to get this to work is to make sure that you remote desktop to the server's "console" session.
Simply put, when you open mstsc.exe append the text " /admin" to the computer name you are trying to connect to. For instance, if you were trying to connect to a server called "FOO", then in the Computer name text box in mstsc.exe, you would enter "FOO /admin".
After connecting and logging in to the server, you can execute your PsExec command. You should then see Visual VM with the GlassFish process you are trying to connect to.
For more info about connecting to the console session with remote desktop in Windows, have a look at the "How to Connect to the Console" section http://support.microsoft.com/kb/278845.
Also, for those looking for PsExec.exe, you can get it from the PsTools package from Microsoft at technet.microsoft.com/en-us/sysinternals/bb897553.aspx.