HI,
I am deploying an EAR file into my JBOSS 5.1. I want to be able to access the EAR application name which is stored in the deployment file "application.xml" under 'display-name'.
I want to deeploy an admin-webapp how read this information and display all module deployed of my EAR
I think application.xml it's the correct place to search this information开发者_如何转开发...
I tryed:
InputStream in = new MyController().getClass().getResourceAsStream("META-INF/application.xml");
but dont work! return null...
Suggestion? (code please)
Add slash in the beginning of your path:
InputStream in = new MyController().getClass().getResourceAsStream("/META-INF/application.xml");
It should work.
But I think that better solution is to use JMX. It provides you higher level API to access the app server resources including deployed applications. The disadvantage of this approach is that I am afraid that your code will be JBoss specific.
I solved :
ClassLoader loader = getClass().getClassLoader();
URL url = loader.getResource("META-INF/application.xml");
BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
while (true) {
String line = reader.readLine();
System.out.println(line);
if (line == null) {
break;
}
}
In this way I solved the problem and I print content for sample...
but I search an highlevel API to access the app server resources...
What's best way?
精彩评论