Aion4j Tips —Exception Stack Trace during method call in Embedded AVM

3 min readJun 14, 2019


Stack Traces are one of the most common things we run into while doing Java development. The stack trace provides more details when there is an exception during a method call. It contains all invocations from the start of a thread until the point it’s generated. So stack traces are very useful while debugging an error condition.

Some of the stack trace or details are suppressed in default setting for Embedded AVM in IntelliJ or Aion4j Maven Plugin. So if there is an exception during a method call while testing on Embedded AVM, it doesn’t provide enough information about the exception root cause.

For example,

Let’s say, I have the following method in my smart contract. I am just storing a key, value pair in this method.

public static void setValue(String key, String value) {
Blockchain.putStorage(key.getBytes(), value.getBytes());

When I call this method from IntelliJ IDE with key as “name” and value as “satya”, I get the following error log.

This is a generic error information and it’s impossible to find the root cause from this error stack.

But if you want more verbose information, you need to enable “Verbose Contract Error” option from
Aion Virtual Machine -> Configuration -> Embedded AVM context menu.

Now, re-deploy your smart contract and try to call the method again from IntelliJ.

For my smart contract, now I get the following error stack trace which clearly shows the root cause of this error.

“Key must be 32 bytes”

Similarly, you can set the following options for Embedded AVM in IntelliJ

  • “Verbose Concurrent Executor” option to get information about AVM Executor threads.
  • “Preserve Debug Mode” option to enable debug option. (If you plan to use this option, make sure you deploy the contract in debug mode before method invocation. Check this post for details on how to debug a smart contract.)

Aion4j Maven Plugin

But if you prefer command line and use maven commands directly, you can pass following options with aion4j:deploy and aion4j:call while working with embedded AVM.

  • -DenableVerboseContractErrors. : To get verbose error information
  • -DenableVerboseConcurrentExecutor : To get AVM Executor thread information.
  • -DpreserveDebuggability : To enable debug option (Check this post for details on how to debug.)


$>  mvn aion4j:call -Dmethod=setValue -Dargs="-T name -T satya" -DenableVerboseContractErrors -DenableVerboseConcurrentExecutor