I have an ear deployed on weblogic console. I need to check contents of manifest file and ejb-jar.xml of a jar that is present in the deployed ear.
Currently I am using the code below to access jar inside ear deployed :
Hashtable env = new Hashtable(5);
env.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
env.put(Context.PROVIDER_URL,
url);
env.put(Context.SECURITY_PRINCIPAL, user);
env.put(Context.SECURITY_CREDENTIALS, password);
Context ctx = new InitialContext(env);
mBeanHome = (MBeanHome)ctx.lookup(MBeanHome.ADMIN_JNDI_NAME);
String type = "EJBComponentRuntime";
Set beans = mBeanHome.getMBeansByType(type);
try{
for(Iterator it=beans.iterator();it.hasNext();)
{
EJBComponentRuntimeMBean rt = (EJBComponentRuntimeMBean)it.next();
if(rt.getParent().getName().equals("xxx")){
System.out.println(rt.getName());
l.add(rt.getName());
Here xxx
is the ear. Now I need to get inside the jar (represented) by variable "rt
" and access its manifest file,ejb-jar.xml
Does anyone have an idea how to do this? I understand we can access manifest files using jarinputstream
. Howe开发者_JAVA技巧ver how do i get that stream?
regards Sameer
You could use something like
InputStream is = this.getClass().getClassLoader().getResourceAsStream("jarfile.jar/META-INF/ejb-jar.xml");
where jarfile.jar that is present in ear.
精彩评论