- 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/
我正在编写一个具有以下签名的 Java 方法。 void Logger(Method method, Object[] args); 如果一个方法(例如 ABC() )调用此方法 Logger,它应该
我是 Java 新手。 我的问题是我的 Java 程序找不到我试图用作的图像文件一个 JButton。 (目前这段代码什么也没做,因为我只是得到了想要的外观第一的)。这是我的主课 代码: packag
好的,今天我在接受采访,我已经编写 Java 代码多年了。采访中说“Java 垃圾收集是一个棘手的问题,我有几个 friend 一直在努力弄清楚。你在这方面做得怎么样?”。她是想骗我吗?还是我的一生都
我的 friend 给了我一个谜语让我解开。它是这样的: There are 100 people. Each one of them, in his turn, does the following
如果我将使用 Java 5 代码的应用程序编译成字节码,生成的 .class 文件是否能够在 Java 1.4 下运行? 如果后者可以工作并且我正在尝试在我的 Java 1.4 应用程序中使用 Jav
有关于why Java doesn't support unsigned types的问题以及一些关于处理无符号类型的问题。我做了一些搜索,似乎 Scala 也不支持无符号数据类型。限制是Java和S
我只是想知道在一个 java 版本中生成的字节码是否可以在其他 java 版本上运行 最佳答案 通常,字节码无需修改即可在 较新 版本的 Java 上运行。它不会在旧版本上运行,除非您使用特殊参数 (
我有一个关于在命令提示符下执行 java 程序的基本问题。 在某些机器上我们需要指定 -cp 。 (类路径)同时执行java程序 (test为java文件名与.class文件存在于同一目录下) jav
我已经阅读 StackOverflow 有一段时间了,现在我才鼓起勇气提出问题。我今年 20 岁,目前在我的家乡(罗马尼亚克卢日-纳波卡)就读 IT 大学。足以介绍:D。 基本上,我有一家提供簿记应用
我有 public JSONObject parseXML(String xml) { JSONObject jsonObject = XML.toJSONObject(xml); r
我已经在 Java 中实现了带有动态类型的简单解释语言。不幸的是我遇到了以下问题。测试时如下代码: def main() { def ks = Map[[1, 2]].keySet()
一直提示输入 1 到 10 的数字 - 结果应将 st、rd、th 和 nd 添加到数字中。编写一个程序,提示用户输入 1 到 10 之间的任意整数,然后以序数形式显示该整数并附加后缀。 public
我有这个 DownloadFile.java 并按预期下载该文件: import java.io.*; import java.net.URL; public class DownloadFile {
我想在 GUI 上添加延迟。我放置了 2 个 for 循环,然后重新绘制了一个标签,但这 2 个 for 循环一个接一个地执行,并且标签被重新绘制到最后一个。 我能做什么? for(int i=0;
我正在对对象 Student 的列表项进行一些测试,但是我更喜欢在 java 类对象中创建硬编码列表,然后从那里提取数据,而不是连接到数据库并在结果集中选择记录。然而,自从我这样做以来已经很长时间了,
我知道对象创建分为三个部分: 声明 实例化 初始化 classA{} classB extends classA{} classA obj = new classB(1,1); 实例化 它必须使用
我有兴趣使用 GPRS 构建车辆跟踪系统。但是,我有一些问题要问以前做过此操作的人: GPRS 是最好的技术吗?人们意识到任何问题吗? 我计划使用 Java/Java EE - 有更好的技术吗? 如果
我可以通过递归方法反转数组,例如:数组={1,2,3,4,5} 数组结果={5,4,3,2,1}但我的结果是相同的数组,我不知道为什么,请帮助我。 public class Recursion { p
有这样的标准方式吗? 包括 Java源代码-测试代码- Ant 或 Maven联合单元持续集成(可能是巡航控制)ClearCase 版本控制工具部署到应用服务器 最后我希望有一个自动构建和集成环境。
我什至不知道这是否可能,我非常怀疑它是否可能,但如果可以,您能告诉我怎么做吗?我只是想知道如何从打印机打印一些文本。 有什么想法吗? 最佳答案 这里有更简单的事情。 import javax.swin
我是一名优秀的程序员,十分优秀!