Tomcat v 7 と Jess v 7.0 を使用しています
これは私が得ている例外です
root cause
javax.servlet.ServletException: java.lang.NoSuchMethodError: uges.servlets.MyQuery: method <init>()V not found
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.jav a:911)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:840)
org.apache.jsp.catalog_jsp._jspService(catalog_jsp.java:121)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause
java.lang.NoSuchMethodError: uges.servlets.MyQuery: method <init>()V not found
org.apache.jsp.catalog_jsp._jspService(catalog_jsp.java:69)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
これはクラス MyQuery パッケージ uges.servlets; のソース コードです。
import jess.*;;
public class MyQuery
{
private static QueryResult result;
public MyQuery(Rete engine) throws JessException
{
getQuery(engine);
}
public QueryResult getQuery(Rete engine) throws JessException
{
result = engine.runQueryStar("all-products", new ValueVector());
return result;
}
public String getString(String str) throws JessException
{
String srtResult;
srtResult = result.getString(str);
return srtResult;
}
public Float getFloat(String str) throws JessException
{
float flt;
flt = result.getFloat(str);
return flt;
}
public boolean next() throws JessException
{
boolean next;
next = result.next();
return next;
}
}
これは Catalog Servlet パッケージ uges.servlets です。
import jess.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Catalog extends BaseServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
checkInitialized();
try {
String customerId =
(String) request.getParameter("customerId");
if (customerId == null || customerId.length() == 0) {
dispatch(request, response, "/index.html");
return;
}
request.getSession().invalidate();
HttpSession session = request.getSession();
session.setAttribute("customerId", customerId);
session.setAttribute("orderNumber",
String.valueOf(getNewOrderNumber()));
ServletContext servletContext = getServletContext();
Rete engine = (Rete) servletContext.getAttribute("engine");
//engine.reset();
MyQuery result = new MyQuery(engine);
//engine.runQueryStar("all-products", new ValueVector());
request.setAttribute("queryResult",result);
} catch (JessException je) {
throw new ServletException(je);
}
dispatch(request, response, "/catalog.jsp");
}
private int getNewOrderNumber() throws JessException {
ServletContext servletContext = getServletContext();
Rete engine = (Rete) servletContext.getAttribute("engine");
int nextOrderNumber =
engine.executeCommand("(get-new-order-number)").intValue(null);
return nextOrderNumber;
}
public void destroy() {
try {
ServletContext servletContext = getServletContext();
Rete engine = (Rete) servletContext.getAttribute("engine");
String factsFileName =
servletContext.getInitParameter("factsfile");
File factsFile = new File(factsFileName);
File tmpFile =
File.createTempFile("facts", "tmp", factsFile.getParentFile());
engine.executeCommand("(save-facts " + tmpFile.getAbsolutePath() +
" order recommend line-item next-order-number)");
factsFile.delete();
tmpFile.renameTo(factsFile);
} catch (Exception je) {
// Log error
}
}
}
JSP catalog.jsp
<HTML>
<%@ page import="jess.*" %>
<jsp:useBean id="queryResult" class="uges.servlets.MyQuery" scope="request"/>
<HEAD>
<TITLE>Ordering from Tekmart.com</TITLE>
</HEAD>
<BODY>
<H1>Tekmart.com Catalog</H1>
Select the items you wish to purchase and press "Check Order" to continue.
<FORM action="/Order/recommend" method="POST">
<TABLE border="1">
<TR><TH>Name</TH>
<TH>Catalog #</TH>
<TH>Price</TH>
<TH>Purchase?</TH>
</TR>
<% while (queryResult.next()) {
String partNum =
queryResult.getString("part-number");%>
<TR>
<TD><%= queryResult.getString("name") %></TD>
<TD><%= queryResult.getString("part-number") %></TD>
<TD><%= queryResult.getFloat("price") %></TD>
<TD><INPUT type="checkbox" name="items"
value=<%= '"' + partNum + '"'%>></TD>
</TR>
<% } %>
</TABLE>
<INPUT type="submit" value="Check Order">
</FORM>
</BODY>
</HTML>
手がかりをいただければ幸いです。ありがとう、