0

我正在使用 symja-0.0.7a.jar 进行代数表达式评估。它在独立的 java 应用程序中工作。但是,当我使用 Tomcat 和 Eclipse 在服务器中运行时,出现以下错误...

workingExp: (4p * 2) + (8q * 2)
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at core.MarkAns.doGet(MarkAns.java:53)
    at core.MarkAns.doPost(MarkAns.java:76)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.NoClassDefFoundError: org/matheclipse/parser/client/SyntaxError
    at core.MarkWorkingsLessThanSoln.checkAlgebraEvaluator(MarkWorkingsLessThanSoln.java:126)
    at core.MarkWorkingsLessThanSoln.checkWorkingLessThanSoln(MarkWorkingsLessThanSoln.java:71)
    at core.MarkAns.gradePaper(MarkAns.java:153)
    ... 24 more
Caused by: java.lang.ClassNotFoundException: org.matheclipse.parser.client.SyntaxError
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
    ... 27 more

下面是用于调用方法的类文件之一中使用的代码...

import static org.matheclipse.core.expression.F.*;

import org.matheclipse.core.basic.Config;
import org.matheclipse.core.eval.EvalUtilities;
import org.matheclipse.core.interfaces.IAST;
import org.matheclipse.core.interfaces.IExpr;
import org.matheclipse.parser.client.SyntaxError;
import org.matheclipse.parser.client.math.MathException;

public class EvalExpand {
  public void EvalAlgebra() {
    // Static initialization of the MathEclipse engine instead of null 
    // you can set a file name to overload the default initial
      try {
            EvalUtilities util = new EvalUtilities(false, true);
            // Show an expression in the Java form:
            String javaForm = util.toJavaForm("d(sin(x)*cos(x),x)");
            // prints: D(Times(Sin(x),Cos(x)),x)
            System.out.println(javaForm.toString());

            // Use the Java form to create an expression with F.* static methods:
            IAST function = D(Times(Sin(x), Cos(x)), x);
            IExpr result = util.evaluate(function);
            // print: -Sin(x)^2+Cos(x)^2
            System.out.println(result.toString());

            // evaluate the string directly
            result = util.evaluate("d(sin(x)*cos(x),x)");
            // print: -Sin(x)^2+Cos(x)^2
            System.out.println(result.toString());

            // evaluate the last result ($ans contains "last answer")
            result = util.evaluate("$ans+cos(x)^2");
            // print: -Sin(x)^2+2*Cos(x)^2
            System.out.println(result.toString());

            // evaluate an Integrate[] expression
            result = util.evaluate("integrate(sin(x)^5,x)");
            // print: -1/5*Cos(x)^5+2/3*Cos(x)^3-Cos(x)
            System.out.println(result.toString());

            // Use [...] for function arguments instead of (...) and upper case names for predefined functions (i.e. Sin[...]
            // instead of sin[...]).
            EvalUtilities util2 = new EvalUtilities(false, false);

            if (Config.PARSER_USE_LOWERCASE_SYMBOLS) {
                // If true the parser doesn't distinguish between lower- or uppercase predefined symbols
                result = util2.evaluate("integrate[sin[x]^5,x]");
            } else {
                result = util2.evaluate("Integrate[Sin[x]^5,x]");
            }
            // print: -1/5*Cos(x)^5+2/3*Cos(x)^3-Cos(x)
            System.out.println(result.toString());

        } catch (SyntaxError e) {
            // catch Symja parser errors here
            System.out.println(e.getMessage());
        } catch (MathException me) {
            // catch Symja math errors here
            System.out.println(me.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
        } 

    }     

  }

有好心人能帮忙吗?我一直在尝试各种方法,但无济于事。

谢谢!

4

0 回答 0