How do you run Jboss 4.2.0A as a service in Windows XP Pro - windows

I saw something once for wrappers used to do this but it asked for a licensing fee. Is there an open source way to do this?

"JBoss AS comes with Windows service executable as part of JBossNative
that can run JBoss Application Server as service.
The service executable jbosssvc.exe transforms the run.bat and
shutdown.bat batch scripts to services. This means that any change
made to those scripts will be used both in service and command
line mode."
http://www.jboss.org/community/wiki/JBossNativeWindows

A Problem I had was the remote Access to JBoss. In JBoss 4.2.3 you must start it with the Parameter run.bat -b 0.0.0.0 to have access from other hosts.
I think since JBoss 4.2 remote access is turned off by default.
My solution was to adjust the :RESTART Section in the file run.bat like this:
:RESTART
"%JAVA%" %JAVA_OPTS% ^
-Djava.endorsed.dirs="%JBOSS_ENDORSED_DIRS%" ^
-classpath "%JBOSS_CLASSPATH%" ^
org.jboss.Main -b "0.0.0.0" %*

Related

Install Liferay as Windows 2012R2 service

I am a newbie on Liferay and furthermore 100% Windows infrastructure knowledge based. I installed Liferay 6.2 on my Windows 2012R2 server together with Java jdk-8u5 version. All is running perfect as long as I am logged in as user on the Server via remotedesktop having open the tomcat startup.bat window.
What have I to do exactly to start Liferay and/or tomcat as service?
Thanks in advance for your efforts.
Configuring liferay or tomcat to run as a service on a windows server doesn't differ that much.So in order to do that you have to add some files to the LIFERAY_HOME\tomcat\bin directory.
To get those files you have to download a full version of 64-bitWindows tomcat from here :
http://tomcat.apache.org/download-70.cgi.
Extract the zip and go to the bin directory, copy service.bat , tomcat7.exe and tomcat7w.exe to this location : LIFERAY_HOME\tomcat\bin
Setting Up the service
Open the commad prompt (Make sure you have admin rights or run the command prompt as administrator),In Command Prompt go to LIFERAY_HOME\tomcat\bin and Execute the following command
service.bat install tomcat7
This will install the tomcat6 service in windows.
Now execute following commond to setup additional configuration for the service
tomcat7w.exe ES tomcat7.exe
2 . Extra configuration :
-XX:MaxPermSize=512m
-Dfile.encoding=UTF8
-Duser.timezone=GMT
-Djava.security.auth.login.config="%CATALINA_HOME%/conf/jaas.config"
-Dorg.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES=false
and make sure to provide enough memory for your service by setting the initial memory pool and the maximum one.
Either go with Rafik Beldi's answer (quite an effort, wow) or just go to tomcat's documentation in case you're still missing some information
I had to delete what was in Java Options completely or it wouldn't start: and then I entered:
-XX:MaxPermSize=512m
-Dfile.encoding=UTF8
-Duser.timezone=America/New_York
-Dorg.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES=false
-Djava.net.preferIPv4Stack=true
note that where I am: America/New_York allows for both EST and EDT

How to enable JMX on tomcat7 running as Windows service?

I have googled this extensively before posting it here. I've been trying to find out a way to enable JMX Access on a Tomcat instance installed as Windows service. Its quite straightforward when Tomcat is invoked via the startup.bat script, one just needs to set the CATALINA_OPTS environment variable to something like "-Dcom.sun.management.jmxremote.port=1234 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"
But how do i get the Tomcat Windows service to read these options? I tried this:
C:>tomcat\server\bin> service.bat install #install the Tomcat7 windows service
C:>tomcat\server\bin> tomcat7.exe //US//Tomcat7 ++JvmOptions "-Djava.io.tmpdir=$INSTDIR\server\temp;-XX:MaxPermSize
=256m;-Dcom.sun.management.jmxremote.port=8090;-Dcom.sun.management.jmxremote.au
thenticate=false;-Dcom.sun.management.jmxremote.ssl=false" --JvmMs 256 --JvmMx 1
024 #update the installed service using the //US switch; set tmpdir, JMX access and heap size
When i start the service from Services panel, the service fails to start and i get the following error on the logs\tomcat7-stderr-yyyy-mm-dd.log file:
yyyy-mm-dd hh:mm:ss Commons Daemon procrun stderr initialized
Error: Invalid com.sun.management.jmxremote.port number: 8090 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false
I don't have a Java background, am i trying to achieve something outlandish here? Please advise.
Answering my own question; turned out to be easier than i thought.
Following needs to be done, for enabling JMX access for Tomcat installed as a Windows service, that has a name "ApacheTomcatWindowsServer" for example:
Install Tomcat as Windows service, either using the command (first cd into \bin\ )
service.bat install
or your custom scripts.
Enable Apache Service Manager for the installed service using the following command:
tomcat7w.exe //MS//ApacheTomcatWindowsServer
This should start Apache Service Monitor program on your system tray. Click on its icon. select 'Configure', click on the 'Java' tab and append the following on the 'Java Options' text box, one option per line:
-Dcom.sun.management.jmxremote.port=8090
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
Save and exit and restart the service.
To connect to the JMX console, fire jconsole from your JDK installation, click 'New Connection', specify 'Remote Process' and enter hostname:8090.
you can also uninstall the service by
service.bat remove
then edit the service.bat and add the parameters in your StartPath and add the options
-Djavax.management.builder.initial=;-Dcom.sun.management.jmxremote.port=8090;-Dcom.sun.management.jmxremote.authenticate=false;-Dcom.sun.management.jmxremote.ssl=false
here is the sample StartPath in my file
--StartPath "C:\tomcat7\" --Startup auto --JvmOptions "-Dcatalina.home=%CATALINA_HOME%;-Dcatalina.base=%CATALINA_BASE%;-Djava.endorsed.dirs=%CATALINA_HOME%\endorsed;-Djava.io.tmpdir=%CATALINA_BASE%\temp;-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager;-Djava.util.logging.config.file=%CATALINA_BASE%\conf\logging.properties;-Djava.rmi.server.hostname=;-Djavax.management.builder.initial=;-Dcom.sun.management.jmxremote.port=8090;-Dcom.sun.management.jmxremote.authenticate=false;-Dcom.sun.management.jmxremote.ssl=false" %JAVA_OPTS% ^
re-install the service by
service.bat install
then start Tomcat to apply changes

Running Selenium Server standalone 2 as a service in windows XP

How can I run Selenium Server Standalone 2 as a windows service in Windows XP?
Or if you want it start at startup, you can do this:
Create file 01_start_hub.bat which will contain this command:
java -jar selenium-server-standalone-2.20.0.jar -role hub
Create file 02_start_node.bat which will contain this command:
java -jar selenium-server-standalone-2.20.0.jar -role node -hub http://localhost:4444/grid/register
Place both bat files into Startup folder C:\Documents and Settings\UserName\Start Menu\Programs\Startup
Yes you will have two "ugly" dos prompts after startup, but this is quickwin solutin
http://brantleytec.blogspot.com/2012/11/selenium-hub-and-node-as-windows-service.html
That link describes the process I used to set up and use Selenium hub and node as a service using native Microsoft programs. I was able to get this running locally on my work PC as well as on a remote server which runs my tests after every build.
If this is for your local PC though, I might suggest using the ChromeDriver instead of the RemoteWebDriver. It's less setup and allows new hires to start using your tests without any extra setup.
I've had a lot of luck with the Non-Sucking Service Manager. It's a standalone executable that creates and a windows service and works much better than any alternatives I've ever used (I'm thinking about srvany.exe). The usage instructions are pretty straightforward.
Here's how I used it:
Download and extract nssm.exe
I wanted to run a single instance that acted as both the hub and a node, so I didn't specify a role. I also just wanted the default settings, so I didn't pass in any parameters. Here's what I did from the command line: nssm install Selenium-Server "C:\Program Files\Java\jre6\bin\java.exe" "-jar C:\Selenium\selenium-server-standalone-2.21.0.jar"
If you want to run as just a hub or a node, then add in the -role hub or -role node to the last parameter in step #2, e.g. "-jar C:\Selenium\selenium-server-standalone-2.21.0.jar -role hub". You can specify any other parameters for Selenium here as well.
If you need to adjust the parameters later, you can do this through Regedit under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\\Parameters. Specifically, the AppParameters Key contains the parameters you pass to Selenium.
Checkout the following project...
I've used it to setup my Minecraft Server (java project) as a windows service.
http://yajsw.sourceforge.net/
Good Luck
And here is link to more durable solution - first create the BAT files as in my other answer. Second read this article - Its about creating the service. I would reccomend pointing out to the BAT files in the options.
I never created a service, so that help page is as much as I can offer

Can't setup remote debugging with JBoss Web 2.1.4 windows and eclipse

I'm unable to find an option to setup remote debugging in JBossWeb 2.1.4 on Windows. It is not installed as a service and there are no .bat scripts where I can edit the JAVA_OPTS environment variable to include:
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=4142
The only thing in the jboss web bin directory are jbossweb.exe files.
I've tried editing the run configuration in eclipse to start the container by running jbossweb.exe and setting the environment variable JAVA_OPTS to the above, but it doesn't listen on port 4142 on startup (ie, there seems to be no effect in adding the environment variable to the run configuration).
Any ideas here?
If you control the server from eclipse with for instance JBoss Tools, you can just click "debug" instead of "start" in the Server pane in order to start up in debug mode.
You can create such bat script by yourself. Just add jboss.bat file to bin subdirectory of JBoss install directory and put there:
java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=4142 -jar "D:\JBoss.org\JBoss Web 2.1\bin\bootstrap.jar" start
When you run this script, you will get JBoss running in debug mode. Probably, it won't help you in all situations, but it worked for me.

Run batch file as a Windows service

In order to run one application, a batch file has to be kicked off (which does things like start Jetty, display live logs, etc). The application will work only if this batch file is running. I am hence forced to have this batch file running and not logout from the Windows server.
Can this batch file be run as a service? I am experimenting with one of the suggestions from a similar question.
NSSM is totally free and hyper-easy, running command prompt / terminal as administrator:
nssm install "YourCoolServiceNameLabel"
then a dialog will appear so you can choose where is the file you want to run.
to uninstall
nssm remove "YourCoolServiceNameLabel"
There's a built in windows cmd to do this: sc create. Not as fancy as nssm, but you don't have to download an additional piece of software.
sc create "ServiceName" start= demand displayname= "DisplayName" binpath= [path to .bat file]
Note
start=demand means you must start the service yourself. Options include: boot, system, auto, demand, disabled, delayed-auto
whitespace is required after =
I did encounter an error on service start that the service did not respond in a timely manner, but it was clear the service had run the .bat successfully. Haven't dug into this yet but this thread experienced the same thing and solved it using nssm to install the service.
No need for extra software. Use the task scheduler -> create task -> hidden. The checkbox for hidden is in the bottom left corner. Set the task to trigger on login (or whatever condition you like) and choose the task in the actions tab. Running it hidden ensures that the task runs silently in the background like a service.
Note that you must also set the program to run "whether the user is logged in or not" or the program will still run in the foreground.
On Windows 2019 Server, you can run a Minecraft java server with these commands:
sc create minecraft-server DisplayName= "minecraft-server" binpath= "cmd.exe /C C:\Users\Administrator\Desktop\rungui1151.lnk" type= own start= auto
The .lnk file is a standard windows shortcut to a batch file.
--- .bat file begins ---
java -Xmx40960M -Xms40960M -d64 -jar minecraft_server.1.15.1.jar
--- .bat file ends ---
All this because:
service does not know how to start in a folder,
cmd.exe does not know how to start in a folder
Starting the service will produce "timely manner" error, but the log file reveals the server is running.
If you need to shut down the server, just go into task manager and find the server java in background processes and end it, or terminate the server from in the game using the /stop command, or for other programs/servers, use the methods relevant to the server.
As Doug Currie says use RunAsService.
From my past experience you must remember that the Service you generate will
have a completely different set of environment variables
have to be carefully inspected for rights/permissions issues
might cause havoc if it opens dialogs asking for any kind of input
not sure if the last one still applies ... it was one big night mare in a project I worked on some time ago.
While it is not free (but $39), FireDaemon has worked so well for me I have to recommend it. It will run your batch file but has loads of additional and very useful functionality such as scheduling, service up monitoring, GUI or XML based install of services, dependencies, environmental variables and log management.
I started out using FireDaemon to launch JBoss application servers (run.bat) but shortly after realized that the richness of the FireDaemon configuration abilities allowed me to ditch the batch file and recreate the intent of its commands in the FireDaemon service definition.
There's also a SUPER FireDaemon called Trinity which you might want to look at if you have a large number of Windows servers on which to manage this service (or technically, any service).
Since NSSM is no longer maintained, you can consider using WinSW. It has binaries that would work with or without .Net.
Basically you create an XML file and then install it. Here is a sample of a minimal XML:
<service>
<!-- ID of the service. It should be unique across the Windows system-->
<id>myapp</id>
<!-- Path to the executable, which should be started -->
<!-- CAUTION: Don't put arguments here. Use <arguments> instead. -->
<executable>%BASE%\myExecutable.exe</executable>
</service>
And then you can install and start it:
winsw install myapp.xml
winsw start myapp.xml
Install NSSM and run the .bat file as a windows service.
Works as expected
My easest way is using opensource svcbatch (https://github.com/mturk/svcbatch/) as wrapper of CMD(BAT) in sc :
sc create myservice binPath= ""%cd%\svcbatch.exe" myservice.bat"

Resources