Cannot persist simple entity with Hibernate when run in an OSGI server(Works in a standalone Java application) -


i starting use hibernate-jpa. not know in deep how works, though know jpa specification fair extent.

i have single entity address, has no relationships whatsoever. has primary key id has @generatedvalue annotation , 4 other fields. instantiated entitymanagerfactory, entitymanager, address object , called em.persist(address);

i error org.hibernate.propertyaccessexception: not field value reflection getter of com.sac.hbn.address.id.

i running in osgi server, when run in standalone application works without issues.

https://hibernate.atlassian.net/browse/hhh-9434 issue facing asker there mentioned when changed 4.3.6 4.3.5 worked him. me tried 4.3.2,4.3.5,4.3.6 gave me same behavior.

this stack trace getting.

caused by: javax.persistence.persistenceexception: org.hibernate.propertyaccessexception: not field value reflection getter of com.sac.hbn.address.id @ org.hibernate.jpa.spi.abstractentitymanagerimpl.convert(abstractentitymanagerimpl.java:1763) @ org.hibernate.jpa.spi.abstractentitymanagerimpl.convert(abstractentitymanagerimpl.java:1677) @ org.hibernate.jpa.spi.abstractentitymanagerimpl.convert(abstractentitymanagerimpl.java:1683) @ org.hibernate.jpa.spi.abstractentitymanagerimpl.persist(abstractentitymanagerimpl.java:1187) @ com.sac.hbn.triggerer.start(triggerer.java:46) @ org.eclipse.osgi.framework.internal.core.bundlecontextimpl$1.run(bundlecontextimpl.java:711) @ java.security.accesscontroller.doprivileged(native method) @ org.eclipse.osgi.framework.internal.core.bundlecontextimpl.startactivator(bundlecontextimpl.java:702) ... 8 common frames omitted

caused by: org.hibernate.propertyaccessexception: not field value reflection getter of com.sac.hbn.address.id @ org.hibernate.property.directpropertyaccessor$directgetter.get(directpropertyaccessor.java:60) @ org.hibernate.tuple.entity.abstractentitytuplizer.getidentifier(abstractentitytuplizer.java:346) @ org.hibernate.persister.entity.abstractentitypersister.getidentifier(abstractentitypersister.java:4746) @ org.hibernate.persister.entity.abstractentitypersister.istransient(abstractentitypersister.java:4465) @ org.hibernate.engine.internal.foreignkeys.istransient(foreignkeys.java:243) @ org.hibernate.event.internal.abstractsaveeventlistener.getentitystate(abstractsaveeventlistener.java:511) @ org.hibernate.event.internal.defaultpersisteventlistener.onpersist(defaultpersisteventlistener.java:116) @ org.hibernate.event.internal.defaultpersisteventlistener.onpersist(defaultpersisteventlistener.java:75) @ org.hibernate.internal.sessionimpl.firepersist(sessionimpl.java:811) @ org.hibernate.internal.sessionimpl.persist(sessionimpl.java:784) @ org.hibernate.internal.sessionimpl.persist(sessionimpl.java:789) @ org.hibernate.jpa.spi.abstractentitymanagerimpl.persist(abstractentitymanagerimpl.java:1181) ... 12 common frames omitted

caused by: java.lang.illegalargumentexception: can not set int field com.sac.hbn.address.id com.sac.hbn.address @ sun.reflect.unsafefieldaccessorimpl.throwsetillegalargumentexception(unsafefieldaccessorimpl.java:167) @ sun.reflect.unsafefieldaccessorimpl.throwsetillegalargumentexception(unsafefieldaccessorimpl.java:171) @ sun.reflect.unsafefieldaccessorimpl.ensureobj(unsafefieldaccessorimpl.java:58) @ sun.reflect.unsafeintegerfieldaccessorimpl.getint(unsafeintegerfieldaccessorimpl.java:56) @ sun.reflect.unsafeintegerfieldaccessorimpl.get(unsafeintegerfieldaccessorimpl.java:36) @ java.lang.reflect.field.get(field.java:387) @ org.hibernate.property.directpropertyaccessor$directgetter.get(directpropertyaccessor.java:57) ... 23 common frames omitted

and address class

import javax.persistence.entity; import javax.persistence.generatedvalue; import javax.persistence.id; import javax.persistence.table;  @entity @table(name = "address") public class address {   @id   @generatedvalue   private integer id;    private string street;   private string city;   private string province;   private string country;   private string postcode;    /**    * @return id    */   public integer getid() {     return id;   }    /**    * @param id id set    */   public address setid(integer id) {     this.id = id;     return this;   }    /**    * @return street    */   public string getstreet() {     return street;   }    /**    * @param street street set    */   public address setstreet(string street) {     this.street = street;     return this;   }    /**    * @return city    */   public string getcity() {     return city;   }    /**    * @param city city set    */   public address setcity(string city) {     this.city = city;     return this;   }    /**    * @return province    */   public string getprovince() {     return province;   }    /**    * @param province province set    */   public address setprovince(string province) {     this.province = province;     return this;   }    /**    * @return country    */   public string getcountry() {     return country;   }    /**    * @param country country set    */   public address setcountry(string country) {     this.country = country;     return this;   }    /**    * @return postcode    */   public string getpostcode() {     return postcode;   }    /**    * @param postcode postcode set    */   public address setpostcode(string postcode) {     this.postcode = postcode;     return this;   } } 

any idea why?

solution : worked through unexpected solution. thing there persistence provider eclipse link configured in server. tries pickup bundle has meta-persistence tag in manifest. not know how connected issue facing removed tag, started working!

i'm guessing setid (and other setters) must return void, , jpa implementation getting confused because don't. try changing them return void instead.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -