将jdk从1.6升级到jdk 1.7时,无法写入只读对象异常

时间:2015-12-30 07:34:38

标签: java hibernate web-services maven jboss

我正在尝试将现有应用程序(包含Web服务)从JDK_1.6迁移到1.7_79,并尝试将其部署到JBOSS 5.1中,但仍然遇到以下异常,无法找到任何解决方案。我无法弄清楚它正在尝试更新哪个只读对象。我间歇性地面对这个例外。应用程序适用于jdk 1.6。 有人可以告诉我这个问题......

该应用程序具有以下配置

  • Apache的行家-2.2.1
  • jboss-5.1.0.GA

异常追踪:

2015-12-30 05:38:11,938 WARN  [com.arjuna.ats.arjuna.logging.arjLoggerI18N] (tomcat-exec-2) [com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator_2] TwoPhaseCoordinator.beforeCompletion - failed for com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple@67c3fd26
javax.persistence.PersistenceException: java.lang.UnsupportedOperationException: Can't write to a readonly object
    at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:516)
    at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:101)
    at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:269)
    at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:89)
    at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:177)
    at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1423)
    at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:137)
    at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:75)
    at org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:170)
    at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:87)
    at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:190)
    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
    at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
    at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
    at org.jboss.ejb3.security.RoleBasedAuthorizationInterceptorv2.invoke(RoleBasedAuthorizationInterceptorv2.java:201)
    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
    at com.XYZ.framework.Ejb3AuthenticationInterceptorv2.invoke(Ejb3AuthenticationInterceptorv2.java:202)
    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
    at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:41)
    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
    at org.jboss.ejb3.BlockContainerShutdownInterceptor.invoke(BlockContainerShutdownInterceptor.java:67)
    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
    at org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67)
    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
    at org.jboss.ejb3.session.SessionSpecContainer.invoke(SessionSpecContainer.java:176)
    at org.jboss.ejb3.session.SessionSpecContainer.invoke(SessionSpecContainer.java:216)
    at org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:207)
    at org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:164)
    at com.sun.proxy.$Proxy1054.getPopulatedPrincipal(Unknown Source)
    at com.XYZ.login.UADLoginModule.getRoleSets(UADLoginModule.java:97)
    at org.jboss.security.auth.spi.AbstractServerLoginModule.commit(AbstractServerLoginModule.java:210)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at javax.security.auth.login.LoginContext.invoke(LoginContext.java:762)
    at javax.security.auth.login.LoginContext.access$000(LoginContext.java:203)
    at javax.security.auth.login.LoginContext$4.run(LoginContext.java:690)
    at javax.security.auth.login.LoginContext$4.run(LoginContext.java:688)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:687)
    at javax.security.auth.login.LoginContext.login(LoginContext.java:596)
    at org.jboss.security.plugins.auth.JaasSecurityManagerBase.defaultLogin(JaasSecurityManagerBase.java:552)
    at org.jboss.security.plugins.auth.JaasSecurityManagerBase.authenticate(JaasSecurityManagerBase.java:486)
    at org.jboss.security.plugins.auth.JaasSecurityManagerBase.isValid(JaasSecurityManagerBase.java:365)
    at org.jboss.security.plugins.JaasSecurityManager.isValid(JaasSecurityManager.java:160)
    at org.jboss.web.tomcat.security.JBossWebRealm.authenticate(JBossWebRealm.java:384)
    at org.apache.catalina.authenticator.BasicAuthenticator.authenticate(BasicAuthenticator.java:181)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:491)
    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
    at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
    at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
    at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:905)
    at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:592)
    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2506)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.UnsupportedOperationException: Can't write to a readonly object
    at net.sf.ehcache.hibernate.strategy.ReadOnlyEhcacheEntityRegionAccessStrategy.lockItem(ReadOnlyEhcacheEntityRegionAccessStrategy.java:74)
    at net.sf.ehcache.hibernate.nonstop.NonstopAwareEntityRegionAccessStrategy.lockItem(NonstopAwareEntityRegionAccessStrategy.java:150)
    at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:108)
    at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:168)
    at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
    at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
    at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1027)
    at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:365)
    at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:504)
    ... 64 more
2015-12-30 05:38:12,325 INFO  [com.XYZ.method.audit] (tomcat-exec-9) About to call [validate in UADWebServiceClientImpl]
2015-12-30 05:38:12,327 INFO  [com.XYZ.method.audit] (tomcat-exec-9) About to call [getTTLUADWebServiceSoap in UADWSLookupHelper]
2015-12-30 05:38:12,327 INFO  [com.XYZ.method.audit] (tomcat-exec-9) Completed call to [getTTLUADWebServiceSoap in UADWSLookupHelper]
2015-12-30 05:38:12,325 INFO  [com.XYZ.uad.UADWebServiceClientImpl] (tomcat-exec-9) [?] validate request: UADValidateRequest{username=user4, password=****, applicationId=100029}
2015-12-30 05:38:12,327 INFO  [com.XYZ.uad.UADWebServiceClientImpl] (tomcat-exec-9) [?] inside callUADValidate in UADWebServiceClientImpl
2015-12-30 05:38:12,356 INFO  [com.XYZ.external.ws.FakeUad] (tomcat-exec-11) Fake UAD pretending to validate user4 returning UADResponse{value=1, userId=100254, message=Fake Validation Success, user4 will act as user id 100254}
2015-12-30 05:38:12,361 INFO  [com.XYZ.method.audit] (tomcat-exec-9) Completed call to [validate in UADWebServiceClientImpl]
2015-12-30 05:38:12,361 INFO  [com.XYZ.login.UADLoginModule] (tomcat-exec-9) Inside getRoleSets
2015-12-30 05:38:12,703 WARN  [com.arjuna.ats.arjuna.logging.arjLoggerI18N] (tomcat-exec-9) [com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator_2] TwoPhaseCoordinator.beforeCompletion - failed for com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple@6c68ef31
javax.persistence.PersistenceException: java.lang.UnsupportedOperationException: Can't write to a readonly object
    at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:516)
    at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:101)

1 个答案:

答案 0 :(得分:0)

at com.sun.proxy.$Proxy1054.getPopulatedPrincipal(Unknown Source)

在上面的事务范围内的EJB方法中,配置有READ_ONLY二级缓存的hibernate实体似乎变脏(更新)。 因此,在更新了hibernate实体的EJB方法调用后,它就会失败。

如果您不是故意更新实体,请在实体的获取/设置方法中检查您是否有类似的内容。

String getProperty1() {
  return property1 != null ? property1 : "";
}

如果您不打算继续,更新或删除该ejb方法中的实体,请添加以下注释。

 @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)