1
我正在將應用程序從GlassFish 3.1遷移到JBoss 6.1。IllegalArgumentException:無法將UserTransaction字段設置爲ServerVMClientUserTransaction
此代碼在GlassFish表現的很出色,但拋出一個醜陋的錯誤與JBoss:
自定義註釋:
@Named
@ViewAccessScoped
@Stereotype
@Target({ ElementType.TYPE, ElementType.METHOD, ElementType.FIELD })
@Retention(RetentionPolicy.RUNTIME)
public @interface Model {
}
豆:
@Model
public class MyBean extends BaseBean {
@Inject
UserService userService
public void save() {
startTransaction();
studioService.persist(studio);
commitTransaction();
}
}
基地豆:
public class BaseBean implements Serializable {
@Resource
protected UserTransaction transaction;
@PersistenceContext(unitName = "fits_PU")
protected EntityManager entityManager;
[...]
protected void startTransaction() {
try {
transaction.begin();
entityManager.joinTransaction();
} catch [a few exceptions]
}
protected void commitTransaction() {
try {
transaction.commit();
} catch [an awful lot of exceptions]
}
}
我得到以下異常:
Caused by: java.lang.IllegalArgumentException: Can not set javax.transaction.UserTransaction field my.company.project.BaseBean.transaction to org.jboss.tm.usertx.client.ServerVMClientUserTransaction
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:164) [:1.7.0_11]
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:168) [:1.7.0_11]
at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81) [:1.7.0_11]
at java.lang.reflect.Field.set(Field.java:680) [:1.7.0_11]
我已經整個下午谷歌搜索,但沒有找到任何線索開始。任何想法?