Установка: Windows 10 Pro 64 bit, IntelliJ IDEA 2018, JBoss WebServer
Я довольно новичок в Java и JSP, хотя благодаря исследованиям и многому прочтению я смог придумать следующий код, которыйреализует библиотеки Digital Persona для информирования пользователя о том, подключен ли сканер к его компьютеру:
package com.digitalpersona.sample;
import com.digitalpersona.onetouch.DPFPGlobal;
import com.digitalpersona.onetouch.readers.DPFPReaderDescription;
import com.digitalpersona.onetouch.readers.DPFPReadersCollection;
public class ListReaders {
public static String readerStatus() {
String response = "";
DPFPReadersCollection readers = DPFPGlobal.getReadersFactory().getReaders();
if (readers == null || readers.size() == 0) {
response = "There are no readers available.";
}
for (DPFPReaderDescription readerDescription : readers)
response = readerDescription.getSerialNumber();
return response;
}
}
Приведенный выше код работает нормально, когда я запускаю его независимо на IntelliJ, но у меня возникают проблемы с вызовом readerStatus () метод из файла JSP.Когда я пытаюсь это:
<%@ page import="com.digitalpersona.sample.*" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>List Readers</title>
</head>
<body>
<%
ListReaders deviceStatus = new ListReaders();
out.println(deviceStatus);
%>
</body>
</html>
я получаю это:
com.digitalpersona.sample.ListReaders@133d1476
или
com.digitalpersona.sample.ListReaders@71f2d51b
или
com.digitalpersona.sample.ListReaders@1c272943
По сути,последние 8 символов постоянно меняются.И когда я попробую это:
<%@ page import="com.digitalpersona.sample.*" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>List Readers</title>
</head>
<body>
<%
ListReaders deviceStatus = new ListReaders();
String responseMessage = deviceStatus.readerStatus();
out.println(responseMessage);
%>
</body>
</html>
Результат будет таким:
Error processing request
Context Path:/HelloWorld_war_exploded
Servlet Path:/listreaders.jsp
Path Info:null
Query String:null
Stack Trace:
javax.servlet.ServletException: java.lang.NoSuchMethodError: com.digitalpersona.sample.ListReaders.readerStatus()Ljava/lang/String;
at org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:889)
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:818)
at org.apache.jsp.listreaders_jsp._jspService(listreaders_jsp.java:118)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:403)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:347)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
at io.undertow.jsp.JspFileHandler.handleRequest(JspFileHandler.java:32)
at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at org.wildfly.extension.undertow.deployment.GlobalRequestControllerHandler.handleRequest(GlobalRequestControllerHandler.java:68)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)
at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
at org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:326)
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:812)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NoSuchMethodError: com.digitalpersona.sample.ListReaders.readerStatus()Ljava/lang/String;
at org.apache.jsp.listreaders_jsp._jspService(listreaders_jsp.java:101)
... 45 more
Может кто-нибудь, пожалуйста, помогите мне получить правильный вывод из:
return response;
Спасибозаранее.