2017-12-11 10 views
0

現在のスレッドに対してトランザクション同期セッションを取得できませんでした。のみ特定のサービス層法に


 
@Aspect 
 
@Service("vendorNotificationService") 
 
@Transactional(rollbackFor=Exception.class) 
 
public class VendorNotificationServiceImpl implements vendorNotificationService { 
 
} 
 

 

 
@Repository("vendorNotificationDao") 
 
public class VendorNotificationDaoImpl implements VendorNotificationDao{ 
 

 
@SuppressWarnings("unchecked") 
 
\t @Override 
 
\t public List<VendorNotification> fetchAll(Integer startResult, Integer 
 
     maxResults) { 
 
\t \t log.info("in vendor Notification fetch all"); 
 
\t \t Criteria cr = this.getSessionFactory().createCriteria(VendorNotification.class); 
 
\t \t if ((startResult != null) && (maxResults != null) 
 
        && (maxResults != 0)) { 
 
        cr.setFirstResult(startResult); 
 
        cr.setMaxResults(maxResults); 
 
       } 
 
\t  return cr.list(); 
 
\t } 
 
    
 
    @SuppressWarnings("unchecked") 
 
\t @Override 
 
\t public List<DtoVendorNotification> getAllNotification(DetachedCriteria dcForNotification) { 
 
\t \t log.info("inside getAllNotification"); 
 
\t \t Criteria cr = this.getSessionFactory().createCriteria(VendorNotification.class,"vendorNotification"); 
 
\t \t cr.add(Subqueries.propertyIn("vendornotification.id", dcForNotification)); 
 
\t \t ProjectionList proList = Projections.projectionList(); 
 
\t \t proList.add(Projections.property("vendornotification.id"),"id"); 
 
\t \t cr.setProjection(proList); 
 
\t \t cr.setResultTransformer(Transformers.aliasToBean(DtoVendorNotification.class)); 
 
\t \t return cr.list(); 
 
\t } 
 
}

私の他のサービスとDAOは正常に動作しています。私は私のサービス層に @org.springframework.transaction.annotation.Transactionalを使用しています。突然、NotificationDaoと呼ばれるただ1つのDAOが問題を起こし始めました。このNotificationDaoにはエンティティを保存する別の方法があり、正常に動作します。結果をフェッチするための条件が作成された場合にのみ、例外がスローされます。

私も自分の要件の一部を同じ方法で@Aspectのアノテーションを使用しています。これが問題を作り出しているかどうかはわかりません。

2017-12-11 16:55:22 DEBUG AbstractTransactionImpl:175 - committing 
 
2017-12-11 16:55:23 DEBUG JdbcTransaction:113 - committed JDBC Connection 
 
2017-12-11 16:55:23 DEBUG JdbcTransaction:126 - re-enabling autocommit 
 
2017-12-11 16:55:23 DEBUG LogicalConnectionImpl:246 - Releasing JDBC connection 
 
2017-12-11 16:55:23 DEBUG LogicalConnectionImpl:264 - Released JDBC connection 
 
2017-12-11 16:55:23 INFO VendorNotificationDaoImpl:36 - in vendor Notification fetch all 
 
org.hibernate.HibernateException: Could not obtain transaction-synchronized Session for current thread 
 
\t at org.springframework.orm.hibernate4.SpringSessionContext.currentSession(SpringSessionContext.java:134) 
 
\t at org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:1014) 
 
\t at ather.inv.dao.impl.VendorNotificationDaoImpl.getSession(VendorNotificationDaoImpl.java:28) 
 
\t at ather.inv.dao.impl.VendorNotificationDaoImpl.fetchAll(VendorNotificationDaoImpl.java:37) 
 
\t at ather.inv.service.impl.VendorNotificationServiceImpl.fetchAll(VendorNotificationServiceImpl.java:47) 
 
\t at ather.inv.controllers.VendorController.vendorNotification(VendorController.java:30) 
 
\t at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
 
\t at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
 
\t at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
 
\t at java.lang.reflect.Method.invoke(Unknown Source) 
 
\t at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) 
 
\t at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136) 
 
\t at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:114) 
 
\t at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) 
 
\t at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) 
 
\t at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) 
 
\t at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963) 
 
\t at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) 
 
\t at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) 
 
\t at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861) 
 
\t at javax.servlet.http.HttpServlet.service(HttpServlet.java:621) 
 
\t at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) 
 
\t at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) 
 
\t at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) 
 
\t at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) 
 
\t at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) 
 
\t at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) 
 
\t at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) 
 
\t at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:317) 
 
\t at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127) 
 
\t at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91) 
 
\t at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) 
 
\t at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:115) 
 
\t at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) 
 
\t at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) 
 
\t at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) 
 
\t at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) 
 
\t at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) 
 
\t at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:169) 
 
\t at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) 
 
\t at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) 
 
\t at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) 
 
\t at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:200) 
 
\t at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) 
 
\t at org.springframework.security.web.csrf.CsrfFilter.doFilterInternal(CsrfFilter.java:100) 
 
\t at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 
 
\t at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) 
 
\t at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:66) 
 
\t at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 
 
\t at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) 
 
\t at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) 
 
\t at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 
 
\t at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) 
 
\t at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) 
 
\t at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) 
 
\t at org.springframework.security.web.access.channel.ChannelProcessingFilter.doFilter(ChannelProcessingFilter.java:157) 
 
\t at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) 
 
\t at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:214) 
 
\t at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177) 
 
\t at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) 
 
\t at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262) 
 
\t at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) 
 
\t at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) 
 
\t at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) 
 
\t at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) 
 
\t at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) 
 
\t at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) 
 
\t at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) 
 
\t at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) 
 
\t at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) 
 
\t at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) 
 
\t at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041) 
 
\t at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603) 
 
\t at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310) 
 
\t at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) 
 
\t at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 
 
\t at java.lang.Thread.run(Unknown Source)

+0

いくつかのコードサンプルを追加しようとしています。動作しているメソッドとfaultyメソッドです。 Stacktraceも役に立ちます –

+0

お時間をありがとう。私は追加しました。 –

+0

を参照してください.VendorNotificationDaoImpl.fetchAllでエラーが発生しているようです。コードを追加できますか?また、Transactionalではどの伝播を使用しますか?必要ですか? –

答えて

0

私は、同じサービスで@Aspectを使用しています。削除するとエラーが解決しました。もし誰かがこれに遭遇すれば、あなたの意見を述べてください。

関連する問題