Skip to content

Errors in Web3j-Generated Wrapper Classes: "Cannot find symbol: class LinkReference" and Incorrect Package Name #2139

Open
@abdul-mueed-shz

Description

@abdul-mueed-shz

Title:
Errors in Web3j-Generated Wrapper Classes: "Cannot find symbol: class LinkReference" and Incorrect Package Name


Body:

I'm working on a Spring Boot project that interacts with Ethereum smart contracts. I'm using Web3j to compile Solidity contracts and generate ABI, binary files, and Java wrapper classes. However, the generated wrapper classes contain the following issues:

  1. Compilation Error:

    /home/abdulmueedshahbaz/springboot/eth/eth/src/main/java/generated/com/zuehlke/blockchain/model/HelloWorld.java:204:51
    java: cannot find symbol
      symbol:   class LinkReference
      location: class org.web3j.tx.Contract
    

    This error suggests that the class LinkReference is missing in the generated code.

Due to this issue, I'm unable to run my Spring Boot application.

My Setup:

Dependencies (Maven):

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>
    <dependency>
        <groupId>org.web3j</groupId>
        <artifactId>core</artifactId>
        <version>5.0.0</version>
    </dependency>
    <dependency>
        <groupId>org.web3j</groupId>
        <artifactId>crypto</artifactId>
        <version>5.0.0</version>
    </dependency>
    <dependency>
        <groupId>org.web3j</groupId>
        <artifactId>utils</artifactId>
        <version>5.0.0</version>
    </dependency>
    <dependency>
        <groupId>org.web3j</groupId>
        <artifactId>abi</artifactId>
        <version>5.0.0</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.18.2</version>
    </dependency>
</dependencies>

Build Plugins (Maven):

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>org.web3j</groupId>
            <artifactId>web3j-maven-plugin</artifactId>
            <version>4.12.3</version>
            <configuration>
                <packageName>com.zuehlke.blockchain.model</packageName>
                <sourceDestination>src/main/java/generated</sourceDestination>
                <nativeJavaType>true</nativeJavaType>
                <outputFormat>java,bin</outputFormat>
                <soliditySourceFiles>
                    <directory>src/main/resources/solidity/</directory>
                    <includes>
                        <include>**/*.sol</include>
                    </includes>
                </soliditySourceFiles>
                <outputDirectory>
                    <java>src/main/java/generated</java>
                    <bin>src/bin/generated</bin>
                    <abi>src/abi/generated</abi>
                </outputDirectory>
                <contract>
                    <includes>
                        <include>HelloWorld</include>
                    </includes>
                    <excludes>
                        <exclude>mortal</exclude>
                    </excludes>
                </contract>
                <pathPrefixes>
                    <pathPrefix>dep=../dependencies</pathPrefix>
                </pathPrefixes>
            </configuration>
        </plugin>
    </plugins>
</build>

Steps I Followed:

  1. Added my Solidity files to src/main/resources/solidity/.
  2. Ran mvn generate-sources to generate the ABI, binary, and wrapper classes.
  3. Attempted to build and run the application.

Issues:

  1. The HelloWorld.java wrapper class references a LinkReference class, which does not seem to exist in org.web3j.tx.Contract.

Question:

  • How can I resolve the missing LinkReference error in the Web3j-generated wrapper classes
  • Are there any known compatibility issues between Web3j (v5.0.0) and Solidity contracts?

Any guidance would be greatly appreciated!


Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-reviewissue/PR needs review from maintainer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions