-
1. Re: How to read a file from inside of a deployed war
peterj Aug 10, 2010 12:49 PM (in response to vsrivastav)You can't. The servlet spec requires that the classes in a WAR be isolated and not accessible from outside the WAR.
Having said that, look at the useJBossWebLoader entry in server/xxx/deployers/jbossweb.deployer/ META-INF/war-deployers-jboss -beans.xml, and pay careful attention to the warning in the comment that states this setting is no longer the correct way to achieve this result (the JBAS-6914 reference is to a JIRA entry).
Oh, wait a minute. You are trying to access a file, not a class. Ignore the above. Instead, use exploded deployment for the WAR, then you will be able to access the file assuming your know the name of the exploded WAR directory.
-
2. Re: How to read a file from inside of a deployed war
vsrivastav Aug 10, 2010 5:13 PM (in response to peterj)Ok. Let's say I have this xml file in the war and maybe I can read it using http client. The idea is to read the xml file whenever a WAR is deployed.
The following two wiki websites talk about how to listen for war deployment events:
I have added the following methods to my MBean, but I don't get any notification when I deploy/undeploy a war file. What is missing?@Override protected void startService() throws Exception { super.startService(); registerWithWebDeployer(); } private void registerWithWebDeployer() { try { ObjectName webDeployer = new ObjectName("jboss.web:service=WebServer"); log.info("Registering with WARDeployer=" + webDeployer); getServer().addNotificationListener(webDeployer, this, null, null); } catch (InstanceNotFoundException ex) { Logger.getLogger(UIMgrService.class.getName()).log(Level.SEVERE, null, ex); } catch (MalformedObjectNameException ex) { Logger.getLogger(UIMgrService.class.getName()).log(Level.SEVERE, null, ex); } catch (NullPointerException ex) { Logger.getLogger(UIMgrService.class.getName()).log(Level.SEVERE, null, ex); } } @Override public void handleNotification(Notification notification, Object handback) { log.info("Notification: "+ notification.getMessage()+":"+handback); }
-
3. Re: How to read a file from inside of a deployed war
peterj Aug 10, 2010 5:21 PM (in response to vsrivastav)Which version of JBoss AS are you using? Both of those wiki pages are old an no longer apply to JBoss AS 5.x and beyond - deployment was moved from JMX into the microcontainer. I think there is a way of getting notified regarding deployment, but I don't know what it is off hand. Perhaps Ales will see this post and reply...
-
4. Re: How to read a file from inside of a deployed war
vsrivastav Aug 10, 2010 10:12 PM (in response to peterj)I am using 5.1.0.GA.
-
5. Re: How to read a file from inside of a deployed war
jaikiran Aug 11, 2010 11:17 AM (in response to vsrivastav)Those notifications no longer work for AS-5 and above. See this previous discussion http://community.jboss.org/thread/2709
-
6. Re: How to read a file from inside of a deployed war
jaikiran Aug 11, 2010 11:22 AM (in response to vsrivastav)Vivek Srivastav wrote:
The following two wiki websites talk about how to listen for war deployment events:
Those wiki articles have now been updated with a note on AS-5.
-
7. Re: How to read a file from inside of a deployed war
vsrivastav Aug 12, 2010 12:54 AM (in response to jaikiran)Thanks for the pointers. I guess I am still missing something. I looked through various test cases and even through the DeployImpl code but I don't see a callback mechanism for notification.
Is the new deployer architecture documented anywhere. Appreciate any help.
-
8. Re: How to read a file from inside of a deployed war
jaikiran Aug 12, 2010 2:57 AM (in response to vsrivastav)Vivek Srivastav wrote:
Is the new deployer architecture documented anywhere. Appreciate any help.
Section IV here http://docs.jboss.org/jbossmc/docs/2.0.x/userGuide/index.html
-
9. Re: How to read a file from inside of a deployed war
jaikiran Aug 12, 2010 2:58 AM (in response to jaikiran)By the way, I'm still not sure why you want to use deployment notifications to get access to the files in your .war file.
-
10. Re: How to read a file from inside of a deployed war
vsrivastav Aug 12, 2010 8:13 AM (in response to jaikiran)Jaikiran. Thanks for all your help and pointers.
I am working on a modular framework for UI needs of our application. There will be an application core and provide UI and other features. When a war (which will be like a plugin) is deployed with layout information, the JMX service will get notified and create a consolidated UI skeleton. The UI will be generated based on this skeleton. The browser client will be polling for changes in the layout if a new war is deployed it will dynamically update the UI.
Maybe there are better ways to do this.