兄弟们,大老爷们,救火呀..weblogic jmx管理的程序..在线等

dxadnwfn 2008-06-17 02:45:09
这几天要做一个weblogic jmx的服务的管理,把weblogic里的jmx从程序中抽出写成程序.

我从网上搜索了一些程序,但是报错.环境是这样的. eclipse3.3+weblogic 8.1+jdk1.4

weblogic.jar 和jbossall-client.jar 已经加到lib下

出错的信息是
weblogic.rmi.extensions.RemoteRuntimeException: Unexpected Exception - with nested exception:
[weblogic.rjvm.PeerGoneException: ; nested exception is:
weblogic.utils.NestedException: Lorg/jboss/mx/util/ObjectNamePatternHelper$PropertyPattern; - with nested exception:
[java.lang.NoClassDefFoundError: Lorg/jboss/mx/util/ObjectNamePatternHelper$PropertyPattern;]]
at weblogic.management.internal.AdminMBeanHomeImpl_811_WLStub.getActiveDomain(Unknown Source)
at com.ivsoftware.weblogic.WeblogicJMX.main(WeblogicJMX.java:32)
Exception in thread "main"


程序如下:


public class WeblogicJMX {

public MBeanHome localHome;

public MBeanHome adminHome;

public static final String SERVER_NAME = "weblogic";

public static final String SERVER_PASSWORD = "weblogic";

public static final String SERVER_URL = "t3://localhost:7001";
//public static final String SERVER_URL = "t3://158.222.30.246:7001";

public static final String SERVER_POOL="MyJDBCMultiPool";
// public static final String SERVER_POOL="MyPool";
public static void main(String[] args) {
WeblogicJMX weblogicJMX = new WeblogicJMX();
MBeanHome mBeanHome = weblogicJMX.getMBeanHome();
System.out.println(mBeanHome.getActiveDomain());
System.out.println("domainName:"+mBeanHome.getDomainName()+" serverName:"+mBeanHome.getMBeanServer());
//
// // In this case we want the 100 most recently executed statements
// JDBCStatementProfile[] profiles = weblogicJMX.getProfiles(100);
// // Doing the looping so that the most recent statements information is
// // retrieved first
// for (int i = profiles.length - 1; i > -1; i--) {
// // Getting the number of parameters passed into the current
// // //statement
// int paramCount = profiles[i].getParameterCount();
// // Format the start and end time for the current statement
// SimpleDateFormat simpleDateFormat = new SimpleDateFormat(
// "yyyyy.MMMMM.dd GGG hh:mm:ss:SS aaa");
// String startTime = simpleDateFormat.format(new Date(profiles[i]
// .getStartTime()));
// String endTime = simpleDateFormat.format(new Date(profiles[i]
// .getStopTime()));
//
// // Append the parameters together in order to display them
// StringBuffer paramsBuffer = new StringBuffer();
// if (paramCount < 1) {
// paramsBuffer.append("None");
// } else {
// for (int j = 0; j < paramCount; j++) {
// paramsBuffer.append(profiles[i].getParameter(j));
// paramsBuffer.append(" ");
// }
// }
//
// String statementTxt = profiles[i].getStatementText();
// String paramsTxt = paramsBuffer.toString();
// long timeTaken = profiles[i].getTimeTaken();
//
// // Then use statementTxt, paramsTxt, timeTaken, startTime, endTime
// // etc to show the statement details in a UI
// }

}

private MBeanHome getMBeanHome() {
// URL to the serve whose JDBC activity we are tracing
// The MBeanHome will allow us to
// retrieve the MBeans related to JDBC statement tracing
MBeanHome home = null;

try { // We'll need the environment so that we can //retrieve the
// initial context

//--------------------

Environment env = new Environment();
env.setProviderUrl(SERVER_URL);
env.setSecurityPrincipal(SERVER_NAME);
env.setSecurityCredentials(SERVER_PASSWORD);
Context ctx = env.getInitialContext();

// Retrieving the MBeanHome interface for the server with //the url
// t3://localhost:7001
home = (MBeanHome) ctx.lookup(MBeanHome.ADMIN_JNDI_NAME);

//----------------------
// home = (MBeanHome)Helper.getMBeanHome("weblogic","weblogic",SERVER_URL,"myserver");
} catch (Exception ne) {
System.out.println("Error getting MBeanHome " + ne);
}
return home;
}

public void configureJDBCAuditing(boolean isOn) {
try {
MBeanHome home = getMBeanHome();
// Retreive the bean to help us configure the Pool
JDBCConnectionPoolMBean mConfigBean = (JDBCConnectionPoolMBean) home
.getConfigurationMBean(SERVER_POOL, "JDBCConnectionPoolConfig");
mConfigBean.setSqlStmtProfilingEnabled(isOn);
mConfigBean.setSqlStmtParamLoggingEnabled(isOn);
} catch (InvalidAttributeValueException iave) {
System.out.println("Invalid attribute while configuring tracing "
+ iave);
} catch (InstanceNotFoundException infe) {
System.out.println("Instance not found while configuring tracing "
+ infe);
}
}

/** Pass in -1 to get all profiles */
public JDBCStatementProfile[] getProfiles(int maxProfiles) {
JDBCStatementProfile[] profiles = null;
try {
MBeanHome home = getMBeanHome();
JDBCConnectionPoolRuntimeMBean mbean = (JDBCConnectionPoolRuntimeMBean) home
.getRuntimeMBean(SERVER_POOL, "JDBCConnectionPoolRuntime");
int numProfiles = mbean.getStatementProfileCount();
int profilesIndex = 0;
// figure out index to start at and how many we want
if (maxProfiles != -1) {
profilesIndex = numProfiles - maxProfiles;
} else {
maxProfiles = numProfiles;
}
profiles = mbean.getStatementProfiles(profilesIndex, maxProfiles);
} catch (InstanceNotFoundException infe) {
System.out.println("Problem retrieving jdbc profiles " + infe);
}
return profiles;
}

public void reset() {
MBeanHome home = getMBeanHome();
try {
JDBCConnectionPoolRuntimeMBean mbean = (JDBCConnectionPoolRuntimeMBean) home
.getRuntimeMBean(SERVER_POOL, "JDBCConnectionPoolRuntime");
// Remove everything from the cache
mbean.resetStatementProfile();
} catch (InstanceNotFoundException infe) {
System.out.println("Problem while resetting JDBC profiles " + infe);
}
}

}







...全文
290 11 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
guanjun0901 2008-07-28
  • 打赏
  • 举报
回复
哥们怎么还不上线,迫切需要你的帮助,我在线等。。
guanjun0901 2008-07-25
  • 打赏
  • 举报
回复
大哥 你什么时候在,帮帮我呀,我现在有个需要达到和你一样功能的任务,可我对JMX一点都不懂。能否帮帮我,谢谢你了,我的QQ是514164938 迫切需要你的帮助
dxadnwfn 2008-07-14
  • 打赏
  • 举报
回复
没有一个答对的...

后来发现是因为多加了些jar包..

可能只个包里面有相同的东西,所以造成提示信息说某一个类没有找到

我原来是建的j2EE工程

后来我改建java工程就OK了
night__cat 2008-06-30
  • 打赏
  • 举报
回复
up
dxadnwfn 2008-06-18
  • 打赏
  • 举报
回复
要得到的是上面这些信息
dxadnwfn 2008-06-18
  • 打赏
  • 举报
回复
最小 堆栈大小 29,165 KB
最大 堆栈大小 30,519 KB
平均 堆栈大小 29,839 KB
总计 堆栈大小 32,576 KB
当前 堆栈大小 29,534 KB
告警配置
属性 值 阈值
最小 应答时间 0 ms
最大 应答时间 16 ms
平均应答时间 9 ms
当前 应答时间 没有可用数据
告警配置


线程池明细
名称 健康状况 总线程数 空闲线程 在用线程 未决的请求数目 告警配置
weblogic.admin.RMI 3 2 1 0
weblogic.admin.HTTP 2 2 0 0
weblogic.kernel.Default 15 15 0 0
weblogic.kernel.System 5 5 0 0
weblogic.kernel.Non-Blocking 0 0 0 0


数据库连接池的详细信息
名称 健康状况 连接池大小 活动连接 活动连接数% 遗漏的连接 线程等待 告警配置
MyPool 1 0 0% 0 0


JMS明细
名称 健康状况 字节
当前 挂起 接收数/分
信息数
当前 挂起 接收数/分
告警配置
WSStoreForwardInternalJMSSe... 0 0 0 0 0 0


得到这些信息
dxadnwfn 2008-06-18
  • 打赏
  • 举报
回复
我主要想问的不是这个;
大家知道Applications manager (nanageEngine)的,它里就用一个weblogic管理的

监视器信息
名称 skyon-gcw_WEBLOGIC-server_7001
健康状况 资源停止.
因为资源不可用所以健康状态为严重
类型 WebLogic服务器
WebLogic版本 WebLogic Server 8.1 SP1
监听端口 7001
活化时间 2008-6-18 上午11:06
主机名 skyon-gcw (192.168.8.114)
操作系统 Windows XP
最后轮询时间 2008-6-18 下午3:44
下次轮询时间 2008-6-18 下午3:49

等等...

大家提供点资料

老紫竹 2008-06-17
  • 打赏
  • 举报
回复
java.lang.NoClassDefFoundError: Lorg/jboss/mx/util/ObjectNamePatternHelper$PropertyPattern;]]


很明显,你缺少了一个类库

org.jboss.mx 。。。

我不知道这个jar应该叫什么名字,也许叫 mx.jar吧??
jdlsfl 2008-06-17
  • 打赏
  • 举报
回复
关注,帮顶
dxadnwfn 2008-06-17
  • 打赏
  • 举报
回复
我在线呀....

67,549

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧