kryptokrauts / contraect-maven-plugin

maven plugin to generate java classes for Sophia smart contracts using the ACI. the generated classes make use of the aepp-sdk-java and provide methods to deploy contracts and call entrypoints.
https://kryptokrauts.github.io/contraect-maven-plugin
ISC License
3 stars 0 forks source link

generate-contraects failed - required attribute codegen.compilerBaseUrl not set #43

Closed AJESH-CR closed 3 years ago

AJESH-CR commented 3 years ago

Description

While running mvn contraect:generate-contraects encountered with an error

Execution default-cli of goal com.kryptokrauts:contraect-maven-plugin:1.0.0:generate-contraects failed: org.apache.maven.plugin.MojoExecutionException: Required attribute codegen.compilerBaseUrl not set

pom.xml

<pluginRepositories>
  <pluginRepository>
    <id>jcenter</id>
    <url>http://jcenter.bintray.com</url>
  </pluginRepository>
</pluginRepositories>

<build>
    <plugins>
        <plugin>
                <groupId>com.kryptokrauts</groupId>
                <artifactId>contraect-maven-plugin</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <config></config>
                    <codegen>
                        <targetPath>${basedir}/src/main/java</targetPath>
                        <targetPackage>com.example.app.blockchain.contracts.java</targetPackage>
                        <datatypePackage>com.example.app.blockchain.contracts.java.datatypes</datatypePackage>
                        <directories>
                            <directory>${basedir}/src/main/java/com/example/app/blockchain/contracts/sophia</directory>
                        </directories>
                        <compilerBaseUrl>http://localhost:3080</compilerBaseUrl>
                    </codegen>
                </configuration>
                <executions>
                    <execution>
                        <id>generate-sources-aet</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>generate-contraects</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
    </plugins>
</build>

Failure logs

[INFO] --- contraect-maven-plugin:1.0.0:generate-contraects (default-cli) @ app ---
[INFO] ------------------------------------------------------------------------
[INFO] Starting kryptokrauts contraect generator
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  9.311 s
[INFO] Finished at: 2021-03-29T10:08:18+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.kryptokrauts:contraect-maven-plugin:1.0.0:generate-contraects (default-cli) on project app: Execution default-cli of goal com.kryptokrauts:contraect-maven-plugin:1.0.0:generate-contraects failed: org.apache.maven.plugin.MojoExecutionException: Required attribute codegen.compilerBaseUrl not set -> [Help 1]

Context

Ref

mitch-lbw commented 3 years ago

Hi AJESH-CR, thanks for using the contraect-maven-plugin :) The issue you face is due to an issue with your maven config: can you please delete the <config></config> within the configuration-tag and try again Regards, Mitch

AJESH-CR commented 3 years ago

Thanks for the support Mitch, Applied the fix, now I faced another issue

SEVERE: Unhandled exception
io.vertx.core.json.DecodeException: Failed to decode:Unrecognized field "external_encoded_aci" (class com.kryptokrauts.sophia.compiler.generated.model.ACI), not marked as ignorable (2 known properties: "interface", "encoded_aci"])
 at [Source: (io.netty.buffer.ByteBufInputStream); line: 1, column: 403] (through reference chain: com.kryptokrauts.sophia.compiler.generated.model.ACI["external_encoded_aci"])
        at io.vertx.core.json.Json.decodeValue(Json.java:156)
        at com.kryptokrauts.sophia.compiler.generated.ApiClient.lambda$buildResponseHandler$7(ApiClient.java:553)
        at io.vertx.ext.web.client.impl.HttpContext.handleDispatchResponse(HttpContext.java:286)
        at io.vertx.ext.web.client.impl.HttpContext.execute(HttpContext.java:273)

Thanks again Mitch.

marc0olo commented 3 years ago

Hi @AJESH-CR, sorry for the circumstances. This is a problem with the configuration of our SDK and will be fixed in upcoming versions. You are probably running or using the http compiler which has an updated endpoint that returns more attributes than expected.

You have two options in my opinion:

  1. run the http compiler locally (e.g. via docker) in the version we have used in our showcase application (there we have a docker-compose file which runs a local node and compiler)
  2. take a look at https://stackoverflow.com/a/25718495/2343286 and try to fix this via configuration in your application

Again, sorry! We are currently working on the 3.0.0 release which will fix this and also introduce some other breaking changes as well as support for new features that are coming with the Iris hardfork. (e.g. PayingForTx).

AJESH-CR commented 3 years ago

Thanks, marc0olo.

I got this issue while I run the HTTP compiler locally via docker using the below image

REPOSITORY                TAG                 IMAGE ID            CREATED             SIZE
aeternity/aesophia_http   latest              bb0dc6751804        9 months ago        180MB

And configured the URL http://localhost:3080 in the compilerBaseUrl element.

Edit 1

Thanks marc0olo & Mitch

marc0olo commented 3 years ago

glad you got it solved! :-)

stay tuned for upcoming updates. there will be some breaking changes and you shouldn't face this problem anymore by default