I have a contract:

pragma solidity ^0.4.0;
contract qualification {

address owner;

/* This function is executed at initialization and sets the owner of the contract */
function qualification() { owner = msg.sender; }

/* Function to recover the funds on the contract */
function kill() { if (msg.sender == owner) selfdestruct(owner); }


contract credentials is qualification {

    string studentName;
    string studentEmail;
    string studentUniversity;
    string studentCourse;
    string studentStart;
    string studentEnd;
    string studentClassification;

/* This runs when the contract is executed */
function credentials(string _name, string _email, string _university, string _course, string _start, string _end, string _classification) public {
    studentName = _name;
    studentEmail = _email;
    studentUniversity = _university;
    studentCourse = _course;
    studentStart = _start;
    studentEnd = _end;
    studentClassification = _classification;

/* Main function */
function returnQualification() constant returns (string, string, string, string, string, string, string) {
    return (studentName, studentEmail, studentUniversity, studentCourse, studentStart, studentEnd, studentClassification);

That I want to deploy from my Java class,

Thread t = new Thread(new Runnable() {
                public void run() {
                    Web3j web3j = Web3j.build(new HttpService());

                    try {
                        com.example.QualificationAuthenticator.Credentials contract = com.example.QualificationAuthenticator.Credentials.deploy(web3j, creds, Contract.GAS_PRICE, Contract.GAS_LIMIT, record.getStudentName(), record.getStudentEmail(), "uuj", record.getCourseName(), "date", "date2   ", record.getClassification()).send();

                    } catch (Exception e) {

            try {
            } catch (InterruptedException e) {
                System.out.println("thread couldnt finish");

This wont work and I get the error:

java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at org.web3j.tx.Contract.deploy(Contract.java:302) at org.web3j.tx.Contract.lambda$deployRemoteCall$5(Contract.java:334) at org.web3j.protocol.core.RemoteCall.send(RemoteCall.java:30)

..and more lines of error

However if I put the deploy call inside of my Main thread then the contract deploys fine.

  • Apologies..I was passing a null value for credentials. Duh – Hughes_J Mar 20 '18 at 20:40

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.