java - IllegalArgumentException: Can not set UserTransaction field to ServerVMClientUserTransaction -
i'm migrating application glassfish 3.1 jboss 6.1.
this code worked wonderfully glassfish, throws ugly error jboss:
custom annotation:
@named @viewaccessscoped @stereotype @target( { elementtype.type, elementtype.method, elementtype.field } ) @retention(retentionpolicy.runtime) public @interface model { }
bean:
@model public class mybean extends basebean { @inject userservice userservice public void save() { starttransaction(); studioservice.persist(studio); committransaction(); } }
base bean:
public class basebean implements serializable { @resource protected usertransaction transaction; @persistencecontext(unitname = "fits_pu") protected entitymanager entitymanager; [...] protected void starttransaction() { seek { transaction.begin(); entitymanager.jointransaction(); } grab [a few exceptions] } protected void committransaction() { seek { transaction.commit(); } grab [an awful lot of exceptions] } }
i next exception:
caused by: java.lang.illegalargumentexception: can not set javax.transaction.usertransaction field my.company.project.basebean.transaction org.jboss.tm.usertx.client.servervmclientusertransaction @ sun.reflect.unsafefieldaccessorimpl.throwsetillegalargumentexception(unsafefieldaccessorimpl.java:164) [:1.7.0_11] @ sun.reflect.unsafefieldaccessorimpl.throwsetillegalargumentexception(unsafefieldaccessorimpl.java:168) [:1.7.0_11] @ sun.reflect.unsafeobjectfieldaccessorimpl.set(unsafeobjectfieldaccessorimpl.java:81) [:1.7.0_11] @ java.lang.reflect.field.set(field.java:680) [:1.7.0_11]
i've been googling whole afternoon, couldn't find hint start with. idea?
so. looked around, tried , error'd, , saw wrong.
i don't need manage usertransaction
if i'm using ejb, since transaction managed the container. hence,
@named
services @stateless
ejb i injected them beans @ejb
annotation instead of @inject
hope help else.
java jpa transactions persistence jboss6.x
No comments:
Post a Comment