- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
尽管我在日志中看到它,但我似乎无法捕捉到它。
实体
@Column(unique = true)
private String email;
我正试图像这样捕获它
try {
memberDao.create(newMember);
} catch (ConstraintViolationException e) {
//
}
-- 它永远不会到达 catch block 。
当我使用
捕获(异常 e)
我捕获到“javax.transaction.RollbackException:ARJUNA016053:无法提交事务。”
错误日志如下:
21:24:36,296 ERROR [org.jboss.ejb3.invocation] (http--127.0.0.1-8080-5) JBAS014134: EJB Invocation failed on component MemberDAOImpl for method public abstract void pv243.peaktogether.dao.MemberDAOInt.create(pv243.peaktogether.model.Member): javax.ejb.EJBTransactionRolledbackException: Transaction rolled back
at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleEndTransactionException(CMTTxInterceptor.java:115) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.ejb3.tx.CMTTxInterceptor.endTransaction(CMTTxInterceptor.java:95) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:232) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:304) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:190) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:32) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:173) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:72) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]
at pv243.peaktogether.dao.MemberDAOInt$$$view178.create(Unknown Source) [peaktogether-ejb-0.0.1-SNAPSHOT.jar:]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_17]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_17]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_17]
at java.lang.reflect.Method.invoke(Method.java:601) [rt.jar:1.7.0_17]
at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:264) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:260) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
at org.jboss.weld.bean.proxy.EnterpriseBeanProxyMethodHandler.invoke(EnterpriseBeanProxyMethodHandler.java:111) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
at org.jboss.weld.bean.proxy.EnterpriseTargetBeanInstance.invoke(EnterpriseTargetBeanInstance.java:56) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:105) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
at pv243.peaktogether.dao.MemberDAOInt$-682821774$Proxy$_$$_Weld$Proxy$.create(MemberDAOInt$-682821774$Proxy$_$$_Weld$Proxy$.java) [peaktogether-ejb-0.0.1-SNAPSHOT.jar:]
at pv243.peaktogether.web.controller.RegisterController.register(RegisterController.java:95)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_17]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_17]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_17]
at java.lang.reflect.Method.invoke(Method.java:601) [rt.jar:1.7.0_17]
at org.apache.el.parser.AstValue.invoke(AstValue.java:262)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)
at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:39) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
at
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
at pv243.peaktogether.filters.SecurityFilter.doFilter(SecurityFilter.java:48)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
at pv243.peaktogether.filters.EncodingFilter.doFilter(EncodingFilter.java:20)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)
at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_17]
Caused by: javax.transaction.RollbackException: ARJUNA016053: Could not commit transaction.
at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1177)
at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:117)
at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:75)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.endTransaction(CMTTxInterceptor.java:92) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
... 75 more
Caused by: javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: ERROR: duplicate key value violates unique constraint "member_email_key"
Detail: Key (email)=(email@test.com) already exists.
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1361) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1289) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1295) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.AbstractEntityManagerImpl$CallbackExceptionMapperImpl.mapManagedFlushFailure(AbstractEntityManagerImpl.java:1481) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.engine.transaction.synchronization.internal.SynchronizationCallbackCoordinatorImpl.beforeCompletion(SynchronizationCallbackCoordinatorImpl.java:109) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.engine.transaction.synchronization.internal.RegisteredSynchronization.beforeCompletion(RegisteredSynchronization.java:53) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:76)
at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:273)
at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:93)
at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:164)
at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1165)
... 78 more
Caused by: org.hibernate.exception.ConstraintViolationException: ERROR: duplicate key value violates unique constraint "member_email_key"
Detail: Key (email)=(email@test.com) already exists.
at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:128) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:47) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:129) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at sun.proxy.$Proxy99.executeUpdate(Unknown Source)
at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:56) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2849) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3290) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:80) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:272) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:264) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:186) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:326) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:52) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1081) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:315) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.engine.transaction.synchronization.internal.SynchronizationCallbackCoordinatorImpl.beforeCompletion(SynchronizationCallbackCoordinatorImpl.java:104) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
... 84 more
Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "member_email_key"
Detail: Key (email)=(email@test.com) already exists.
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2157) [postgresql-8.4-701.jdbc4.jar:]
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1886) [postgresql-8.4-701.jdbc4.jar:]
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255) [postgresql-8.4-701.jdbc4.jar:]
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:555) [postgresql-8.4-701.jdbc4.jar:]
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:417) [postgresql-8.4-701.jdbc4.jar:]
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:363) [postgresql-8.4-701.jdbc4.jar:]
at org.jboss.jca.adapters.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:493)
at sun.reflect.GeneratedMethodAccessor206.invoke(Unknown Source) [:1.7.0_17]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_17]
at java.lang.reflect.Method.invoke(Method.java:601) [rt.jar:1.7.0_17]
at org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:122) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
... 98 more
我做错了什么?
更新>>
我当前的代码是:
try {
memberDao.create(newMember);
} catch (EJBTransactionRolledbackException e) {
log.info("Exception caught!! "+e.getCausedByException());
log.info("Exception caught!! "+e.getCause());
log.info("Exception caught!! "+e.getMessage());
StackTraceElement[] stack = e.getStackTrace();
for (int i = 0; i< stack.length; i++) {
log.info(stack[i].toString());
}
}
日志是
22:02:57,297 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) Exception caught!! javax.transaction.RollbackException: ARJUNA016053: Could not commit transaction.
22:02:57,298 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) Exception caught!! javax.transaction.RollbackException: ARJUNA016053: Could not commit transaction.
22:02:57,298 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) Exception caught!! Transaction rolled back
22:02:57,298 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) org.jboss.as.ejb3.tx.CMTTxInterceptor.handleEndTransactionException(CMTTxInterceptor.java:115)
22:02:57,299 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) org.jboss.as.ejb3.tx.CMTTxInterceptor.endTransaction(CMTTxInterceptor.java:95)
22:02:57,299 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:232)
22:02:57,299 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:304)
22:02:57,300 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:190)
22:02:57,300 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
22:02:57,300 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)
22:02:57,301 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
22:02:57,301 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59)
22:02:57,301 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
22:02:57,302 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)
22:02:57,302 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
22:02:57,302 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:32)
22:02:57,303 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
22:02:57,303 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)
22:02:57,303 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
22:02:57,304 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
22:02:57,304 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165)
22:02:57,304 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:173)
22:02:57,305 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
22:02:57,305 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
22:02:57,305 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:72)
22:02:57,306 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) pv243.peaktogether.dao.MemberDAOInt$$$view241.create(Unknown Source)
22:02:57,306 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
22:02:57,306 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
22:02:57,307 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
22:02:57,307 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) java.lang.reflect.Method.invoke(Method.java:601)
22:02:57,307 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:264)
22:02:57,308 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52)
22:02:57,308 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137)
22:02:57,308 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:260)
22:02:57,309 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) org.jboss.weld.bean.proxy.EnterpriseBeanProxyMethodHandler.invoke(EnterpriseBeanProxyMethodHandler.java:111)
22:02:57,309 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) org.jboss.weld.bean.proxy.EnterpriseTargetBeanInstance.invoke(EnterpriseTargetBeanInstance.java:56)
22:02:57,309 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:105)
22:02:57,310 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) pv243.peaktogether.dao.MemberDAOInt$-682821774$Proxy$_$$_Weld$Proxy$.create(MemberDAOInt$-682821774$Proxy$_$$_Weld$Proxy$.java)
22:02:57,310 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) pv243.peaktogether.web.controller.RegisterController.register(RegisterController.java:98)
22:02:57,310 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
22:02:57,310 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
22:02:57,311 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
22:02:57,311 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) java.lang.reflect.Method.invoke(Method.java:601)
22:02:57,311 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) org.apache.el.parser.AstValue.invoke(AstValue.java:262)
22:02:57,312 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)
22:02:57,312 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:39)
22:02:57,312 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
22:02:57,313 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
22:02:57,313 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
22:02:57,313 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
22:02:57,313 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) javax.faces.component.UICommand.broadcast(UICommand.java:315)
22:02:57,314 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
22:02:57,314 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
22:02:57,314 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
22:02:57,315 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
22:02:57,315 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
22:02:57,315 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
22:02:57,315 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
22:02:57,316 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
22:02:57,316 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62)
22:02:57,317 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
22:02:57,317 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
22:02:57,317 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) pv243.peaktogether.filters.SecurityFilter.doFilter(SecurityFilter.java:48)
22:02:57,317 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
22:02:57,318 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
22:02:57,318 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) pv243.peaktogether.filters.EncodingFilter.doFilter(EncodingFilter.java:20)
22:02:57,318 INFO [pv243.peaktogether.web.controller.RegisterController] (http--127.0.0.1-8080-6) org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
22:02:57,319 INFO [pv243.peaktogether.web.controller.RegisterController] (http-
环境:PostgreSQL 9.2JBoss 作为 7.1.1JPA 2.0
干杯,奥西里斯
最佳答案
它包含在 EJBTransactionRolledbackException
中,因此您应该 try catch 该异常而不是 ConstraintViolationException
。
ConstraintViolationException
首先被 PersistenceException
包装,然后被 RollbackException
包装,最后被 EJBTransactionRolledbackException
包装>.
您应该调用 Exception
的 getCause()
方法,直到遇到约束违反或 null,这表明异常不是由于约束违反造成的.你可以尝试这样的事情:
try {
memberDao.create(newMember);
} catch (EJBTransactionRolledbackException e) {
Throwable t = e.getCause();
while ((t != null) && !(t instanceof ConstraintViolationException)) {
t = t.getCause();
}
if (t instanceof ConstraintViolationException) {
// Here you're sure you have a ConstraintViolationException, you can handle it
}
}
关于java - 无法捕获 ConstraintViolationException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17384008/
多个 ChildException catch block 和一个 Exception catch block 之间哪个更好? 更好,我的意思是以良好的实践方式。 举例说明: public stati
我正在尝试将脱机计算机记录在文本文件中,以便以后可以再次运行它们。似乎没有被记录或捕获。 function Get-ComputerNameChange { [CmdletBinding()]
我正在将 Scala 'try/catch' 测试代码转换为使用 'intercept' 有没有我不应该使用“拦截”的场景?使用 'intercept' 而不是 'try/catch' 的唯一好处是简
我对erlang很陌生,我正在尝试使用基本的try/catch语句来工作。我正在使用Webmachine处理一些请求,我真正想做的就是解析一些JSON数据并将其返回。如果JSON数据无效,我只想返回一
我不知道如何捕获删除按键。我发现在 ASCII 代码表中,它位于 127 位,但是 if (Key = #127) then 却无济于事。 然后我检查了 VK_DELETE 的值,它是 47。尝试使用
我很少在失败时对数据库查询使用唯一的错误消息 我经常使用简短的标准消息,例如“数据库错误/失败。请与网站管理员联系”或类似的消息。或自动发送给我 我正在寻找一种在PDO中全局设置一次try {}和ca
我有一个变量CompletableFuture completableFuture 。我希望能够使用任何类型的对象来完成它。例如:completableFuture.complete(new Stri
我认为这是基本的东西,但我不知道该怎么做。为什么我得到 IOException never throw in body of相应的 try 语句 public static void main(Str
我在此代码中遇到 JSON 异常: JSONObject jObject = new JSONObject(JSONString); pontosUsuario.setIdUsuari
我正在尝试打印出用单引号括起来的文本。 /bin/bash -lc '/home/CASPER_REPORTS/scripts/CASPER_gen_report.sh CASPER_1' /bin/
我这里遇到了一点问题。我想弄清楚如何捕获 IllegalArgumentException。对于我的程序,如果用户输入负整数,程序应该捕获 IllegalArgumentException 并询问用户
我无法理解 EJBTransactionRolledbackException。 我有实体: @Entity public class MyEntity { @Id @Generate
对于我给自己提出的以下挑战,如果社区的经验给我任何建议,我将不胜感激 - 即,这里有任何关于最佳方法/方向的指示吗? 要求 允许收集/实时监控从用户 Windows PC 到一组特定 IP 地址(或
我想在我的 ABAP 代码中捕获并处理 SAPSQL_DATA_LOSS。 我试过这个: try. SELECT * FROM (rtab_name) AS rtab
我知道捕获错误不是一个好的做法,但在这种情况下,这样做很重要。我正在尝试运行一个包含游戏一部分的 jar,但它给了我一个 unsatisfiedlink 错误,但这是有趣的部分:我正在使用这段代码:
我有一个表单页面,当我保存它时,它会覆盖数据库。表单页面中有一个文本框,允许用户输入 4000 个字符,但如果用户输入的字符超过此值,则会出现以下错误: ERROR 15:54:05 Abstrac
我想知道在python中绑定(bind)键的最简单方法 例如,默认的 python 控制台窗口出现并等待,然后在 psuedo -> if key "Y" is pressed: print (
下面是别人写的类。 我面临的问题是,当它进入parse method时与 null as the rawString ,它正在扔NumberFormatException 。 所以我想做的是,我应该捕
我有一个简单的脚本,可以捕获所有鼠标单击,除非您单击实际有效的内容。链接、Flash 视频等。我如何调整它,以便无论用户点击什么,在视频加载、新页面加载等之前,它都会发送我构建的简单 GET 请求?
我有一个带有一些选择列表的表单,当选择某些值时,这些列表将显示/隐藏更多输入字段。 问题是大多数用户都是数据输入人员,因此他们在输入数据时大量使用键盘,并且选择列表的 change 事件仅在焦点离开输
我是一名优秀的程序员,十分优秀!