jboss war deployed listener - jboss

Is there a single listener one could implement to get a "war deployed" event?
I know there is the ContextServletListener.
But it has to be 'attached' for each component (several web.xml files).
As a fallback, if I use ContextServletListener, how can I tell that the last component has been deployed?
As a side note: I need to be aware of a hot deploy when it finishes.

JBoss registers a J2EEApplication MBean when a war is deployed. You can register a JMX notification listener with the JBoss MBeanServer's MBeanServer delegate (Object name: JMImplementation:type=MBeanServerDelegate) which will notify you when MBeans are registered and unregistered.
An ObjectName filter like jboss.management.local:J2EEServer=Local,j2eeType=WebModule,* for your registered notification listener will get you notifications for all deployed wars.
This will work for JBoss 4.x and 5.x.

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..!!

JMS web application with Eclipse and WebSphere Application Server

I am new to JMS and WAS. I am grateful if someone provides any reference that helps me to create a web application in eclipse with JMS and WAS 7.0.
Also want to get answers for below questions..
How to inject ConnectionFactory or Destination object (created in WAS) into application using jndi?
How to install and run JMS web application on WAS server?
First you need to decide on the provider for JMS. It could be WebSphere MQ, the JMS provider that comes inbuilt with WAS or some other provider too.
Refer to the redbooks https://www.redbooks.ibm.com/Redbooks.nsf/RedbookAbstracts/sg247770.html?Open.
You can use InitialContext to lookup connection factory and Destination.
You can deploy the JMS app just like any other app. But ensure that JNDI objects are configured.
This is also a nice info-center to use for reference: http://pic.dhe.ibm.com/infocenter/prodconn/v1r0m0/topic/com.ibm.scenarios.wmqwasusing.doc/topics/scenario_overview.htm

Jboss EAR with EJB and webservice health monitoring and management

I am using Jboss5.1 and I have a EAR1 deployed which has a EJB3 component implemented using #Stateless annotation and the same EJB is also exposed as webservice using the annotation #webservice.
I want to check through a EJB service/management service bean(Packaged in another EAR2) from the start of deployment to un-deployment of EAR1 PERIODICALLY, if the EJB and Webservice is deployed and running properly and working normally and is not in deadlock/non responsive state.
I have looked into JMX and I am able to get notifications of create and destroy for EJB as well as webservice, but how to check periodically whether the EJB and webservice is working normally and is not in deadlock/non responsive state?
Also how to monitor Jboss ESB services?
Is the JMX is the only way or does jboss provides any other API's to do monitoring how about JBOSS MONITORING
Thanks in advance if you are looking at this.
Especially JBoss AS5.x is using the so called profile service (PS) as the main way to interact with the server. Unfortunately the PS is not JMX-based and on the other side you don't see all EJBs in the Platform MBean server.
RHQ has a plugin to monitor EJB instances inside AS5 as well as for other resource types like JBoss ESB or Apache Tomcat and is able to determine the availability of EJBs.
but how to check periodically whether the EJB and webservice is
working normally and is not in deadlock/non responsive state?
This is usually something that you can (only)(*) determine by hitting the relevant beans/methods and evaluating the outcome.
*) It may be possible to determine a bean in a deadlocked state by requesting a heap dump and looking for deadlocked periodically.

How to monitor ejb deployments in jboss6

In Jboss4, I used to have an MDB listening to deployment messages for dynamically registering components in a system. I used the approach described at http://community.jboss.org/wiki/ExampleMinimalNotificationListener.
Apparently, this mechanism doesn't help anymore in JBoss 6.
So how can I get notified after an EJB has been deployed or before it gets undeployed?

Unable to see new MBeans in JBoss 5.0

I've been going through several examples on how to add MBeans to JBoss 5.0 so they can be configured though the JMX Console, but none of these examples have ever shown up in the JMX view. I've now tried to get ehCache's JMX integration to work to no avail.
I'm trying (as in the ehCache documentation) the following:
CacheManager manager = CacheManager.create("./ehcache.xml");
MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
ManagementService.registerMBeans(manager, mBeanServer, false, false, false, true);
I never see any errors with my own or now with the ehCache version, but it never shows up in the JMX view. I'm wondering - is there a setting I need to make to to the JBoss configuration to get it to pick up these additions? Am I missing something fundamental? Any hints?
Thanks for any help. I'm pulling my hair out here.
If you're running JBoss on Java 5 or above, then you'll likely have 2 MBean servers running: the "platform" mbean server, which is hosted by the JVM, and the JBoss MBean server, which is hosted by the JBoss code. The two have nothing to do with each other.
Your posted code will register ehcache's mbean in the JVM platform server, which is no use to you.
The easiest way to get a programmatic reference to the JBoss MBean server is
org.jboss.mx.util.MBeanServerLocator.locateJBoss()
Try using that instead of
ManagementFactory.getPlatformMBeanServer();