I have a simple java maven project whose pom.xml
looks like:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>poc</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<solidity.version>0.7.4</solidity.version>
</properties>
<dependencies>
<dependency>
<groupId>org.web3j</groupId>
<artifactId>core</artifactId>
<version>4.8.4</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.web3j</groupId>
<artifactId>web3j-maven-plugin</artifactId>
<version>4.6.5</version>
<configuration>
<soliditySourceFiles/>
</configuration>
</plugin>
</plugins>
</build>
</project>
As you can see I am using web3j library to interact with my blockchain and web3j maven plugin to convert my solidity files to java files.
When I run mvn web3j:generate-sources
, it successfully runs and converts the solidity files to java files. But when I run the main method of the project from the IDE, it fails with this error:
From the error message above, I tried removing the constructor from my solidity file and the pragma line, and then my project builds and runs fine as expected. So, I am thinking my java project is picking the wrong solidity version somehow.
Any tips/hints as to what may be going on here or how to fix this?