Since I could not find an answer looking through the Forums or the Wiki I resorted to
downloading the source code.
Basically my goal is to be able to receive STARTED and FAILED notifications when an ear
has actually started or failed. Currently these notifications are not sent. STARTED is
sent once you redeploy the app as I have showed in the previous post, and the FAILED
notification isn't sent at all.
I've been remote debugging the deployers and it seems these are just not sent when you
expect them. To solve the problem I've had to modify some of the JBoss code.
EARDeployer.java
| public void start(DeploymentInfo di) throws DeploymentException
| {
| ...
| log.info("Started J2EE application: " + di.url);
| }
|
As you can see above, the start method ends with a log.info. This is where I would have
expected a STARTED notification to be sent. There is none, and there is none in the
ServiceController.start method which is also called by EARDeployer.start.
I modified the code to be
| public void start(DeploymentInfo di) throws DeploymentException
| {
| ...
| log.info("Started J2EE application: " + di.url);
|
| di.state = DeploymentState.STARTED;
| Notification notification = new Notification(
| di.state.toString(),
| di.deployer.getServiceName(),
| super.nextNotificationSequenceNumber()
| );
| notification.setUserData(di);
| sendNotification(notification);
| }
|
To receive FAILED notifications, I added code to EARDeployer to 4 methods: init, create,
start, stop. Depending on what is wrong with the ear, a deployement can fail in any of
these method. All these methods begin with a try/catch so the code is the same for each
method.
Current code
| public void init(DeploymentInfo di) throws DeploymentException
| {
| try
| {
| ...
| } catch (Exception e)
| {
| DeploymentException.rethrowAsDeploymentException("Error in accessing
application metadata: ", e);
| }
| ...
| }
|
Modified to receive FAILED notifications
| public void init(DeploymentInfo di) throws DeploymentException
| {
| try
| {
| ...
| } catch (Exception e)
| {
| di.state = DeploymentState.FAILED;
| Notification notification = new Notification(
| di.state.toString(),
| di.deployer.getServiceName(),
| super.nextNotificationSequenceNumber()
| );
| notification.setUserData(di);
| sendNotification(notification);
|
| DeploymentException.rethrowAsDeploymentException("Error in accessing
application metadata: ", e);
| }
| ...
| }
|
|
The create, start, stop methods are modified similarly to the init method above.
Unless someone can show me a different way of getting these notifications, I'm going
to add my findings to a JIRA ticket since not getting the STARTED and FAILED notifications
limits the usefulness of being able to create NotificationListeners.
I've only been interested in the EARDeployer but the same bug exists for the other
deployers such as JARDeployer.
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4220088#...
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&a...