English 中文(简体)
How to access application.xml file of an EAR deployed to IBM WebSphere 6.1
原标题:

I am deploying an EAR file to the IBM WebSpehre server 6.1 - I want to be able to access the EAR application name which is stored in the deployment file under display-name . Looking through stack overflow posts on related subjects, I ve been able to gather that this is possible via the Java MBean API - or IBM s WAS API - Problem is I cannot find a place where these API lists are summarized, i.e. cannot figure out which one to begin looking at. I could hardcode the WAS install location and find the file by looking in the installedApps directory, but this is not dynamic.

Does anyone have any experience working with these APIs? Any other way to dynamically find the deployed EAR s display name?

EDIT - I should add that the reason I would like this information is to dynamically load our properties files - that are named by the following convention "EARAppName.properties" - so you see there IS a reasonable rationale behind desiring this information in my application

EDIT 2 - I should also note that this app will always be deployed on a WAS - but in the case that it isnt, a generic non-proprietary solution would be preferred, but not necessary at this moment.

EDIT 3 - What I want to accomplish: Is there a way to dynamically find the deployed EAR s display name from within the application code?

最佳回答

If the whole reason for this objective is reading properties files, then I would recommend a different approach.

Use WebSphere Shared Library.

http://publib.boulder.ibm.com/infocenter/wasinfo/v6r0/index.jsp?topic=/com.ibm.websphere.nd.doc/info/ae/ae/tcws_sharedlib.html

For each deployed EAR have a separate directory containing properties files that needs to be accessed by that EAR.

Create shared library entry for each directory containing properties file.

From EAR create shared library reference to required shared library.

.

However below links may be of some help to you for your approach:

Managing applications through programming

Interface AppManagement

问题回答

Not a direct answer but wouldn t it be simpler to use an hard coded name for the properties file? After all, it seems to make sense for a given application to be aware of what file to load. Writing code to read the display-name in a deployment descriptor sounds odd (especially since you, as Application Component Provider, shouldn t rely on something owned by the Application Assembler).

I am trying to accomplish the same thing here. I am trying to locate at runtime the ApplicationName found in the META-INF/application.xml.

We use this AppName in our Log4J File Appender to create a proper log file name base on the Application currently logging. We have lots of programmers and lots of App and we need to enforce some convention in a framework.

I whish I could simply call:

InputStream in = new MyObject().getClass().getResourceAsStream(“META-INF/application.xml”);

I also tried to change the classloader to ‘PARENT_LAST/FIRST’ and ‘Single ClassLoader’ but it does not work.

I could locate the application.xml on filesystem relative to my war file but I am not sure it would work all the time.

Is the JMX Api realy the only way?

That is not for your application to know as such, but for EAR-handling tools, including the application server.





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签