2017-04-24 6 views
0

を無視しました。 @TransactionalはWebプロジェクトではうまく動作しますが、Dataでは無視されるようです。@Transactionalは、私はjarファイル(データ)を含めているSpring4 + Hibernate3のプロジェクト(ウェブ)を持っている

ファクト:両方のプロジェクトが同じパッケージに含まれています。 "com.awsmpkg"としましょう。

ここでは例外です:

org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here 
at org.springframework.orm.hibernate3.SpringSessionContext.currentSession(SpringSessionContext.java:67) 
at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:700) 
at com.awsmpkg.i18n.AWSMBookResourceBundle.getDescription(AWSMBookResourceBundle.java:77) 
at com.awsmpkg.i18n.AWSMBookResourceBundle.handleGetObject(AWSMBookResourceBundle.java:56) 
at com.awsmpkg.i18n.AWSMBookResourceBundle$$FastClassBySpringCGLIB$$a187c237.invoke(<generated>) 
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) 
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:652) 
at com.awsmpkg.i18n.AWSMBookResourceBundle_en$$EnhancerBySpringCGLIB$$44ff334a.handleGetObject(<generated>) 
at java.util.ResourceBundle.getObject(ResourceBundle.java:441) 
at java.util.ResourceBundle.getString(ResourceBundle.java:407) 
at com.awsmpkg.spring.util.CustomResourceBundleMessageSource.getStringOrNull(CustomResourceBundleMessageSource.java:29) 
at org.springframework.context.support.ResourceBundleMessageSource.resolveCodeWithoutArguments(ResourceBundleMessageSource.java:131) 
at org.springframework.context.support.AbstractMessageSource.getMessageInternal(AbstractMessageSource.java:209) 
at org.springframework.context.support.AbstractMessageSource.getMessage(AbstractMessageSource.java:151) 
at org.springframework.context.support.AbstractApplicationContext.getMessage(AbstractApplicationContext.java:1259) 
at org.springframework.web.servlet.tags.MessageTag.resolveMessage(MessageTag.java:241) 
at org.springframework.web.servlet.tags.MessageTag.doEndTag(MessageTag.java:180) 
at org.apache.jsp.WEB_002dINF.pages.selectManual_jsp._jspx_meth_spring_005fmessage_005f0(selectManual_jsp.java:321) 
at org.apache.jsp.WEB_002dINF.pages.selectManual_jsp._jspx_meth_c_005fforEach_005f0(selectManual_jsp.java:205) 
at org.apache.jsp.WEB_002dINF.pages.selectManual_jsp._jspService(selectManual_jsp.java:142) 
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) 
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:443) 
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385) 
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) 
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) 
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:728) 
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:467) 
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:392) 
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:311) 
at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:168) 
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303) 
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1282) 
at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1037) 
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:980) 
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:661) 
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) 
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) 
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:728) 
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:467) 
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:392) 
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:311) 
at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:168) 
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303) 
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1282) 
at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1037) 
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:980) 
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:661) 
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) 
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) 
at com.awsmpkg.spring.HibernateSessionFilter.doFilter(HibernateSessionFilter.java:137) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) 
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) 
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) 
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478) 
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) 
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80) 
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624) 
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) 
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:341) 
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783) 
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) 
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798) 
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1441) 
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) 
at java.lang.Thread.run(Thread.java:745) 
org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspTagException: No message found under code 'm_6303' for locale 'en_US'. 
at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:601) 
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:466) 
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385) 
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) 
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) 
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:728) 
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:467) 
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:392) 
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:311) 
at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:168) 
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303) 
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1282) 
at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1037) 
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:980) 
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:661) 
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) 
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) 
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:728) 
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:467) 
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:392) 
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:311) 
at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:168) 
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303) 
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1282) 
at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1037) 
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:980) 
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:661) 
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) 
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) 
at com.awsmpkg.spring.HibernateSessionFilter.doFilter(HibernateSessionFilter.java:137) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) 
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) 
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) 
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478) 
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) 
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80) 
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624) 
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) 
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:341) 
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783) 
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) 
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798) 
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1441) 
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) 
at java.lang.Thread.run(Thread.java:745) 
Caused by: javax.servlet.ServletException: javax.servlet.jsp.JspTagException: No message found under code 'm_6303' for locale 'en_US'. 
at org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:909) 
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:838) 
at org.apache.jsp.WEB_002dINF.pages.selectManual_jsp._jspService(selectManual_jsp.java:159) 
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) 
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:443) 
... 68 more 
Caused by: javax.servlet.jsp.JspTagException: No message found under code 'm_6303' for locale 'en_US'. 
at org.springframework.web.servlet.tags.MessageTag.doEndTag(MessageTag.java:200) 
at org.apache.jsp.WEB_002dINF.pages.selectManual_jsp._jspx_meth_spring_005fmessage_005f0(selectManual_jsp.java:321) 
at org.apache.jsp.WEB_002dINF.pages.selectManual_jsp._jspx_meth_c_005fforEach_005f0(selectManual_jsp.java:205) 
at org.apache.jsp.WEB_002dINF.pages.selectManual_jsp._jspService(selectManual_jsp.java:142) 
... 71 more 

それはsessionFactory.getCurrentSession()が発生した行に私を送信します。 Class from Dataプロジェクト。

package com.awsmpkg.i18n; 

@Service("resourceBundle") 
public class AwesomeClass { 

    @Autowired 
    private SessionFactory sessionFactory; 

    @Transactional("transactionManager") 
    public String getDescription(String key) { 
     Session session = sessionFactory.getCurrentSession(); // here 
     return "Whatever"; 
    } 

WebプロジェクトからappContext.xml

<?xml version="1.0" encoding="UTF-8" ?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:context="http://www.springframework.org/schema/context" 
    xmlns:mvc="http://www.springframework.org/schema/mvc" 
    xmlns:tx="http://www.springframework.org/schema/tx" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
    https://www.springframework.org/beans/spring-beans.xsd 
    http://www.springframework.org/schema/context https://www.springframework.org/context/spring-context.xsd 
    http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> 

<mvc:annotation-driven/> 
<tx:annotation-driven/> 

<!-- Web App --> 
<context:component-scan base-package="com.awsmpkg"/> 
<context:annotation-config/> 

<!-- SessionFactory --> 
<bean id="sessionFactory" 
     class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> 
    <property name="configLocation" value="classpath:hibernate.cfg.xml"/> 
</bean> 

<bean id="transactionManager" 
     class="org.springframework.orm.hibernate3.HibernateTransactionManager"> 
    <property name="sessionFactory" ref="sessionFactory" /> 
</bean> 

<!-- SessionFactoryUsers --> 
<bean id="sessionFactoryUsers" 
     class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> 
    <property name="configLocation" value="classpath:hibernateUsers.cfg.xml"/> 
</bean> 

<bean id="transactionManagerUsers" 
     class="org.springframework.orm.hibernate3.HibernateTransactionManager"> 
    <property name="sessionFactory" ref="sessionFactoryUsers" /> 
</bean> 

<bean id="messageSource" 
class="com.awsmpkg.spring.util.CustomResourceBundleMessageSource"> 
    <property name="basenames"> 
     <list> 
      <value>resourceBundle</value> 
     </list> 
    </property> 
</bean> 

</beans> 
+0

関連と思われる、この質問を見てください。それはSpringによって管理されるBeanですか? –

+0

はい、実際はResourceBundleクラスです。私は春にBeanを作ったのです。 –

+0

スタックトレースを共有できますか? –

答えて

関連する問題