Glassfish 4.1.1, domain installed as a service does not restart as a service - windows

I got a Glassfish 4.1.1 copy with two domains on Win2012R2 (no clusters, no instances). I've set a windows service for each of those.
Both services run regularly up until the moment when I restart either or both of them thru their admin web console (server (Admin Server) -> Restart). The following happens:
The domain-related service stops, but does not start again,
The allegedly stopped domain is perfectly functional (deployed apps and admin console are there) (!!!),
When I try to start the win service manually, I get Error 1067 (GF reports "something" is already listening on required ports and that's the domain itself that is now, somehow, NOT run as a service!),
I can start the service again only after I've stopped the domain thru server (Admin Server) -> Stop.
Why did I mention two domains? Because this does not happen when I have just one domain with its' service.
Domains do not share ports, only things in common are the JDK/JRE and general GF files.
Is this a bug in Glassfish or did I set something wrong?

This is a limitation, rather than a bug. The problem is that GlassFish has no way to tell whether or not it is running as a service (and, if it is, what the name of that service would be).
The restart command means that GlassFish is restarting itself, so Windows detects that the process it started has been terminated and shows the service as stopped, but GlassFish spawns a new JVM itself. It has no capability to tell Windows to start the service again.
Essentially, the behaviour you are seeing is expected.

After some more testing, I realized what was going on:
Glassfish is definitively capable of restarting its' own Windows service,
The thing that was happening is it takes GF a few seconds do this on its' own,
But, before GF domain could restart as a service, I clicked the URL to return to admin console, every time. That forced it to run as an ordinary executable.
It does seem like the restart happens faster with just one win service, but I won't claim that as an absolute truth without more testing, for which I have no time now.

Related

What are the reason when a stopped windows service starts automatically?

What are the reason when a stopped windows service starts automatically?
I know only few which are
When service start-up mode is automatic and someone re-start the server then service will also get started.
When someone forcefully start the service manually.
Is there any other way when a stopped service can start?
Service triggers. This can be hardware device added, internet connection discovered, group policy change or any ETW event.
Have you checked there is a service Dependence? If another service depends on its function, it will automatically come up even though you stop the service.
Since it keeps restarting, it means you are not suppose to disable or stop the service.
Locate the ASP.NET State Service and check the Startup Type property and click the recovery tab for your service configuration and check if the options there could be restarting it.
You can also run a virus scan on your system to be sure your pc is safe.

why run WAS as service

What are the business reasons (advantages/disadvantages) of running a websphere 6.1 App server as a windows service? I mean what are the factors governing this decision?
The other thing I notice is that when I restart the service...and I click something on the admin console, it does n't give me the login page. What is happening here?
You should give this article a read:
http://www.ibm.com/developerworks/websphere/techjournal/1010_supauth/1010_supauth.html
Can you elaborate on the restarting the service and not receiving the login page issue. I am not sure i understand your query here.
What happens when you click on the console after restarting?
HTH
Manglu
To my knowledge - the main reason for choosing to run WebSphere as a Windows Service is that whenever the server goes down for whatever reason, and then is restarted, if not running WebSphere as a service you will need to actually log on to the server and manually start WebSphere. (startServer.bat, startManager.bat, startNode.bat etc).
So for any environment where uptime is an issue on the Windows platform, choose windows service. If you are just installing a development/test environment...not needed.

Chrome losing sessions when my Axis2 web service is accessed

Odd one this. I've got a servlet application running under Tomcat with Axis2. The application also exposes a web service (via Axis2).
Now then, Tomcat handles session management no problem, as per usual, however, when the web service is invoked, randomly, all sessions appear to be invalidated. Plus, afaik, this only happens in Chrome! The next time the Chrome client makes a request, it is handed a new session by Tomcat.
This happens after every time the web service is invoked, but doesn't affect sessions in Firefox or Safari.
Any ideas? This is extremely baffling for me.
Thanks in advance
Fixed it. Very strange result but the Axis2/web service part was a complete red herring. The problem here was that I was using another instance of Chrome to invoke the web service (using a different web app).
This second app was running on the same URL but on a different port (8080 instead of the default 80). It would seem that browsers (not just Chrome) manage sessions based on A. the domain (such as www.stackoverflow.com or localhost in my case) and B. the path (ie the name of the web app in Tomcat).
It does NOT make any distinction between domains running on different ports, hence Chrome got itself all confused when I had two windows open, one pointed to localhost/webapp and the other pointing to localhost:8080/webapp. As far as Chrome was concerned it was the same site and therefore each one kept overwriting the other's session ID.
What a mess!

Debugging Topshelf service that won't run under restrictive account

I have a Windows service written using Topshelf. I'm trying to configure it to run using a Windows account with restricted privileges rather than using LocalSystem. That's also necessary as I'd like to connect to a database using integrated authentication.
The service works when run as LocalSystem (albeit with a database connection string containing credentials) and running the console application as my limited account (using runas) also works.
However, when I try to start the service the service control manager times out waiting for a response:
The service did not respond to the start or control request in a timely fashion.
I also get the following in the Application Popup event log:
Application Error : The exception unknown software exception (0xc06d007e) occurred in the application at location 0x77e4bef7.
The first thing that the application does is writes to a log file but it doesn't reach that when I start the service. The logging works if I run via the console.
Any suggestions what I might be missing or what I might try next?
This problem seems to be related to the server (a domain controller) rather than TopShelf. A service built with the .NET service component also exhibits the same behaviour.
The service runs successfully on a different machine (in the same domain).
Unfortunately this doesn't help diagnose the problem but gives me an acceptable workaround.
Check the MSDN article Debugging windows services which describes how you debug windows services.
I've just started seeing this on a few of my services written in .net 2.0. They'll start fine when the server boots, but if I were to restart them throughout the day, they would not start, and give this error message.
They currently ran under a domain account which has admin rights on the box, but for kicks, I switched it to Local System, and the service started normally. I stopped it, changed it back to the domain account (reentering the password), and it started normally again as expected.
Don't know if this counts as a 'fix' so much, but that's what worked for me.

Restarting windows service from website

I've a website that puts info into a mySQL database and a windows service (written in VB.Net) that polls the db and actions what's in there.
However, occasionally it stalls and rather than having to RDP into the server, I want superusers to click on a button to restart the service.
I can get the button to say, do a directory listing of c:\ output to a test file so the whole 'getting a command to execute on a remote server' issue works. However, I can't restart services.
I assume this is a security thing (although it has full rights to c:\ I thought I'd sussed that already).
The website runs under the normal IUSR_user so am I doing something really stupid or can someone explain how to get the service to be restarted ?
Many thanks
Adrian
I think a significantly bigger problem is that you have a service that's stalling. Do you have any logs or errors that the service outputs to that you could use to diagnose why it's stalling?
I'd write a service that restarts selected services and call that from my website, just for fun!
It seems that you need to give the user permissions on the specific service. The simplest way to do this (in my view) is to use subinacl.exe from the Windows Resource Kit.
subinacl.exe /service MySQL /Grant=IUSR_user
I'm would be very careful when doing this on a public-facing web server. Have both authentication and rate limiting on the restarting code.
Use the ServiceController class:
http://msdn.microsoft.com/en-us/library/system.serviceprocess.servicecontroller.aspx
This should allow you to connect to the named service and stop/start it.
EDIT:
In addition, you probably need to have your web app impersonate a user with rights to restart the service. This can be accomplished via an identity impersonate in the web.config, or running the web app in a configured application pool in IIS. Keep in mind that the web app will have to run on the same box as the service is running on.

Resources