如何调试beanshell脚本?

时间:2009-01-23 23:13:27

标签: debugging beanshell

调试一个我总是得到的beanhell脚本有麻烦:

异常调用导入的对象方法。 :at line:194:in file:inline evaluation of:``import java.lang.reflect.InvocationTargetException; import java.util.Arrays;一世 。 。 。 '':migrateModels(models,apiManager,isSAPRetailImportCondition,isSAPAFSCondition)

从方法调用:initMissingImportSources:at Line:-1:in file :: 目标异常:java.lang.reflect.InvocationTargetException

at bsh.BshMethod.invoke(Unknown Source)
at bsh.BshMethod.invoke(Unknown Source)
at bsh.Name.invokeLocalMethod(Unknown Source)
at bsh.Name.invokeMethod(Unknown Source)
at bsh.BSHMethodInvocation.eval(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.BSHBlock.evalBlock(Unknown Source)
at bsh.BSHBlock.eval(Unknown Source)
at bsh.BshMethod.invokeImpl(Unknown Source)
at bsh.BshMethod.invoke(Unknown Source)
at bsh.BshMethod.invoke(Unknown Source)
at bsh.This.invokeMethod(Unknown Source)
at ImportSourceMigration.initMissingImportSources(BeanShell Generated via ASM (www.objectweb.org))
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at bsh.Reflect.invokeMethod(Unknown Source)
at bsh.Reflect.invokeObjectMethod(Unknown Source)
at bsh.Name.invokeMethod(Unknown Source)
at bsh.BSHMethodInvocation.eval(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.BSHBlock.evalBlock(Unknown Source)
at bsh.BSHBlock.eval(Unknown Source)
at bsh.BSHBlock.eval(Unknown Source)
at bsh.BSHTryStatement.eval(Unknown Source)
at bsh.Interpreter.eval(Unknown Source)
at bsh.Interpreter.eval(Unknown Source)
at bsh.Interpreter.eval(Unknown Source)
at bsh.servlet.BshServlet.evalScript(Unknown Source)
at bsh.servlet.BshServlet.doGet(Unknown Source)

我正在尝试使用此代码检索完整的堆栈跟踪

    try {
        migration.initMissingImportSources();
    } catch (java.lang.Throwable e) {
        print(ExceptionUtils.getFullStackTrace(e));
    }

是否有可能检索导致的异常?

非常感谢。

2 个答案:

答案 0 :(得分:1)

你是什么“ExceptionUtils.getFullStackTrace()”真的在做什么?你确定它打印了嵌套异常吗?

答案 1 :(得分:1)

非常感谢你的回复。是的,getFullStackTrace来自apache commons并且应该可以工作。我发现了这个问题。关键在于我在一个方法调用中没有完整的脚本。这很重要,只有这样你才能用try catch包围它并查看异常。希望将来对其他人也有帮助。我现在看到例外。我有几种方法互相呼唤。