简体   繁体   English

如何调试beanshell脚本?

[英]How to debug a beanshell script?

I have troubles to debug a beanshell script all I get all the time is: 调试一个我总是得到的beanhell脚本有麻烦:

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

Called from method: initMissingImportSources : at Line: -1 : in file: : Target exception: java.lang.reflect.InvocationTargetException 从方法调用:initMissingImportSources:at Line:-1:in file :: Target exception: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)

I am trying to retrieve the full stack trace with this code 我试图用这段代码检索完整的堆栈跟踪

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

Is there a possibility to retrieve the causing exception? 是否有可能检索导致的异常?

Thanks a lot. 非常感谢。

What is you "ExceptionUtils.getFullStackTrace()" really doing? 你是什​​么“ExceptionUtils.getFullStackTrace()”真的在做什么? Are you sure it's printing the nested exception? 你确定它打印嵌套异常吗?

Thanks a lot for the reply. 非常感谢您的回复。 Yes the getFullStackTrace is from apache commons and should work. 是的,getFullStackTrace来自apache commons并且应该可以工作。 I found the problem. 我发现了这个问题。 The point is here that I didnt have the complete script in one method call. 关键在于我在一个方法调用中没有完整的脚本。 This is important, only then you are able to surround it with a try catch and see the exception. 这很重要,只有这样你才能用try catch包围它并查看异常。 Hope that will helpful for the others in the future too. 希望将来对其他人也有帮助。 I see the exception now. 我现在看到例外。 I had several methods calling each other. 我有几种方法相互呼唤。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM