Corda Bi-Weekly FAQ’s #1

January 29, 2021

Occasionally we look to take some of the feedback we get most often and see if we can provide tips to help developers with everyday issues.

white markee light
(Photo by Jon Tyson on Unsplash)

Debugging import issues in CorDapps. 

 

Hey there! 

 

Occasionally we look to take some of the feedback we get most often and see if we can provide tips to help developers with everyday issues. 

 

We recently had a question where a developer couldn’t get their application to compile because of an import issue. It seemed like an import issue at first, but through some debugging, the problem became apparent. 

 

When writing CorDapps, our developers sometimes run into compilation issues, and the reason isn’t always apparent. For example, if you’re finding a java.lang.ClassNotFoundException or an import that fails to work even though the class name is right, there are a couple of things you can do to get your project to build correctly. Here are the steps that solve this issue most often. 

 

  • First, always make sure your machine is configured correctly
  • Next, make sure to look at your Gradle files. You may be missing a critical jar or dependency. I recommend developers to compare their build.Gradle files (and submodule build.Gradle files!) to the cordapp template in either java or kotlin.
  • Third, make sure your Corda nodes are getting the correct modules by default (for example, having cordapp project(‘: contracts’) propagate to all nodes is probably a good idea.)
  • Fourth, double check the configuration of CorDapps using the features you’re trying to get to work. Our sample repo has a lot of different options. For example, if you’re working on a SchedulableState CorDapp, the HeartBeat CorDapp would be an excellent resource for you. (Remember that all of our samples are in both java and kotlin.) 
  • Finally, it’s always possible that a Gradle clean and resync can get things back in order.

 

These kinds of structural issues are generally solved by trying to make sure that you’re following the CorDapp template guidelines. 

 

Some other things you can check if you’re looking for ideas on possible compilation problems: 

  • Gradle properties (we call the file constants.properties
  • Gradle wrapper version number
  • Make sure the class names and paths are correct 
  • Ensure your workflows Gradle file has a dependency on your contracts, but not the other way around 
  • Make sure your IDE is using the correct version of java (even if the system version is right; IntelliJ, for example, can manage multiple SDKs) 

 

Here are the links again to the templates in both java and kotlin

 

Hopefully, this is helpful and good luck with your debugging! 

 

If you’d like to see more blog posts like these or have ideas on what we should add, feel free to send a note to [email protected].


————————

Want to learn more about building awesome blockchain applications on Corda? Be sure to visit https://corda.net, check out our community page to learn how to connect with other Corda developers, and sign up for one of our newsletters for the latest updates.

— David Awad is a Developer Evangelist at R3, an enterprise blockchain software firm working with a global ecosystem of more than 350 participants across multiple industries from both the private and public sectors to develop on Corda, its open-source blockchain platform, and Corda Enterprise, a commercial version of Corda for enterprise usage.

Follow David on Twitter here.

Share: