The constructor is not visible (but it is)

1,137 views
Skip to first unread message

Geoffrey De Smet

unread,
Apr 20, 2017, 10:54:39 AM4/20/17
to RestyGWT
Using gwt 2.8.0, restygwt 2.2.0, gwtjackson 0.14.2 (all latest versions),
I am getting this error:
  [ERROR] Line 22: The constructor Employee() is not visible
But that constructor is visible:

public class Employee implements Serializable {

    private String name;

    private Employee() {
    }

    public Employee(String name) {
        this.name = name;
    }
    ...
}

Any idea what can cause this?



Full error message:

[INFO] --- gwt-maven-plugin:1.0-rc-6:compile (default-compile) @ employee-rostering-oaas-gwtui ---
[INFO] Compiling module org.optaplanner.openshift.workerrostering.gwtui.WorkerRosteringWebapp
[INFO]    Adding '2' new generated units
[INFO]       See snapshot: /tmp/org.optaplanner.openshift.workerrostering.domain.Employee_Generated_JsonEncoderDecoder_3932536815121640627.java
[INFO]       Ignored 1 unit with compilation errors in first pass.
[INFO] Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
[INFO]    [ERROR] Errors in 'generated://BA1D9DD7AB25C9820EE61BC007A1D0C2/org/optaplanner/openshift/workerrostering/domain/Employee_Generated_JsonEncoderDecoder_.java'
[INFO]       [ERROR] Line 22: The constructor Employee() is not visible
[INFO]       See snapshot: /tmp/org.optaplanner.openshift.workerrostering.domain.Employee_Generated_JsonEncoderDecoder_4842096055955344587.java
[INFO]    Tracing compile failure path for type 'org.optaplanner.openshift.workerrostering.domain.Employee_Generated_JsonEncoderDecoder_'
[INFO]       [ERROR] Errors in 'generated://BA1D9DD7AB25C9820EE61BC007A1D0C2/org/optaplanner/openshift/workerrostering/domain/Employee_Generated_JsonEncoderDecoder_.java'
[INFO]          [ERROR] Line 22: The constructor Employee() is not visible

David

unread,
Apr 21, 2017, 4:02:23 AM4/21/17
to RestyGWT

Gwt jackson is trying to use the private constructor.
Add a @JsonProperty("name") to the public constructor name parameter then it should work. Why do you even declare a private default constructor ?


--
You received this message because you are subscribed to the Google Groups "RestyGWT" group.
To unsubscribe from this group and stop receiving emails from it, send an email to restygwt+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Geoffrey De Smet

unread,
Apr 21, 2017, 4:57:36 AM4/21/17
to RestyGWT
(My previous mail had a bad copy paste - the constructor is public.)

Even with a public no-arg constructor and a public @JsonProperty constructor as shown below,
I am getting that error "Line 22: The constructor Employee() is not visible":


public class Employee implements Serializable {

    private String name;

    public Employee() {
    }

    public Employee(@JsonProperty("name") String name) {
        this.name = name;
    }
...
}

That weird.
Could it be due to the use of the latest GWT and latest gwtjackson releases (gwt 2.8.0, restygwt 2.2.0, gwtjackson 0.14.2)?
Reply all
Reply to author
Forward
0 new messages