我得到的问题是通过 JSP 获取详细信息。我正在使用以下版本:jna-4.2.2.jar、slf4j-api-1.7.21.jar、slf4j-simple-1.7.21.jar、jna-platform-4.2.2.jar、oshi-core-2.3。 jar 问题是每当我从 JSP 执行下面的代码时,我都会收到下面所述的错误,但是在普通的 Java App 中它可以正常工作而没有任何错误?
这是 JSP 的错误吗?或者有没有其他方法可以在 JSP 中调用它?
<%@page import="oshi.hardware.HardwareAbstractionLayer"%>
<%@page import="oshi.software.os.OperatingSystem"%>
<%@page import="oshi.SystemInfo"%>
<%
SystemInfo si = new SystemInfo();
OperatingSystem os = si.getOperatingSystem();
HardwareAbstractionLayer hal = si.getHardware();
out.println(hal.getProcessor());
%>
错误是:
Warning: StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception
java.lang.NoSuchMethodError: com.sun.jna.IntegerType.<init>(IJZ)V
at com.sun.jna.platform.win32.WinDef$DWORD.<init>(WinDef.java:135)
at com.sun.jna.platform.win32.WinDef$DWORD.<init>(WinDef.java:125)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at java.lang.Class.newInstance(Class.java:442)
at com.sun.jna.NativeMappedConverter.defaultValue(NativeMappedConverter.java:47)
at com.sun.jna.NativeMappedConverter.<init>(NativeMappedConverter.java:41)
at com.sun.jna.NativeMappedConverter.getInstance(NativeMappedConverter.java:29)
at com.sun.jna.Structure.calculateSize(Structure.java:717)
at com.sun.jna.Structure.allocateMemory(Structure.java:251)
at com.sun.jna.Structure.<init>(Structure.java:153)
at com.sun.jna.Structure.<init>(Structure.java:143)
at com.sun.jna.Structure.<init>(Structure.java:139)
at com.sun.jna.Structure.<init>(Structure.java:130)
at com.sun.jna.platform.win32.WinBase$MEMORYSTATUSEX.<init>(WinBase.java:595)
at oshi.hardware.platform.windows.WindowsGlobalMemory.<init>(WindowsGlobalMemory.java:40)
at oshi.hardware.platform.windows.WindowsHardwareAbstractionLayer.getMemory(WindowsHardwareAbstractionLayer.java:50)
at org.apache.jsp.api.cpuload_jsp._jspService(cpuload_jsp.java:62)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:411)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:473)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:377)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:415)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:282)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
at java.lang.Thread.run(Thread.java:745)
请提出一些解决该问题的方法。