使用window10上的eclips存在问题
5월 25, 2017 9:15:52 오전 org.apache.catalina.core.StandardWrapperValve invoke
심각: Servlet.service() for servlet [jsp] in context with path [/ESTIS] threw exception [An exception occurred processing JSP page /Estis/Admin_SystemMonitoring.jsp at line 51
48: SystemMonitoring sm=new SystemMonitoring();
49: CPUVo cpuVo=new CPUVo();
50: MemoryVo memoryVo=new MemoryVo();
51: cpuVo=sm.getCPU();
52: memoryVo=sm.getMemory();
53: %>
54: <div><%=cpuVo.getTotalSysTime() %></div>
Stacktrace:] with root cause
java.lang.UnsatisfiedLinkError: org.hyperic.sigar.Cpu.gather(Lorg/hyperic/sigar/Sigar;)V
at org.hyperic.sigar.Cpu.gather(Native Method)
at org.hyperic.sigar.Cpu.fetch(Cpu.java:30)
at org.hyperic.sigar.Sigar.getCpu(Sigar.java:320)
at org.hyperic.sigar.Sigar.getCpuPerc(Sigar.java:341)
at SystemMonitoring.SystemMonitoring.getCPU(SystemMonitoring.java:27)
at org.apache.jsp.Estis.Admin_005fSystemMonitoring_jsp._jspService(Admin_005fSystemMonitoring_jsp.java:163)
我在Admin_SystemMonitoring.jsp中调用Sigar API
public CPUVo getCPU()
{
System.out.println("================== CPU DATA ====================");
Sigar sigar = new Sigar();
CpuPerc cpu = null;
CpuPerc[] cpus = null;
CPUVo vo=new CPUVo();
try
{
cpu = sigar.getCpuPerc();
cpus = sigar.getCpuPercList();
vo.setUserTime(CpuPerc.format(cpu.getUser()));
vo.setTotalSysTime(CpuPerc.format(cpu.getSys()));
vo.setTotalIdle(CpuPerc.format(cpu.getIdle()));
System.out.println(String.format("Total User Time : %s / Total Sys Time : %s / Total Idle : %s ",
vo.getUserTime(),
vo.getTotalSysTime(),
vo.getTotalIdle()));
} catch (Exception e)
{
e.printStackTrace();
}
return vo;
}
但是如果我在java主类中调用,则SystemMonitoring类可以正常工作。 另外,我在(project-properties-java build path)和(WebContent-WEB-INF-lib)中添加了Sigar.jar
如果我在jsp中调用该方法,我不知道为什么它不起作用... 我该如何解决?