-
1. Re: Demarshalling fails on null enum value
csa Nov 1, 2012 12:21 PM (in response to nva)Thanks, Valentin. This is fixed now in the latest 2.2.0-SNAPSHOTs.
-
2. Re: Demarshalling fails on null enum value
lewarrior22 Nov 7, 2012 4:06 AM (in response to csa)Hi, Just got the same problem with int property.
//When using this, The demarchalling Fail (Note the use of int id ), I have an Demarchalling Error; message = null and exception class is ResponseException.
@Portable
@Bindable
public class Account {
private int id ;
private String name ;
@NotNull
private String login ;
@NotNull
private String password ;
private String email ;
@NotNull
private String website ;
public Account() {
}
public Account(int id, String name, String login, String password,
String email, String website) {
super();
this.id = id;
this.name = name;
this.login = login;
this.password = password;
this.email = email;
this.website = website;
}
//getters + setters
//toString
}
//And when I use this bean everything is correct.
/**
* @author boris
*
*/
@Portable
@Bindable
public class Account {
private String name ;
@NotNull
private String login ;
@NotNull
private String password ;
private String email ;
@NotNull
private String website ;
public Account() {
// TODO Auto-generated constructor stub
}
public Account(int id, String name, String login, String password,
String email, String website) {
super();
this.name = name;
this.login = login;
this.password = password;
this.email = email;
this.website = website;
}
//getters + setters//toString
}
-
3. Re: Demarshalling fails on null enum value
nva Nov 7, 2012 2:36 AM (in response to lewarrior22)Hi Boris, does it also happen when you change your 'int' field to 'Integer'? Java primitives do not support null values and 'int a = null' will always give you a null pointer exception.
Cheers,
V.
-
4. Re: Demarshalling fails on null enum value
lewarrior22 Nov 8, 2012 10:13 AM (in response to nva)Hi,
Yeah, the same problem occur, event with Long and Integer. It work fine only with String values. If I can post my code here :@Portable
@Bindable
publicclass Account {
private Long id ;
private String name ;
@NotNull
private String login ;
@NotNull
private String password ;
private String email ;
@NotNull
private String website ;
public Account() {
// TODO Auto-generated constructor stub
}
public Account(Long id, String name, String login, String password,
String email, String website) {
super();
this.id = id;
this.name = name;
this.login = login;
this.password = password;
this.email = email;
this.website = website;
}
//getters and setters , toString()
}
//in the sample.local.share package
@Path("/accounts")
public interface AccountRESTService {
@POST
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Account create(Account account) ;
@PUT
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Account update(Account account) ;
//others methods
}
//and the implementation in the .sample.rest
public class SimpleAccountRESTService implements AccountRESTService{
@Override
public Account create(Account account) {
System.out.println("Account Received From client "+account);
account.setName("creation success");
return account;
}
@Override
public Account update(Account account) {
System.out.println("\n Account Received For Update client "+account);
account.setName("update success");
return account;
}
//others methods implementations
}
//here is how .sample.client.local
@Templated("#createAccountView")
public class CreateAccountView extends Composite {
@Inject
@Bound
@DataField
private TextBox id ;
@Inject
@Bound
@DataField
private TextBox name ;
//..others TextBox
@Inject
@AutoBound
private DataBinder<Account> accountDataBinder ;
@Inject
private Caller<AccountRESTService> accountRestServiceCaller ;
@EventHandler("btnSave")
public void onBtnSaveClicked(ClickEvent click){
//use the model to retrieve data from the form
Account account = accountDataBinder.getModel();
Window.alert("Save acount "+account+" \n path"+RestClient.getApplicationRoot());
RemoteCallback<Account> remoteCallback = new RemoteCallback<Account>() {
@Override
public void callback(Account response) {
Window.alert("Account Created from server !"+response);
}
};
ErrorCallback errorCallback = new ErrorCallback() {
@Override
publicboolean error(Message message, Throwable throwable) {
if(throwable instanceof TransportIOException){
Window.alert("Could Reach the server : ["+message+"] \n and ["+throwable+"]" );
}else {
Window.alert("Marschalling errors ["+message+"] \n and ["+throwable+"]" );
}
returnt rue;
}
};
RestClient.setJacksonMarshallingActive(true);
accountRestServiceCaller.call(remoteCallback, errorCallback).create(account);
Account update = accountRestServiceCaller.call(remoteCallback,errorCallback).update(account)
}
}
I have my System.out.println() in JbossAS7's console. but I can't retrieve the returned account in the remoteCallBack object. @See the errorCallBack.
Now I waiting the version 2.2.0.SNAPSHOT been released ! And try again.
Thanks,