我在我的网络应用程序中收到"未找到线程绑定请求"错误,并希望得到一些帮助.我正在尝试使用struts2 + spring + hibernate,并使用spring来管理hibernate会话工厂,并将hibernate会话注入我的struts操作.我希望这是有道理的.当应用程序启动时,没有错误,但是当我发出第一个Web请求时,它会弹出"未找到线程绑定请求"错误.这是我的春季配置:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>
<bean id="hibernateSessionFactory" scope="singleton"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation" value="classpath:hibernate.cfg.xml" />
</bean>
<bean id="hibernateSession" factory-bean="hibernateSessionFactory"
factory-method="openSession" destroy-method="close" scope="request" class="org.hibernate.Session" />
</beans>
Run Code Online (Sandbox Code Playgroud)
这是我的行动:
package actions.events;
import org.hibernate.Session;
public class Listing {
Session session;
public void setHibernateSession(Session value) throws Exception
{
session = value;
}
public String execute() {
return "success";
}
}
Run Code Online (Sandbox Code Playgroud)
我唯一的领先是,如果我删除上面的'setHibernateSession'函数,我不会得到错误,因为如果动作不需要一个(懒惰的实例化),大概春天不打扰创建会话.
这是例外:
Unable to instantiate Action, actions.events.Listing, defined for 'Listing' in namespace '/events'Error creating bean with …Run Code Online (Sandbox Code Playgroud) 运行Grails应用程序时出错.
我的应用程序在Grails 2.1.4中工作.
我在用
Groovy 2.1.*
Java 1.7
Tomcat 7.0.37
Run Code Online (Sandbox Code Playgroud)
我将我的应用程序从Grails 2.1.4升级到2.3.0.M1.我收到这样的错误之后:
| Loading Grails 2.3.0.M1
| Configuring classpath
| Error SLF4J: Class path contains multiple SLF4J bindings.
| Error SLF4J: Found binding in [jar:file:/home/testuser/.m2/repository/org/grails/grails-plugin-log4j/2.3.0.M1/grails-plugin-log4j-2.3.0.M1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
| Error SLF4J: Found binding in [jar:file:/home/testuser/.m2/repository/org/slf4j/slf4j-log4j12/1.6.6/slf4j-log4j12-1.6.6.jar!/org/slf4j/impl/StaticLoggerBinder.class]
| Error SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
| Error SLF4J: Actual binding is of type [org.slf4j.impl.GrailsSlf4jLoggerFactory]
| Configuring classpath.
| Environment set to development.....
| Packaging Grails application.....
| Compiling 143 source files.
Copying properties file...
| …Run Code Online (Sandbox Code Playgroud)