0

在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 构建路径) 和 (WebContent-WEB-INF-lib) 中添加 Sigar.jar

如果我在jsp中调用该方法,我不知道为什么它不起作用......我该如何解决它?

4

0 回答 0