I'm using NamedParameterJdbcTemplate,below SQL works well in Oraclie SQL Developer.
select sum(PRINTEDLICNUM), sum(PRINTEDLICCOPYNUM), PRIPID from LICENSEPRINTRECORD where PRIPID in ('370212230027855') GROUP BY PRIPID;
But this code not works in NamedParameterJdbcTemplate
Map namedParameters = Collections.singletonMap("pripids", pripIds);
StringBuffer recordQueryString = new StringBuffer();
recordQueryString.append("SELECT SUM(PRINTEDLICNUM), SUM(PRINTEDLICCOPYNUM), PRIPID from LICENSEPRINTRECORD where PRIPID in (:pripids) GROUP BY PRIPID");
List<PreviousPrintRecords> records = template.query(recordQueryString.toString(), namedParameters, new RowMapper<PreviousPrintRecords>());
Below is my RowMapper Class:
public class PreviousPrintRecords implements Serializable{
/**
*
*/
private static final long serialVersionUID = -3763072257141955974L;
private int printedLicNum;
private int printedLicCopyNum;
private String pripId;
public PreviousPrintRecords() {
super();
}
public PreviousPrintRecords(int printedLicNum, int printedLicCopyNum, String pripId) {
super();
this.printedLicNum = printedLicNum;
this.setPrintedLicCopyNum(printedLicCopyNum);
this.pripId = pripId;
}
public int getPrintedLicNum() {
return printedLicNum;
}
public void setPrintedLicNum(int printedLicNum) {
this.printedLicNum = printedLicNum;
}
public String getPripId() {
return pripId;
}
public void setPripId(String pripId) {
this.pripId = pripId;
}
public int getPrintedLicCopyNum() {
return printedLicCopyNum;
}
public void setPrintedLicCopyNum(int printedLicCopyNum) {
this.printedLicCopyNum = printedLicCopyNum;
}
}
It will occurs error, nested exception is java.sql.SQLException: Invalid column name
below is detailed trace:
10:48:09,477 INFO [stdout] (DefaultThreadPoolService1) 2018-05-15 10:48:09 INFO o.s.j.support.SQLErrorCodesFactory - SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase, Hana]
10:48:09,532 INFO [stdout] (DefaultThreadPoolService1) 2018-05-15 10:48:09 ERROR c.a.p.a.task.GetLicenseItemListTask - Get licenseitem task occurs error org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [SELECT SUM(PRINTEDLICNUM), SUM(PRINTEDLICCOPYNUM), PRIPID from LICENSEPRINTRECORD where PRIPID in (?, ?, ?, ?, ?, ?, ?) GROUP BY PRIPID]; nested exception is java.sql.SQLException: Invalid column name
10:48:09,532 INFO [stdout] (DefaultThreadPoolService1) at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:231)
10:48:09,532 INFO [stdout] (DefaultThreadPoolService1) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73)
10:48:09,532 INFO [stdout] (DefaultThreadPoolService1) at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:649)
10:48:09,532 INFO [stdout] (DefaultThreadPoolService1) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:684)
10:48:09,532 INFO [stdout] (DefaultThreadPoolService1) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:711)
10:48:09,533 INFO [stdout] (DefaultThreadPoolService1) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:761)
10:48:09,533 INFO [stdout] (DefaultThreadPoolService1) at org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.query(NamedParameterJdbcTemplate.java:192)
10:48:09,533 INFO [stdout] (DefaultThreadPoolService1) at org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.query(NamedParameterJdbcTemplate.java:199)
10:48:09,534 INFO [stdout] (DefaultThreadPoolService1) at com.aw.product.abp.licenseprint.service.DaoLicensePrintService.requestLicensePrintItemData(DaoLicensePrintService.java:167)
10:48:09,534 INFO [stdout] (DefaultThreadPoolService1) at com.aw.product.abp.task.GetLicenseItemListTask.run(GetLicenseItemListTask.java:85)
10:48:09,534 INFO [stdout] (DefaultThreadPoolService1) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
10:48:09,534 INFO [stdout] (DefaultThreadPoolService1) at java.util.concurrent.FutureTask.run(FutureTask.java:266)
10:48:09,534 INFO [stdout] (DefaultThreadPoolService1) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
10:48:09,535 INFO [stdout] (DefaultThreadPoolService1) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
10:48:09,535 INFO [stdout] (DefaultThreadPoolService1) at java.lang.Thread.run(Thread.java:745)
10:48:09,535 INFO [stdout] (DefaultThreadPoolService1) Caused by: java.sql.SQLException: Invalid column name
10:48:09,535 INFO [stdout] (DefaultThreadPoolService1) at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
10:48:09,535 INFO [stdout] (DefaultThreadPoolService1) at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133)
10:48:09,537 INFO [stdout] (DefaultThreadPoolService1) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:199)
10:48:09,539 INFO [stdout] (DefaultThreadPoolService1) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:263)
10:48:09,539 INFO [stdout] (DefaultThreadPoolService1) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:271)
10:48:09,539 INFO [stdout] (DefaultThreadPoolService1) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:445)
10:48:09,539 INFO [stdout] (DefaultThreadPoolService1) at oracle.jdbc.driver.OracleStatement.getColumnIndex(OracleStatement.java:3367)
10:48:09,540 INFO [stdout] (DefaultThreadPoolService1) at oracle.jdbc.driver.OracleResultSetImpl.findColumn(OracleResultSetImpl.java:2009)
10:48:09,540 INFO [stdout] (DefaultThreadPoolService1) at oracle.jdbc.driver.OracleResultSet.getString(OracleResultSet.java:494)
10:48:09,540 INFO [stdout] (DefaultThreadPoolService1) at org.jboss.jca.adapters.jdbc.WrappedResultSet.getString(WrappedResultSet.java:1381)
10:48:09,540 INFO [stdout] (DefaultThreadPoolService1) at com.aw.product.abp.licenseprint.service.DaoLicensePrintService$2.mapRow(DaoLicensePrintService.java:173)
10:48:09,540 INFO [stdout] (DefaultThreadPoolService1) at com.aw.product.abp.licenseprint.service.DaoLicensePrintService$2.mapRow(DaoLicensePrintService.java:1)
10:48:09,541 INFO [stdout] (DefaultThreadPoolService1) at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:93)
10:48:09,541 INFO [stdout] (DefaultThreadPoolService1) at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:60)
10:48:09,541 INFO [stdout] (DefaultThreadPoolService1) at org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:697)
10:48:09,543 INFO [stdout] (DefaultThreadPoolService1) at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:633)
10:48:09,543 INFO [stdout] (DefaultThreadPoolService1) ... 12 more
Does NamedParameterJdbcTemplate not support sum function?
If I wanna use sum function, is there any way to achieve this?
java.sql.SQLException: Invalid column name
The exception is clear enough. You properly named your table column name in the wrong way.
You are using rowMapper class, but you not define the column name.
Change your code as below
recordQueryString.append("SELECT SUM(PRINTEDLICNUM) AS printedLicNum, SUM(PRINTEDLICCOPYNUM) AS printedLicCopyNum, PRIPID from LICENSEPRINTRECORD where PRIPID in (:pripids) GROUP BY PRIPID");
Related
The problem
I've migrated from Hibernate 3.6.10 to 4.3.11. These are my pom.xml properties:
<!--<hibernate.version>3.6.10.Final</hibernate.version>-->
<hibernate.version>4.3.11.Final</hibernate.version>
I'm working with legacy code and I've got a service method like this:
public Collection<ProtExtraccionMuestra> guardarProtExtraccionMuestras(
Collection<ProtExtraccionMuestra> protExtraccionMuestras) {
Date fechaEntrada = null;
Date fechaSalida = null;
Collection<ProtExtraccionMuestra> muestrasRetornar = new HashSet<ProtExtraccionMuestra>();
if (protExtraccionMuestras != null) {
for (ProtExtraccionMuestra protExtraccionMuestra : protExtraccionMuestras) {
Localizador.servMuestra().comprobarMuestraEnBiobanco(protExtraccionMuestra.getMuestra());
fechaEntrada = protExtraccionMuestra.getMuestra().getFechaEntrada();
fechaSalida = protExtraccionMuestra.getMuestra().getFechaSalida();
protExtraccionMuestra = (ProtExtraccionMuestra) guardar(protExtraccionMuestra, true);
protocoloExtraccionService.comprobarEstadoMuestra(protExtraccionMuestra.getMuestra(), fechaEntrada, fechaSalida);
muestrasRetornar.add(protExtraccionMuestra);
}
}
return muestrasRetornar;
}
After upgrading, the code didn't work. I got this error (HibernateException: Could not obtain transaction-synchronized Session for current thread):
10:32:54,135 INFO [stdout] (http-/127.0.0.1:63724-1) [ERROR,ExceptionControllerAdvice,http-/127.0.0.1:63724-1] EXCEPTION TRACE:
10:32:54,135 INFO [stdout] (http-/127.0.0.1:63724-1) org.hibernate.HibernateException: Could not obtain transaction-synchronized Session for current thread
10:32:54,135 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.orm.hibernate4.SpringSessionContext.currentSession(SpringSessionContext.java:134)
10:32:54,135 INFO [stdout] (http-/127.0.0.1:63724-1) at org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:1014)
10:32:54,135 INFO [stdout] (http-/127.0.0.1:63724-1) at es.gva.san.fisabio.rvb.HibernateDAO.getSession(HibernateDAO.java:31)
10:32:54,135 INFO [stdout] (http-/127.0.0.1:63724-1) at es.gva.san.fisabio.rvb.HibernateDAO.merge(HibernateDAO.java:59)
10:32:54,135 INFO [stdout] (http-/127.0.0.1:63724-1) at util.hibernate.DiUtilHibernate.merge(DiUtilHibernate.java:166)
10:32:54,135 INFO [stdout] (http-/127.0.0.1:63724-1) at service.AbstractService.modificar(AbstractService.java:1052)
10:32:54,135 INFO [stdout] (http-/127.0.0.1:63724-1) at service.GenericCRUDSImpl.guardar(GenericCRUDSImpl.java:110)
10:32:54,135 INFO [stdout] (http-/127.0.0.1:63724-1) at es.di.biobanco.csisp.laboratorio.service.ProtExtraccionMuestraServiceImpl.guardarProtExtraccionMuestras(ProtExtraccionMuestraServiceImpl.java:78)
10:32:54,136 INFO [stdout] (http-/127.0.0.1:63724-1) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
10:32:54,136 INFO [stdout] (http-/127.0.0.1:63724-1) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
10:32:54,136 INFO [stdout] (http-/127.0.0.1:63724-1) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
10:32:54,136 INFO [stdout] (http-/127.0.0.1:63724-1) at java.lang.reflect.Method.invoke(Method.java:498)
10:32:54,136 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
10:32:54,136 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
10:32:54,136 INFO [stdout] (http-/127.0.0.1:63724-1) at com.sun.proxy.$Proxy58.guardarProtExtraccionMuestras(Unknown Source)
10:32:54,136 INFO [stdout] (http-/127.0.0.1:63724-1) at es.gva.san.fisabio.rvb.controller.LaboratorioController.guardarProtExtraccionMuestras(LaboratorioController.java:128)
10:32:54,136 INFO [stdout] (http-/127.0.0.1:63724-1) at es.gva.san.fisabio.rvb.controller.LaboratorioController$$FastClassBySpringCGLIB$$7fedee67.invoke(<generated>)
10:32:54,136 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
10:32:54,136 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:651)
10:32:54,136 INFO [stdout] (http-/127.0.0.1:63724-1) at es.gva.san.fisabio.rvb.controller.LaboratorioController$$EnhancerBySpringCGLIB$$b9797364.guardarProtExtraccionMuestras(<generated>)
10:32:54,136 INFO [stdout] (http-/127.0.0.1:63724-1) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
10:32:54,136 INFO [stdout] (http-/127.0.0.1:63724-1) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
10:32:54,136 INFO [stdout] (http-/127.0.0.1:63724-1) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
10:32:54,136 INFO [stdout] (http-/127.0.0.1:63724-1) at java.lang.reflect.Method.invoke(Method.java:498)
10:32:54,136 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:220)
10:32:54,136 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:134)
10:32:54,136 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:116)
10:32:54,139 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
10:32:54,139 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
10:32:54,139 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
10:32:54,139 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
10:32:54,139 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
10:32:54,139 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
10:32:54,139 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
10:32:54,139 INFO [stdout] (http-/127.0.0.1:63724-1) at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
10:32:54,139 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
10:32:54,139 INFO [stdout] (http-/127.0.0.1:63724-1) at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
10:32:54,139 INFO [stdout] (http-/127.0.0.1:63724-1) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295)
10:32:54,139 INFO [stdout] (http-/127.0.0.1:63724-1) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
10:32:54,139 INFO [stdout] (http-/127.0.0.1:63724-1) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:220)
10:32:54,139 INFO [stdout] (http-/127.0.0.1:63724-1) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:197)
10:32:54,139 INFO [stdout] (http-/127.0.0.1:63724-1) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
10:32:54,139 INFO [stdout] (http-/127.0.0.1:63724-1) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
10:32:54,139 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:317)
10:32:54,139 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127)
10:32:54,139 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91)
10:32:54,139 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
10:32:54,139 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:114)
10:32:54,139 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
10:32:54,140 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137)
10:32:54,140 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
10:32:54,140 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
10:32:54,140 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
10:32:54,140 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170)
10:32:54,140 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
10:32:54,140 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
10:32:54,140 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
10:32:54,140 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilterInternal(BasicAuthenticationFilter.java:215)
10:32:54,140 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
10:32:54,140 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
10:32:54,140 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:96)
10:32:54,140 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
10:32:54,140 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
10:32:54,140 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:64)
10:32:54,140 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
10:32:54,140 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
10:32:54,140 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)
10:32:54,140 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
10:32:54,140 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
10:32:54,140 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
10:32:54,140 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
10:32:54,140 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:214)
10:32:54,140 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177)
10:32:54,140 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
10:32:54,140 INFO [stdout] (http-/127.0.0.1:63724-1) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)
10:32:54,140 INFO [stdout] (http-/127.0.0.1:63724-1) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
10:32:54,141 INFO [stdout] (http-/127.0.0.1:63724-1) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
10:32:54,141 INFO [stdout] (http-/127.0.0.1:63724-1) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:231)
10:32:54,141 INFO [stdout] (http-/127.0.0.1:63724-1) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149)
10:32:54,142 INFO [stdout] (http-/127.0.0.1:63724-1) at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169)
10:32:54,142 INFO [stdout] (http-/127.0.0.1:63724-1) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:150)
10:32:54,142 INFO [stdout] (http-/127.0.0.1:63724-1) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97)
10:32:54,142 INFO [stdout] (http-/127.0.0.1:63724-1) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102)
10:32:54,142 INFO [stdout] (http-/127.0.0.1:63724-1) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344)
10:32:54,142 INFO [stdout] (http-/127.0.0.1:63724-1) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:854)
10:32:54,142 INFO [stdout] (http-/127.0.0.1:63724-1) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653)
10:32:54,142 INFO [stdout] (http-/127.0.0.1:63724-1) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:926)
10:32:54,142 INFO [stdout] (http-/127.0.0.1:63724-1) at java.lang.Thread.run(Thread.java:745)
So I've made it transactional with #Transactional decorator.
Then I have the following error (InvalidDataAccessApiUsageException: object references an unsaved transient instance):
16:50:05,587 ERROR es.gva.san.fisabio.rvb.controller.advice.ExceptionControllerAdvice,http-/0.0.0.0:63004-6:41 - EXCEPTION TRACE:
org.springframework.dao.InvalidDataAccessApiUsageException: object references an unsaved transient instance - save the transient instance before flushing: es.di.biobanco.csisp.laboratorio.entity.ProtocoloExtraccion; nested exception is org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: es.di.biobanco.csisp.laboratorio.entity.ProtocoloExtraccion
at org.springframework.orm.hibernate4.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:190)
at org.springframework.orm.hibernate4.HibernateTransactionManager.convertHibernateAccessException(HibernateTransactionManager.java:730)
at org.springframework.orm.hibernate4.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:592)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:761)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:730)
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:504)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:292)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655)
at es.gva.san.fisabio.rvb.controller.LaboratorioController$$EnhancerBySpringCGLIB$$432cae2f.guardarProtExtraccionMuestras(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:220)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:134)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:116)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:220)
at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:197)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:317)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:114)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilterInternal(BasicAuthenticationFilter.java:215)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:96)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:64)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:214)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:231)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149)
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:150)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:854)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:926)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: es.di.biobanco.csisp.laboratorio.entity.ProtocoloExtraccion
at org.hibernate.engine.internal.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:294)
at org.hibernate.type.EntityType.getIdentifier(EntityType.java:537)
at org.hibernate.type.ManyToOneType.isDirty(ManyToOneType.java:311)
at org.hibernate.type.ManyToOneType.isDirty(ManyToOneType.java:321)
at org.hibernate.type.TypeHelper.findDirty(TypeHelper.java:310)
at org.hibernate.persister.entity.AbstractEntityPersister.findDirty(AbstractEntityPersister.java:4243)
at org.hibernate.event.internal.DefaultFlushEntityEventListener.dirtyCheck(DefaultFlushEntityEventListener.java:546)
at org.hibernate.event.internal.DefaultFlushEntityEventListener.isUpdateNecessary(DefaultFlushEntityEventListener.java:232)
at org.hibernate.event.internal.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:159)
at org.hibernate.event.internal.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:231)
at org.hibernate.event.internal.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:102)
at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:55)
at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1258)
at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:425)
at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransactionCommit(JdbcTransaction.java:101)
at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:177)
at org.springframework.orm.hibernate4.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:584)
... 76 more
More data and code
This is the way objects are saved, after some validations:
In some heir of AbstractEntity:
public AbstractEntity guardar(AbstractEntity entity,boolean merge) {
return super.modify(entity, merge);
}
public HibernateDAO getHibernateTemplate() {
return this;
}
[...]
public AbstractEntity modify(AbstractEntity obj, boolean merge) {
if (!merge) {
try {
this.getHibernateTemplate().saveOrUpdate(obj);
} catch (Exception e) {
logger.error(e);
obj = DiUtilHibernate.merge(obj, getSession());
this.getHibernateTemplate().saveOrUpdate(obj);
}
} else {
obj = DiUtilHibernate.merge(obj, this.getHibernateTemplate());
}
return obj;
}
And this awful utility class:
/**
* Merge function, to load only the required entities
*/
public static AbstractEntity merge(AbstractEntity ent, Session ses) {
// We save the values, before they are lost with the merge
String lazysCargados = ent.getLazysCargados();
boolean valorLazys = ent.getCargarLazysProxy();
return afterMerge((AbstractEntity) ses.merge(ent), lazysCargados, valorLazys);
}
Please let me know if you need some other piece of code or clarification.
I want to register two queues listeners for Spring AMQP with the latest Spring version:
#Bean
public SimpleMessageListenerContainer processingTransactionSaleContainer(ConnectionFactory cf, TransactionElavonSaleListener listener) {
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(cf);
container.setQueueNames(QUEUE_PROCESSING_SALE);
container.setMessageListener(new MessageListenerAdapter(listener, "transactionSaleProcess"));
container.setMessageConverter(new SerializerMessageConverter());
return container;
}
#Bean
public SimpleMessageListenerContainer processingTransactionAuthorizeContainer(ConnectionFactory cf, TransactionAuthorizeListener listener) {
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(cf);
container.setQueueNames(QUEUE_PROCESSING_AUTHORIZE);
container.setMessageListener(new MessageListenerAdapter(listener, "transactionAuthorizeProcess"));
container.setMessageConverter(new SerializerMessageConverter());
return container;
}
Listener:
#Component
public class TransactionElavonSaleListener {
public TransactionResponseFactory transactionElavonSaleProcess(TransactionRequestFactory ro) {
..... do some heavy network request
return parseRawSuccessResponse(response);
}
}
When I remove one of the SimpleMessageListenerContainer it's working file but when I use the both methods I get this exception:
00:40:14,469 INFO [stdout] (pool-9-thread-5) 00:40:14.468 [pool-9-thread-5] WARN o.s.amqp.rabbit.core.RabbitTemplate - Reply received after timeout for 1
00:40:14,472 INFO [stdout] (pool-9-thread-5) 00:40:14.472 [pool-9-thread-5] WARN o.s.a.r.l.ConditionalRejectingErrorHandler - Execution of Rabbit message listener failed.
00:40:14,473 INFO [stdout] (pool-9-thread-5) org.springframework.amqp.rabbit.listener.exception.ListenerExecutionFailedException: Listener threw exception
00:40:14,473 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.wrapToListenerExecutionFailedExceptionIfNeeded(AbstractMessageListenerContainer.java:1613)
00:40:14,473 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:1517)
00:40:14,473 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.actualInvokeListener(AbstractMessageListenerContainer.java:1440)
00:40:14,473 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:1428)
00:40:14,473 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:1423)
00:40:14,473 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.executeListener(AbstractMessageListenerContainer.java:1372)
00:40:14,473 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.listener.DirectMessageListenerContainer$SimpleConsumer.callExecuteListener(DirectMessageListenerContainer.java:995)
00:40:14,473 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.listener.DirectMessageListenerContainer$SimpleConsumer.handleDelivery(DirectMessageListenerContainer.java:955)
00:40:14,474 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//com.rabbitmq.client.impl.ConsumerDispatcher$5.run(ConsumerDispatcher.java:149)
00:40:14,474 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//com.rabbitmq.client.impl.ConsumerWorkService$WorkPoolRunnable.run(ConsumerWorkService.java:104)
00:40:14,474 INFO [stdout] (pool-9-thread-5) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
00:40:14,474 INFO [stdout] (pool-9-thread-5) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
00:40:14,478 INFO [stdout] (pool-9-thread-5) at java.base/java.lang.Thread.run(Thread.java:844)
00:40:14,481 INFO [stdout] (pool-9-thread-5) Caused by: org.springframework.amqp.AmqpRejectAndDontRequeueException: Reply received after timeout
00:40:14,494 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.core.RabbitTemplate.onMessage(RabbitTemplate.java:2446)
00:40:14,494 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.listener.DirectReplyToMessageListenerContainer.lambda$setMessageListener$1(DirectReplyToMessageListenerContainer.java:115)
00:40:14,494 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:1514)
00:40:14,494 INFO [stdout] (pool-9-thread-5) ... 11 common frames omitted
00:40:14,495 INFO [stdout] (pool-9-thread-5) 00:40:14.495 [pool-9-thread-5] ERROR o.s.a.r.l.DirectReplyToMessageListenerContainer - Failed to invoke listener
00:40:14,495 INFO [stdout] (pool-9-thread-5) org.springframework.amqp.rabbit.listener.exception.ListenerExecutionFailedException: Listener threw exception
00:40:14,495 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.wrapToListenerExecutionFailedExceptionIfNeeded(AbstractMessageListenerContainer.java:1613)
00:40:14,495 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:1517)
00:40:14,496 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.actualInvokeListener(AbstractMessageListenerContainer.java:1440)
00:40:14,496 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:1428)
00:40:14,496 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:1423)
00:40:14,496 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.executeListener(AbstractMessageListenerContainer.java:1372)
00:40:14,496 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.listener.DirectMessageListenerContainer$SimpleConsumer.callExecuteListener(DirectMessageListenerContainer.java:995)
00:40:14,496 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.listener.DirectMessageListenerContainer$SimpleConsumer.handleDelivery(DirectMessageListenerContainer.java:955)
00:40:14,496 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//com.rabbitmq.client.impl.ConsumerDispatcher$5.run(ConsumerDispatcher.java:149)
00:40:14,496 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//com.rabbitmq.client.impl.ConsumerWorkService$WorkPoolRunnable.run(ConsumerWorkService.java:104)
00:40:14,496 INFO [stdout] (pool-9-thread-5) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
00:40:14,496 INFO [stdout] (pool-9-thread-5) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
00:40:14,497 INFO [stdout] (pool-9-thread-5) at java.base/java.lang.Thread.run(Thread.java:844)
00:40:14,497 INFO [stdout] (pool-9-thread-5) Caused by: org.springframework.amqp.AmqpRejectAndDontRequeueException: Reply received after timeout
00:40:14,497 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.core.RabbitTemplate.onMessage(RabbitTemplate.java:2446)
00:40:14,497 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.listener.DirectReplyToMessageListenerContainer.lambda$setMessageListener$1(DirectReplyToMessageListenerContainer.java:115)
00:40:14,497 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:1514)
00:40:14,497 INFO [stdout] (pool-9-thread-5) ... 11 common frames omitted
Do you know why I get this exception when I have these two methods?
EDITL Defined listeners:
#Bean
public SimpleMessageListenerContainer processingTransactionElavonSaleContainer(ConnectionFactory cf, TransactionElavonSaleListener listener) {
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(cf);
container.setQueueNames(QUEUE_PROCESSING_ELAVON_SALE);
container.setMessageListener(new MessageListenerAdapter(listener, "transactionElavonSaleProcess"));
return container;
}
#Bean
public SimpleMessageListenerContainer processingTransactionElavonAuthorizeContainer(ConnectionFactory cf, TransactionElavonAuthorizeListener listener) {
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(cf);
container.setQueueNames(QUEUE_PROCESSING_ELAVON_AUTHORIZE);
container.setMessageListener(new MessageListenerAdapter(listener, "transactionElavonAuthorizeProcess"));
return container;
}
...
#Component
public class TransactionElavonSaleListener {
public TransactionResponseFactory transactionElavonSaleProcess(TransactionRequestFactory ro) {
return new TransactionResponseFactory();
}
}
#Component
public class TransactionElavonAuthorizeListener {
public TransactionResponseFactory transactionElavonAuthorizeProcess(TransactionRequestFactory tf) {
TransactionResponseFactory obj = new TransactionResponseFactory();
return obj;
}
}
Send object:
TransactionResponseFactory processingPeply = (TransactionResponseFactory) processingTransactionElavonAuthorizeTemplate.convertSendAndReceive(
ContextServer.EXCHANGE_PROCESSING, ContextServer.ROUTING_KEY_PROCESSING_TRANSACTION_ELAVON, tf);
System.out.println("!!!!! Received PROCESSING_TRANSACTION " + processingPeply.getTransaction_id());
Observation about your configuration (not relevant to your issue, however)...
The declare... code in your AmqpAdmin are not required.
you should never interact with the broker during the bean definition phase - it's too early.
they are not necessary because the admin will find the Queue and Exchange beans and automatically declare them for you when the connection is first opened.
Yes, that message converter setter is not used for this kind of listener; the message converter should be set on the MessageListenerAdapter instead.
However, it gets a SimpleMessageConverter by default so that should not be the problem; this converter handles serialized objects as well as plain text.
Now, to your actual issue; adding a second container should not have any affect on the client side; each template gets its own reply container and direct reply-to is used by default so there will be no cross talk between them (which can happen if you use a named reply queue, but that's not the case here).
I suggest you turn on DEBUG logging to figure out what's going on; if you need help analyzing them; post the logs (from both client and server side) and I'll take a look.
EDIT
Your bindings are incorrect:
#Bean
public Binding bindingQueueProcessingElavonSale() {
return BindingBuilder.bind(new Queue(QUEUE_PROCESSING_ELAVON_SALE, true))
.to(new TopicExchange(EXCHANGE_PROCESSING)).with(ROUTING_KEY_PROCESSING_TRANSACTION_ELAVON);
}
#Bean
public Binding bindingQueueProcessingElavonAuthorize() {
return BindingBuilder.bind(new Queue(QUEUE_PROCESSING_ELAVON_AUTHORIZE, true))
.to(new TopicExchange(EXCHANGE_PROCESSING)).with(ROUTING_KEY_PROCESSING_TRANSACTION_ELAVON);
}
You are binding both queues to the same exchange with the same routing key - RabbitMQ will send messages with that routing key to both queues, so both listeners will respond.
Default timeout for convertSendAndReceive is 5 seconds. To modify the timeout set property replyTimeout of AmqpTemplate to bigger value (milliseconds).
https://docs.spring.io/spring-amqp/reference/html/#reply-timeout
I'm stuck here, Couldn't figure out any Solution for StaleObjectStateException.
I have read these StackOverflow Article 1, StackOverflow Article 2, But couldn't get much..
My Code in Abstract Class :
try {
long currentTime = System.currentTimeMillis();
try{
session = sessionFactory.getCurrentSession();
}catch(Exception e){}
if (session == null) {
session = sessionFactory.openSession();
isNewSession = true;
}
if (baseDO.isDeleted()) {
log.debug("Deleting instance" + baseDO.getId());
session.delete(baseDO);
} else if (baseDO.isInserted() || baseDO.isNew()) {
log.debug("Inserting instance");
baseDO.setVersionID(1l);
session.saveOrUpdate(this.getDOName(), baseDO);
} else if (baseDO.isUpdated()) {
log.debug("Updating instance");
//Session session = sessionFactory.getCurrentSession();
baseDO = (B) session.merge(this.getDOName(), baseDO);
session.saveOrUpdate(this.getDOName(), baseDO);
/* I'm getting here exactly on above Line */
// sessionFactory.getCurrentSession().saveOrUpdate(baseDO);
log.debug("Updated instance" + baseDO);
} else {
log.warn("*** Not persisting any Data for " + getDOName() + " ***");
}
log.debug("persist successful");
}
catch(StaleObjectStateException stoe){
log.error("persist failed due to stalestate", stoe);
throw stoe;
}
catch (RuntimeException re) {
log.error("persist failed", re);
throw re;
}
finally {
if (session != null && isNewSession)
session.close();
}
This is the Error I'm getting :
11:13:52,339 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) [ERROR] 11:13:52 AbstractDAO - persist failed due to stalestate
11:13:52,339 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [com.c2lbiz.symbiosys.insurance.businesscommon.dataobjects.payment.CompensationPayableDO#18238]
11:13:52,339 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.hibernate.event.def.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:261)
11:13:52,339 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:120)
11:13:52,339 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:53)
11:13:52,339 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:677)
11:13:52,339 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:661)
11:13:52,339 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at com.c2lbiz.symbiosys.systemcommon.dao.hibernate.AbstractDAO.save(AbstractDAO.java:549)
11:13:52,339 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at com.c2lbiz.symbiosys.systemcommon.business.BaseBO.save(BaseBO.java:291)
11:13:52,339 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at com.c2lbiz.symbiosys.interfaces.job.GlPostingWriter.execute(GlPostingWriter.java:63)
11:13:52,339 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at com.c2lbiz.symbiosys.interfaces.job.GlPostingWriter.execute(GlPostingWriter.java:1)
11:13:52,339 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at sun.reflect.GeneratedMethodAccessor598.invoke(Unknown Source)
11:13:52,339 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
11:13:52,354 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at java.lang.reflect.Method.invoke(Unknown Source)
11:13:52,354 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
11:13:52,354 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
11:13:52,354 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
11:13:52,354 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90)
11:13:52,354 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
11:13:52,354 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
11:13:52,354 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at $Proxy62.execute(Unknown Source)
11:13:52,354 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
11:13:52,354 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
11:13:52,354 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
11:13:52,354 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at java.lang.reflect.Method.invoke(Unknown Source)
11:13:52,354 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.util.MethodInvoker.invoke(MethodInvoker.java:273)
11:13:52,354 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.item.adapter.AbstractMethodInvokingDelegator.doInvoke(AbstractMethodInvokingDelegator.java:117)
11:13:52,354 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.item.adapter.AbstractMethodInvokingDelegator.invokeDelegateMethodWithArgument(AbstractMethodInvokingDelegator.java:72)
11:13:52,354 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.item.adapter.ItemWriterAdapter.write(ItemWriterAdapter.java:36)
11:13:52,354 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.core.step.item.SimpleChunkProcessor.writeItems(SimpleChunkProcessor.java:171)
11:13:52,354 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.core.step.item.SimpleChunkProcessor.doWrite(SimpleChunkProcessor.java:150)
11:13:52,370 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.core.step.item.SimpleChunkProcessor.write(SimpleChunkProcessor.java:269)
11:13:52,370 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.core.step.item.SimpleChunkProcessor.process(SimpleChunkProcessor.java:194)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.core.step.item.ChunkOrientedTasklet.execute(ChunkOrientedTasklet.java:74)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:386)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:264)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:76)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:367)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:214)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:143)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.core.step.tasklet.TaskletStep.doExecute(TaskletStep.java:250)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:195)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:135)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.core.job.flow.JobFlowExecutor.executeStep(JobFlowExecutor.java:61)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.core.job.flow.support.state.StepState.handle(StepState.java:60)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:144)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:124)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.core.job.flow.FlowJob.doExecute(FlowJob.java:135)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:281)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:120)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at java.lang.Thread.run(Unknown Source)
Please Help,
Thanks in Advance.
I'm trying to integrate a paypal payment to my JavaEE web application.
Every time I try to make a payment, it throw a 403 Error.
Here is the servlet I'm using:
#WebServlet(name="PaypalPayment", urlPatterns={"/paypal-payment.html"})
public class Paypal_Payment extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
OAuthTokenCredential token;
String accessToken;
APIContext apiContext;
Map<String, String> sdkConfig = new HashMap<String, String>();
sdkConfig.put("mode", "sandbox");
sdkConfig.put("service.EndPoint", "https://api.sandbox.paypal.com");
sdkConfig.put("client_id", Constantes.PAYPAL_CLIENT_ID);
sdkConfig.put("secret", Constantes.PAYPAL_CLIENT_SECRET);
try{
token = new OAuthTokenCredential(Constantes.PAYPAL_CLIENT_ID, Constantes.PAYPAL_CLIENT_SECRET, sdkConfig);
accessToken = token.getAccessToken();
apiContext = new APIContext(accessToken);
apiContext.setConfigurationMap(sdkConfig);
Amount amount = new Amount();
amount.setCurrency("EUR");
amount.setTotal("25");
Transaction transaction = new Transaction();
transaction.setDescription("Creating Payment");
transaction.setAmount(amount);
List<Transaction> transactions = new ArrayList<Transaction>();
transactions.add(transaction);
Payer payer = new Payer();
payer.setPaymentMethod("paypal");
Payment payment = new Payment();
payment.setIntent("sale");
payment.setPayer(payer);
payment.setTransactions(transactions);
RedirectUrls redirectUrls = new RedirectUrls();
redirectUrls.setCancelUrl("http://example.com/a-vos-cas-JSP/paypal-payment.html");
redirectUrls.setReturnUrl("http://example.com/a-vos-cas-JSP/paypal-payment.html");
payment.setRedirectUrls(redirectUrls);
Payment createdPayment = payment.create(apiContext);
System.out.println("createdPayment : " + createdPayment);
}catch(PayPalRESTException e){
e.printStackTrace();
}
getServletContext().getNamedDispatcher(Constantes.VUE_PAYPAL_RESPONSE).forward(request, response);
}
}
here is the console output:
14:26:15,550 INFO [stdout] (http--0.0.0.0-8080-6) curl command:
14:26:15,551 INFO [stdout] (http--0.0.0.0-8080-6) curl -v
'https://api.sandbox.paypal.com/v1/oauth2/token' \ 14:26:15,552 INFO
[stdout] (http--0.0.0.0-8080-6) -H "Authorization: Basic
QWJHQTFSQXVpeVA0RDVvQmt5d1o3dTBCanJJWkt0dm9CaVhTcDZ0QWFINlM4LXRFdzByX2hyRzNfbUZMOkVBRmhVQkJkZWRqTmJfTXV6SlNpbVI1YnY3SThQVzdwUldibGQ2aE9seThMZlNnRlhhbS1LaHJtRVZmZA=="
\ 14:26:15,552 INFO [stdout] (http--0.0.0.0-8080-6) -H "User-Agent:
PayPalSDK/paypal-core-java 1.5.0
(lang=Java;v=1.7.0_55;bit=64;os=Mac_OS_X 10.9.2)" \ 14:26:15,553 INFO
[stdout] (http--0.0.0.0-8080-6) -H "Accept: application/json" \
14:26:15,553 INFO [stdout] (http--0.0.0.0-8080-6) -d
'grant_type=client_credentials' 14:26:16,878 INFO [stdout]
(http--0.0.0.0-8080-6) curl command: 14:26:16,879 INFO [stdout]
(http--0.0.0.0-8080-6) curl -v
'https://api.sandbox.paypal.com/v1/payments/payment' \ 14:26:16,879
INFO [stdout] (http--0.0.0.0-8080-6) -H "Authorization: Bearer
A015iJYDQHdb7TJXzJzVIW-eSm1lP8NObGmlJkTzx2wVREo" \ 14:26:16,879 INFO
[stdout] (http--0.0.0.0-8080-6) -H "User-Agent:
PayPalSDK/rest-sdk-java 0.9.0 (lang=Java;v=1.7.0_55;bit=64;os=Mac_OS_X
10.9.2)" \ 14:26:16,880 INFO [stdout] (http--0.0.0.0-8080-6) -H "PayPal-Request-Id: 7b42030f-9b96-4027-9257-0c1311082fa2" \
14:26:16,880 INFO [stdout] (http--0.0.0.0-8080-6) -H "Content-Type:
application/json" \ 14:26:16,880 INFO [stdout] (http--0.0.0.0-8080-6)
-d '{ 14:26:16,880 INFO [stdout] (http--0.0.0.0-8080-6) "intent": "sale", 14:26:16,880 INFO [stdout] (http--0.0.0.0-8080-6) "payer":
{ 14:26:16,881 INFO [stdout] (http--0.0.0.0-8080-6)
"payment_method": "paypal" 14:26:16,881 INFO [stdout]
(http--0.0.0.0-8080-6) }, 14:26:16,881 INFO [stdout]
(http--0.0.0.0-8080-6) "transactions": [ 14:26:16,881 INFO [stdout]
(http--0.0.0.0-8080-6) { 14:26:16,881 INFO [stdout]
(http--0.0.0.0-8080-6) "amount": { 14:26:16,882 INFO [stdout]
(http--0.0.0.0-8080-6) "currency": "EUR", 14:26:16,882 INFO
[stdout] (http--0.0.0.0-8080-6) "total": "25" 14:26:16,882
INFO [stdout] (http--0.0.0.0-8080-6) }, 14:26:16,882 INFO
[stdout] (http--0.0.0.0-8080-6) "description": "Creating
Payment" 14:26:16,882 INFO [stdout] (http--0.0.0.0-8080-6) }
14:26:16,883 INFO [stdout] (http--0.0.0.0-8080-6) ], 14:26:16,883
INFO [stdout] (http--0.0.0.0-8080-6) "redirect_urls": {
14:26:16,883 INFO [stdout] (http--0.0.0.0-8080-6) "return_url":
"http://example.com/a-vos-cas-JSP/paypal-response.html",
14:26:16,883 INFO [stdout] (http--0.0.0.0-8080-6) "cancel_url":
"http://example.com/a-vos-cas-JSP/paypal-cancel.html" 14:26:16,884
INFO [stdout] (http--0.0.0.0-8080-6) } 14:26:16,884 INFO [stdout]
(http--0.0.0.0-8080-6) }' 14:26:17,909 Grave [class
com.paypal.core.HttpConnection] (http--0.0.0.0-8080-6) Error code :
403 with response : {"name":"REQUIRED_SCOPE_MISSING","message":"Access
token does not have required
scope","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#REQUIRED_SCOPE_MISSING","debug_id":"e066fbac38f41"}
14:26:17,911 ERROR [stderr] (http--0.0.0.0-8080-6)
com.paypal.core.rest.PayPalRESTException: Error code : 403 with
response : {"name":"REQUIRED_SCOPE_MISSING","message":"Access token
does not have required
scope","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#REQUIRED_SCOPE_MISSING","debug_id":"e066fbac38f41"}
So, there is a message saying that the scope could not be found, but I was not able to get any information about this error. I think I missed something in this servlet, but I can't find what. Any help would be appreciated :D
Thanks a lot
The answer is contained in this response:
{"name":"REQUIRED_SCOPE_MISSING",
"message":"Access token does not have required scope",
"information_link":"https://developer.paypal.com/webapps/developer/docs/api/#REQUIRED_SCOPE_MISSING",
"debug_id":"e066fbac38f41"}
There's some attribute in your app's configuration that's missing. Your best bet is to contact support with the debug_id listed. They can help get your account configured correctly.
i use smartgwt 2.5. i have a databound treegrid which fetches a json from the database and builds the tree. this works fine. the problem is when i try to reparent for example
at begin the tree looks like:
my json that is fetched from the db:
[{"id":"a","ReportsTo":"root","isFolder":"true","isOpen":"false"},{"id":"b","ReportsTo":"c","isFolder":"false", "isOpen":"false"},{"id":"c","ReportsTo":"root","isFolder":"true","isOpen":"true"},{"id":"d","ReportsTo":"a","isFolder":"false","isOpen":"false"}]
after reparent b (drag b at folder c and drop it into c) all leafs gets folders:
http://i.stack.imgur.com/lLHdX.png
this is send to the server:
{
12:46:52,773 INFO [stdout] (http--127.0.0.1-7443-4) "dataSource":"isc_RestDataSource_0",
12:46:52,773 INFO [stdout] (http--127.0.0.1-7443-4) "operationType":"update",
12:46:52,773 INFO [stdout] (http--127.0.0.1-7443-4) "data":{
12:46:52,773 INFO [stdout] (http--127.0.0.1-7443-4) "id":"b",
12:46:52,773 INFO [stdout] (http--127.0.0.1-7443-4) "ReportsTo":"c",
12:46:52,773 INFO [stdout] (http--127.0.0.1-7443-4) "isFolder":false,
12:46:52,773 INFO [stdout] (http--127.0.0.1-7443-4) "isOpen":"false"
12:46:52,773 INFO [stdout] (http--127.0.0.1-7443-4) },
12:46:52,773 INFO [stdout] (http--127.0.0.1-7443-4) "oldValues":{
12:46:52,773 INFO [stdout] (http--127.0.0.1-7443-4) "id":"b",
12:46:52,773 INFO [stdout] (http--127.0.0.1-7443-4) "ReportsTo":"a",
12:46:52,773 INFO [stdout] (http--127.0.0.1-7443-4) "isFolder":false,
12:46:52,773 INFO [stdout] (http--127.0.0.1-7443-4) "isOpen":"false"
12:46:52,773 INFO [stdout] (http--127.0.0.1-7443-4) }
12:46:52,773 INFO [stdout] (http--127.0.0.1-7443-4) }
after site refresh the tree is displayed correctly:
a
c
-b
-d
my code for the treegrid:
public class FavoritesGrid extends TreeGrid {
public FavoritesGrid() {
setWidth("12%");
setShowConnectors(false);
setShowResizeBar(true);
setCanReorderRecords(true);
setCanAcceptDroppedRecords(true);
setCanDragRecordsOut(true);
setCanReparentNodes(true);
setDragDataAction(DragDataAction.MOVE);
setAutoSaveEdits(false);
setAutoFetchData(false);
setLoadDataOnDemand(false); //load everything
setHeight("50%");
RestDataSource ds = new RestDataSource();
ds.setRecordXPath("/");
ds.setDataFormat(DSDataFormat.JSON);
OperationBinding fetch = new OperationBinding();
fetch.setOperationType(DSOperationType.FETCH);
fetch.setDataProtocol(DSProtocol.POSTMESSAGE);
fetch.setDataFormat(DSDataFormat.JSON);
OperationBinding add = new OperationBinding();
add.setOperationType(DSOperationType.ADD);
add.setDataProtocol(DSProtocol.POSTMESSAGE);
add.setDataFormat(DSDataFormat.JSON);
OperationBinding update = new OperationBinding();
update.setOperationType(DSOperationType.UPDATE);
update.setDataProtocol(DSProtocol.POSTMESSAGE);
update.setDataFormat(DSDataFormat.JSON);
ds.setOperationBindings(fetch, update, add);
ds.setDataURL("/Kronos/Favorites");
DataSourceTextField key = new DataSourceTextField("id", "id");
key.setPrimaryKey(true);
key.setRequired(true);
DataSourceTextField parent = new DataSourceTextField("ReportsTo",
"ReportsTo");
parent.setRequired(true);
parent.setForeignKey("id");
parent.setRootValue("root");
ds.setFields(key, parent);
//define properties
Tree tree = new Tree();
tree.setDefaultIsFolder(false); //default the nodes should be leafs
tree.setRootValue("root");
tree.setNameProperty("id");
tree.setIdField("id");
tree.setParentIdField("ReportsTo");
//the setOpenProperty also doesn't work
//if i set it smartgwt displays all folder opened
tree.setOpenProperty("isOpen");
//setIsFolderProperty is being ignored after reparent, need to refresh the site for correction
tree.setIsFolderProperty("isFolder");
setDataProperties(tree);
setDataSource(ds);
fetchData();
}
}
can somebody pls help me?