首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >InvocationTargetException:使用Aion Embedded AVM时Dapp调用失败

InvocationTargetException:使用Aion Embedded AVM时Dapp调用失败
EN

Stack Overflow用户
提问于 2019-03-22 05:15:44
回答 1查看 42关注 0票数 0

当我使用maven和嵌入式AVM调用我的合同时,我收到以下消息:

代码语言:javascript
复制
[ERROR] Failed to execute goal org.aion4j:aion4j-maven-plugin:0.5.0-beta1:call (default-cli) on project supercontract: Method call failed: InvocationTargetException: Dapp call failed. Code: FAILED, Reason: null -> [Help 1]

我刚刚编辑了您在mvn initialize项目时获得的HelloAvM合同。这是整个合同:

代码语言:javascript
复制
public class HelloAvm {
    // Voting App
    // 1. Users call a function to find out what the question is.
    // 2. They then call another function with their choice.
    // 3. Any use can call the results() function to find out what the current votes are.

    public static int questionNumber = 1;
    public static String questionString = "Is Haggis a real animal?";

    public String getQuestion() {
        return "Question #" + questionNumber + ": " + questionString;
    }

    public void testContract() {
        // This function just returns a string to show that the contract is working.
        BlockchainRuntime.println("This contract is working.");
    }

    public static byte[] main() {
        return ABIDecoder.decodeAndRunWithClass(HelloAvm.class, BlockchainRuntime.getData());
    }
}

我不确定它为什么会失败,错误消息也没有多大用处。我看过StackOverflow上的其他InvocationTargetException错误,但它们似乎对这个问题没有帮助。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-03-26 22:56:08

我自己想出来的。显然,您需要将每个函数设置为static for Java contracts。因此,上面的getQuestiontestContract应该如下所示:

代码语言:javascript
复制
public static String getQuestion() {
        return "Question #" + questionNumber + ": " + questionString;
    }

    public static void testContract() {
        // This function just returns a string to show that the contract is working.
        BlockchainRuntime.println("This contract is working.");
    }
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55289368

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档