Can not set java.lang.Integer field Xyz.id to Xyz - IllegalArgumentException
zemunk Apr 4, 2012 6:49 AMHello,
I came across this error while trying to persist some values. Since I am new to the technology and the project was developed by someone else, I have difficulties in finding the source of the problem.
Here is the entity class:
@Entity
@Table(schema = "webshop_statistik", name = "adressStatistik")
@SequenceGenerator(name = "adressStatistik_id_seq", sequenceName = "webshop_statistik.adressstatistik_id_seq")
public class AdressStatistik {
/**
* automatisch vortlaufend erzeugter Primary Key
*/
@Id
@GeneratedValue(generator = "adressStatistik_id_seq")
private Integer id;
@Column(length = 50)
private String ort;
...
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getOrt() {
return ort;
}
public void setOrt (String ort) {
this.ort = ort;
}
...
}
and the calling method:
@Stateless@WebService
@WebContext(authMethod="BASIC", secureWSDLAccess=false)
@SecurityDomain("gfo")
@RolesAllowed({"webshop"})
public class Statistikmgmt implements IStatistikmgmt {
@PersistenceContext(unitName="gfo_pu")
private EntityManager em;
...
@SuppressWarnings({ "unchecked"})
@WebMethod
@Override
public void persistAdressStatistik(@WebParam(name="adressStatistik")AdressStatistik a){
...
em.persist(a); // the exception is thrown here
...
}
}
I get the same error for other beans as well. Here is a part of the error log:
13:24:12,311 ERROR [org.jboss.ejb3.invocation] (http-localhost-127.0.0.1-8080-6) JBAS014134: EJB Invocation failed on component Statistikmgmt for method public void de.intern.webservices.Statistikmgmt.persistAdressStatistik(de.webshop_statistik.bean.entity.AdressStatistik): javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of de.webshop_statistik.bean.entity.AdressStatistik.id
...
13:24:12,372 ERROR [org.jboss.as.webservices.invocation.InvocationHandlerEJB3] (http-localhost-127.0.0.1-8080-6) Method invocation failed with exception: javax.persistence.PersistenceException: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of de.webshop_statistik.bean.entity.AdressStatistik.id: javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of de.webshop_statistik.bean.entity.AdressStatistik.id
...
13:24:12,431 WARNUNG [org.apache.cxf.phase.PhaseInterceptorChain] (http-localhost-127.0.0.1-8080-6) Application {http://webservices.intern.de/}StatistikmgmtService#{http://webservices.intern.de/}persistAdressStatistik has thrown exception, unwinding now: org.apache.cxf.interceptor.Fault: javax.persistence.PersistenceException: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of de.webshop_statistik.bean.entity.AdressStatistik.id
...
...
Caused by: java.lang.IllegalArgumentException: Can not set java.lang.Integer field de.webshop_statistik.bean.entity.AdressStatistik.id to de.webshop_statistik.bean.entity.AdressStatistik
The project is already working under Jboss 5 and is now in the process of being deployed to Jboss 7.1.
Thank you for helping me out!