Controlling Wildfly undeploy - deployment

We have an issue with undeploying an enterprise archive from Wildfly in a controlled matter. So the issue is that we automatically undeploy and deploy a new enterprise archive to Wildfly (Wildfly is also restarted). However, the issue is that we need to make sure that system goes down in a controlled matter so that state is not lost of corrupted.
This is normally done with a shutdown-hook, but that does not work well with Wildfly. When undeploy executes the shutdown-hook is executed, but Wildfly will not respect it. It will not give enough time to system to do clean up and threads to terminate.
So is there anyway to pause the undeploy or force Wildfly wait longer for the system to terminate before killing it?

Related

Adding wildfly jms subsystem with wildfly cli java api without reloading the server

So we need to provision (add the jms extension/subsystem/configurations to standalone.xml) the JMS subsystem in wildfly when starting the server if it's not already provisioned and that needs to happen automatically. We have an application written in java and we chose to provision the jms subsystem with wildfly's cli java api and that is executed when our application starts deploying. The thing is we need to provision the jms subsystem and use it in the same application.
Problem is, when we add the needed configurations in standalone.xml with wildfly's cli java api, the server requires a reload but we can't reload it because our app is already deploying, it tries to use the defined queues and fails because... Well, the subsystem is not active yet. On next server restart everything is ok but as you can guess in a production environment this is unacceptable. Is there any solution to this? I've tried adding a reload cli command in the end of the batch that creates the jms subsystem and it starts reloading the server but the deployment doesn't stop and exceptions start flying left and right.
Also the whole idea of reloading the server from the app while the app is deploying seems kinda wrong to me.
Thanks in advance.
Solution:
Well the solution in the end was an easy one, we just had to add a reload step in the batch operation that adds the jms subsystem. The problem was that we had a set of async operation that all fired off when the app was deployed so i just had to make sure none of them started until i can check for the messaging subsystem and reload wildfly if necessary. That way I'm not interrupting any async tasks forcefully.
You need to select appropriate profile i.e full or full-ha while starting server only. If you do this there will not be need to add JMS subsystem.
If you want to go with your approach only, add dependency of queue in
application. It will not start deploying until and unless queue is bound to server.
we need to perform reload operation when we add new subsystem, if you dont want to perform reload operation then I will suggest you to start server in 'admin-only' mode. When we start server in 'admin-only' mode then it open only management port(9990/9999). Configure messaging subsystem through CLI command reload server instance. Hope it helps..!!

Difference between starting an application and starting a managed server in weblogic server?

I wanted to know what is the difference between starting an application and starting a managed server in weblogic server?
I have 5 different applications targeted to one managed server, whenever I make any change to any one application I have to restart the managed server entirely to make the changes to reflect. Why is it not that when I simply start and stop the application alone from Deployments it reflects, why do I need to start the managed server every time?
Restarting the managed server will restart the entire JVM including all installed EAR files. Stopping an application simply puts the application in Admin mode so the application class files are not unloaded.
This following document discusses various methods for redeploying applications in WebLogic based on the scope of the deployment:
https://docs.oracle.com/cd/E24329_01/web.1211/e24443/redeploy.htm#DEPGD258

Unable to reconnect to Derby from Tomcat server started via Eclipse

I'm running on Win 7 using Eclipse 4.2 starting a web app on a Tomcat 7 server and using Derby database. I have tried many approaches but run consistently into a common problem:
Everything works just fine the first time I start up and run.
When I redeploy my application after a change, all database connections hang (any kind of restart).
If I stop Eclipse and restart Eclipse, that clears up the problem and the next run works fine again.
Having done some investigation, it appears that the problem is that the Derby port (1527) is not released from one execution of the server to the next. That seems very strange to me since Derby is started by the Tomcat instance which is a separate javaw process.
I've tried:
Configuring the Derby connection as a Tomcat resource
Establishing the connection within my code (rather than via Tomcat resource)
Both the embedded and the network driver
Starting / stopping the network driver from a servlet on startup and shutdown of the Tomcat server
Shutting down the embedded driver via servlet on shutdown of Tomcat
Again, every approach works fine to connect the first time.
One other symptom that doesn't appear to be related (except for as a possible indicator of whether or not shutdown completes correctly) is that the db.lck file for my database never gets deleted. However, whether or not it exists has no bearing on whether or not I can reconnect (only stopping/starting eclipse has an impact).
Any insight would be appreciated.
Thanks!
After some further investigation I'm going to call this a duplicate of: Cannot create JDBC driver of class ' ' for connect URL 'null' : I do not understand this exception. It's not quite the same thing, but that solution (creating META-INF/context.xml) allows it to proceed to failing calls rather than hangs, which is a significant improvement and suggests it's largely related.
I did finally figure this out. It turns out I had the derby jars in the Tomcat lib folder (for Tomcat) and in the deployment assembly for my application in Eclipse (rather than just in the build path). So Tomcat was using the built-in libs, while my app was using the embedded libs, and this resulted in conflicts. Leaving the libs as part of Tomcat and removing them from my war file solved the problem completely.

JBoss 5.1.0 disabled HDScanner, undeploying post restart doesn't work

I have disabled the HDScanner bean (by removing JBOSS_HOME/deploy/hdscanner-jboss-beans.xml) in JBoss 5.1.0 so that I must do all deployments to running instances through Twiddle (applications found in the deployment directory are automatically deployed on startup).
After I have done this I can deploy and undeploy a war by using the following commands:
twiddle.sh -s localhost invoke "jboss.system:service=MainDeployer" deploy "file:/path/to/my.war"
twiddle.sh -s localhost invoke "jboss.system:service=MainDeployer" undeploy "file:/path/to/my.war"
This works fine.
However, if I restart JBoss between the deploy and the undeploy, when I try to undeploy the app using twiddle, the app remains deployed and the JBoss logs display :
2011-04-18 14:30:41,318 WARN [org.jboss.deployment.MainDeployer] (WorkerThread#0[10.21.4.61:43700]) undeploy 'file:/path/to/my.war' : package not deployed
Am I doing something wrong, expecting something that's not possible, or is this a bug in JBoss?
If I am doing something wrong, what is the correct way to undeploy an app that has been deployed using twiddle on an instance of JBoss that has been subsequently restarted?
Edit
Without looking at the source code of JBoss, it seems to me that apps that are deployed on startup are managed in a different place from those deployed through Twiddle. Ie if an app is deployed at startup it is not known of by the mechanism accessed through Twiddle, hence the "package not deployed" error.
So, is there a way to access this other deployment manager through Twiddle such that apps that are present at startup can still be undeployed?
I have done a lot of testing on this, and basically apps that are found at startup are (rightly) considered to be part of the JBoss 'core' and are therefore deployed automatically as part of the startup process. This applies for things such as the jmx-console, and therefore applies for other .wars too. Whether through design or through consequence, these resources that have been automatically deployed during startup cannot be managed by twiddle invokations.

What does the JBoss 5 shutdown do?

At a high level, what does JBoss 5's shutdown do? What might go wrong if I just kill the java process instead of gracefully shutting down JBoss?
A graceful JBoss 5 shutdown takes about 6 minutes for my application, which is pretty big and has 305 EJBs. JBoss seems to pause for a long time just before unbinding the EJB LocalHomes from jndi.
Given that, I am considering simply killing the java process. I am wondering about what might go wrong if I do that.
I run JBoss in mostly in *nix, sometimes in Windows.
Killing the process will leave the JBoss files in a potentially inconsistent state, and will certainly leave them in a messy state. When it restarts, it will probably clean up after itself OK, but then again it may not.
On Windows (you didn't say which platform you use), I've seen a killed JBoss process not release locked files properly, and the server won't restart at all. It's pretty rare, though.
In the end, if it works for you, the I wouldn't worry too much about it.
It releases all you connections such as jndi, jdbc, jms.. It also waits for your classes to finish up what it is doing. It also stops other services such as jms and web console

Categories