According to the error principle to solve the hibernate run appears no Currentsessioncontext configured! error

Source: Internet
Author: User

(1) The exception information is as follows:

Serious: Servlet.service () for Servlet action threw exception java.lang.RuntimeException: <u>no currentsessioncontext Configured!</u> at ( at ( at ( at Sun.reflect.NativeMethodAccessorImpl.invoke0 (Native method) at Sun.reflect.NativeMethodAccessorImpl.invoke ( at Sun.reflect.DelegatingMethodAccessorImpl.invoke (DELEGATINGMETHODACCESSORIMPL.JAVA:25) at Java.lang.reflect.Method.invoke ( at Org.apache.struts.actions.DispatchAction.dispatchMethod ( at Org.apache.struts.actions.DispatchAction.execute ( at Org.apache.struts.chain.commands.servlet.ExecuteAction.execute ( at Org.apache.struts.chain.commands.AbstractExecuteAction.execute ( at org.apache.struts.chAin.commands.ActionCommandBase.execute ( at Org.apache.commons.chain.impl.ChainBase.execute ( at Org.apache.commons.chain.generic.LookupCommand.execute ( at Org.apache.commons.chain.impl.ChainBase.execute ( at Org.apache.struts.chain.ComposableRequestProcessor.process ( at Org.apache.struts.action.ActionServlet.process ( at Org.apache.struts.action.ActionServlet.doPost ( at Javax.servlet.http.HttpServlet.service ( at Javax.servlet.http.HttpServlet.service ( at Org.apache.catalina.core.ApplicationFilterChain.internalDoFilter ( at Org.apache.catalina.core.ApplicationFilterChain.doFilter ( at Org.apache.catalina.core.StandardWrapperValve.invoke ( at Org.apache.catalina.core.StandardContexTvalve.invoke ( at Org.apache.catalina.core.StandardHostValve.invoke ( at Org.apache.catalina.valves.ErrorReportValve.invoke ( at Org.apache.catalina.core.StandardEngineValve.invoke ( at Org.apache.catalina.connector.CoyoteAdapter.service ( at Org.apache.coyote.http11.Http11Processor.process ( at Org.apache.coyote.http11.http11protocol$http11connectionhandler.process ( at$ ( at (

(2) Start debugging to find the cause of the problem:

The root of the problem is: no Currentsessioncontext configured! (Of course, there must be a lot of wrong explanations below.) )

Indicates: There is no currentsession context configuration. This is the thought of our use of currentsession when, in fact, is getcurrentsession when not in the Hibernate.cfg.xml file configuration.

(3) Principle of interpretation:

1. When the Sessionfactory (Session factory) is started, Hibernate will create the corresponding Currentsessioncontext according to the configuration.

When Getcurrentsession () is invoked, the method that is actually executed is currentsessioncontext.currentsession ().

2, here "according to the configuration" is the following configuration:

* If you are using a local transaction (JDBC Transaction local transaction: only one database)

<property name= "Hibernate.current_session_context_class" >thread</property>
* If you are using a global transaction (JTA Transaction Global transaction: Database has multiple)

(4) So the solution to the problem is based on the requirements of the Hibernate.cfg.xml file to add the above configuration can be.

NOTE: Reprint please indicate the source.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

Tags Index: