0

在 Android 项目中,我使用 spring REST lib 在Apache Tomcat/7.0.32上调用 jax-rs 服务。对于数据库通信,我使用的是hibernate 3.0

有时 API 返回错误:org.hibernate.exception.JDBCConnectionException: could not execute query

我认为问题出在休眠SessionFactory中。

想知道如何配置 tomcat web 服务以在企业环境中使用。如何配置休眠 SessionFactory 以处理更多请求。

休眠.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
  <session-factory>
    <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="connection.url">jdbc:mysql://xxxxxx:3306/databasename</property>
    <property name="connection.username">xxxx</property>
    <property name="connection.password">xxxx</property>
    <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
    <property name="hibernate.hbm2ddl.auto">update</property>
    <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
    <property name="current_session_context_class">thread</property>
    <property name="show_sql">false</property>
    <!-- Mapping files -->
    <mapping class="com.fit.model.Users"/>
    <mapping class="com.fit.model.Friends"/>
    <mapping class="com.fit.model.NewsFeed"/>
  </session-factory>
</hibernate-configuration>

HibernateUtil.java

import org.hibernate.*;
import org.hibernate.cfg.*;

public class HibernateUtil {
    private static final SessionFactory sessionFactory;

    static {
        try {
            sessionFactory = new AnnotationConfiguration().configure()
                .buildSessionFactory();
        } catch (Throwable ex) {
            throw new ExceptionInInitializerError(ex);
        }
    }


    public static SessionFactory getSessionFactory() {
        return sessionFactory;
    }


    public static Session getSession() throws HibernateException {
        Session session = sessionFactory.openSession();
        Transaction trans = session.getTransaction();

        if (trans == null || !trans.isActive())
            session.beginTransaction();

        return session;
    }

    public static void commit(Session session) {

        if (session.getTransaction() != null) {

            try {
                session.getTransaction().commit();
            } catch (TransactionException e) {

            } finally {

                if (session != null) {
                    org.hibernate.context.ThreadLocalSessionContext.unbind(HibernateUtil.getSessionFactory());
                    session.close();
                }
            }
        }
    }


    public static void closeSession(Session session) {
        try {
            if (session != null) {
                session.close();
            }
        } catch (Exception e) {

        }
    }
}

BaseDAO.java

import java.io.Serializable;
import java.lang.reflect.ParameterizedType;
import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.FetchMode;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.hibernate.transform.DistinctRootEntityResultTransformer;

public abstract class BaseDAO < T, TID extends Serializable > {
    private Class << ? > theClass;

    public BaseDAO() {
        ParameterizedType type = (ParameterizedType) getClass()
            .getGenericSuperclass();
        this.theClass = (Class << ? > ) type.getActualTypeArguments()[0];
    }

    @SuppressWarnings("unchecked")
    public T getById(TID id) {

        Session session = HibernateUtil.getSession();

        Criteria criteria = session.createCriteria(theClass);
        T obj = (T) criteria.add(Restrictions.idEq(id)).uniqueResult();


        HibernateUtil.commit(session);
        return obj;
    }

    @SuppressWarnings("unchecked")
    public TID insert(T newObj) {

        Session sesija = HibernateUtil.getSession();

        TID id = (TID) sesija.save(newObj);
        HibernateUtil.commit(sesija);
        return id;
    }

    public List < T > getAll() {
        Session session = HibernateUtil.getSession();
        List < T > all = getAll_fetchEager();
        HibernateUtil.commit(session);
        return all;
    }

    @SuppressWarnings("unchecked")
    public T getById_fetchEager(TID id, String...relations) {
        Criteria criteria = HibernateUtil.getSession().createCriteria(theClass);
        for (String s: relations)
            criteria.setFetchMode(s, FetchMode.JOIN);
        return (T) criteria.add(Restrictions.idEq(id)).uniqueResult();
    }

    @SuppressWarnings("unchecked")
    public List < T > getAll_fetchEager(String...relations) {
        Criteria criteria = HibernateUtil
            .getSession()
            .createCriteria(theClass)
            .setResultTransformer(new DistinctRootEntityResultTransformer());

        for (String s: relations)
            criteria.setFetchMode(s, FetchMode.JOIN);

        return criteria.list();
    }

    public void update(T obj) {
        Session session = HibernateUtil.getSession();
        session.update(obj);
        HibernateUtil.commit(session);
    }

    public void saveOrUpdate(T obj) {
        Session session = HibernateUtil.getSession();
        session.saveOrUpdate(obj);
        HibernateUtil.commit(session);
    }

    public void remove(T obj) {
        Session session = HibernateUtil.getSession();
        session.delete(obj);
        HibernateUtil.commit(session);
    }
}

Jax-rs 服务-登录

@GET
@Produces("application/json")
@Path("login")
public Users Login(@QueryParam("username") String username, @QueryParam("password") String password) {

    Session session = null;

    try {

        String hql = "select k from Users k where k.username like :p1 and k.password like :p2";

        session = HibernateUtil.getSession();

        Query q = session.createQuery(hql).setParameter("p1", username).setParameter("p2", password);

        if (q.list().size() == 0) {
            HibernateUtil.closeSession(session);
            return new Users();
        } else {
            Users k = (Users) q.list().get(0);
            HibernateUtil.closeSession(session);
            return k;
        }

    } catch (Exception e) {
        HibernateUtil.closeSession(session);
    }
}

Tomcat日志:

at com.mysql.jdbc.StatementImpl.checkClosed(StatementImpl.java:461)
at com.mysql.jdbc.StatementImpl.getMaxRows(StatementImpl.java:2216)
at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:272)
at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:209)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1682)
at org.hibernate.loader.Loader.doQuery(Loader.java:662)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2144)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2028)
at org.hibernate.loader.Loader.list(Loader.java:2023)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:393)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at com.fit.servis.Korisnik_servis.Login(Korisnik_servis.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:185)
at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1483)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1414)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1363)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1353)
at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:414)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:708)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at com.googlecode.psiprobe.Tomcat70AgentValve.invoke(Tomcat70AgentValve.java:38)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.ajp.AjpAprProcessor.process(AjpAprProcessor.java:197)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1852)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
18:45:00,463 WARN JDBCExceptionReporter:71 - SQL Error: 0, SQLState: 08S01
18:45:00,463 ERROR JDBCExceptionReporter:72 - Communications link failure
The last packet successfully received from the server was 176,214 milliseconds ago. The last packet sent successfully to the server was 0 milliseconds ago.
sesija je otvorena
18:47:20,756 WARN JDBCExceptionReporter:71 - SQL Error: 0, SQLState: 08003
18:47:20,758 ERROR JDBCExceptionReporter:72 - No operations allowed after connection closed.
Exception in thread "ajp-apr-11178-exec-42"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-42"
Exception in thread "scheduler_QuartzSchedulerThread"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "scheduler_QuartzSchedulerThread"
Exception in thread "ajp-apr-11178-exec-44"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-44"
Exception in thread "ajp-apr-11178-exec-48"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-48"
Exception in thread "ajp-apr-11178-exec-49"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-49"
Exception in thread "ajp-apr-11178-exec-50"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-50"
Exception in thread "ajp-apr-11178-exec-41"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-41"
Exception in thread "ajp-apr-11178-exec-52"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-52"
Exception in thread "ajp-apr-11178-exec-47"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-47"
Exception in thread "ajp-apr-11178-exec-51"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-51"
Exception in thread "ajp-apr-11178-exec-57"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-57"
Exception in thread "ajp-apr-11178-exec-43"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-43"
Exception in thread "ajp-apr-11178-exec-59"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-59"
Exception in thread "ajp-apr-11178-exec-45"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-45"
Exception in thread "ajp-apr-11178-exec-53"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-53"
Exception in thread "ajp-apr-11178-exec-55"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-55"
Exception in thread "ajp-apr-11178-exec-56"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-56"
Exception in thread "ajp-apr-11178-exec-64"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-64"
Exception in thread "ajp-apr-11178-exec-54"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-54"
Exception in thread "ajp-apr-11178-exec-62"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-62"
Exception in thread "ajp-apr-11178-exec-60"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-60"
Exception in thread "ajp-apr-11178-exec-58"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-58"
Exception in thread "ajp-apr-11178-exec-65"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-65"
Exception in thread "ajp-apr-11178-exec-63"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-63"
Exception in thread "ajp-apr-11178-exec-67"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-67"
Exception in thread "ajp-apr-11178-exec-61"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-61"
Exception in thread "ajp-apr-11178-exec-66"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-66"
Exception in thread "ajp-apr-11178-exec-74"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-74"
Exception in thread "ajp-apr-11178-exec-75"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-75"
Exception in thread "ajp-apr-11178-exec-76"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-76"
Exception in thread "ajp-apr-11178-exec-70"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-70"
Exception in thread "ajp-apr-11178-exec-71"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-71"
Exception in thread "ajp-apr-11178-exec-72"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-72"
Exception in thread "ajp-apr-11178-exec-73"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-73"
Exception in thread "ajp-apr-11178-exec-77"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-77"
Exception in thread "ajp-apr-11178-exec-78"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-78"
Exception in thread "ajp-apr-11178-exec-79"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-79"
Exception in thread "ajp-apr-11178-exec-46"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-46"
Exception in thread "ajp-apr-11178-exec-68"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-68"
Exception in thread "ajp-apr-11178-exec-69"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-69"
Exception in thread "ajp-apr-11178-exec-80"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-80"
Exception in thread "ajp-apr-11178-exec-81"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-81"
Exception in thread "ajp-apr-11178-exec-89"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-89"
Exception in thread "ajp-apr-11178-exec-83"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-83"
Exception in thread "ajp-apr-11178-exec-84"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-84"
Exception in thread "ajp-apr-11178-exec-85"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-85"
Exception in thread "ajp-apr-11178-exec-93"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-93"
Exception in thread "ajp-apr-11178-exec-94"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-94"
Exception in thread "ajp-apr-11178-exec-88"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-88"
Exception in thread "ajp-apr-11178-exec-92"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-92"
Exception in thread "ajp-apr-11178-exec-90"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-90"
Exception in thread "ajp-apr-11178-exec-91"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-91"
Exception in thread "ajp-apr-11178-exec-95"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-95"
Exception in thread "ajp-apr-11178-exec-87"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-87"
Exception in thread "ajp-apr-11178-exec-101"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-101"
Exception in thread "ajp-apr-11178-exec-98"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-98"
Exception in thread "ajp-apr-11178-exec-100"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-100"
Exception in thread "ajp-apr-11178-exec-97"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-97"
Exception in thread "ajp-apr-11178-exec-82"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-82"
Exception in thread "ajp-apr-11178-exec-106"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-106"
Exception in thread "ajp-apr-11178-exec-103"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-103"
Exception in thread "ajp-apr-11178-exec-104"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-104"
Exception in thread "ajp-apr-11178-exec-102"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-102"
Exception in thread "ajp-apr-11178-exec-86"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-86"
Exception in thread "ajp-apr-11178-exec-107"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-107"
Exception in thread "ajp-apr-11178-exec-96"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-96"
Exception in thread "ajp-apr-11178-exec-109"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-109"
Exception in thread "ajp-apr-11178-exec-110"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ajp-apr-11178-exec-110"
sesija je otvorena
21:09:45,659 WARN JDBCExceptionReporter:71 - SQL Error: 0, SQLState: 08003
21:09:45,660 ERROR JDBCExceptionReporter:72 - No operations allowed after connection closed.
Mar 31, 2013 9:10:08 PM org.apache.catalina.core.AprLifecycleListener init
INFO: Loaded APR based Apache Tomcat Native library 1.1.27 using APR version 1.4.6.
Mar 31, 2013 9:10:08 PM org.apache.catalina.core.AprLifecycleListener init
INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
Mar 31, 2013 9:10:08 PM org.apache.catalina.core.AprLifecycleListener initializeSSL
INFO: OpenSSL successfully initialized (OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008)
Mar 31, 2013 9:10:08 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-apr-11314"]
Mar 31, 2013 9:10:08 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-apr-11178"]
Mar 31, 2013 9:10:08 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 589 ms
Mar 31, 2013 9:10:08 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Mar 31, 2013 9:10:08 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.37
Mar 31, 2013 9:10:08 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /home/harisda/appservers/apache-tomcat-7.0.37/webapps/probe.war
Mar 31, 2013 9:10:11 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /home/harisda/appservers/apache-tomcat-7.0.37/webapps/AndroidServis.war
Mar 31, 2013 9:10:12 PM com.sun.jersey.api.core.PackagesResourceConfig init
INFO: Scanning for root resource and provider classes in the packages:
com.fit.servis
org.codehaus.jackson.jaxrs
Mar 31, 2013 9:10:12 PM com.sun.jersey.api.core.ScanningResourceConfig logClasses
INFO: Root resource classes found:
class com.fit.servis.Korisnik_servis
class com.fit.servis.Obavijesti_servis
Mar 31, 2013 9:10:12 PM com.sun.jersey.api.core.ScanningResourceConfig logClasses
INFO: Provider classes found:
class org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider
class org.codehaus.jackson.jaxrs.JsonMappingExceptionMapper
class org.codehaus.jackson.jaxrs.JsonParseExceptionMapper
class org.codehaus.jackson.jaxrs.JacksonJsonProvider
Mar 31, 2013 9:10:13 PM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.12 02/15/2012 04:51 PM'
Mar 31, 2013 9:10:13 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /home/harisda/appservers/apache-tomcat-7.0.37/webapps/manager
Mar 31, 2013 9:10:13 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /home/harisda/appservers/apache-tomcat-7.0.37/webapps/host-manager
Mar 31, 2013 9:10:13 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /home/harisda/appservers/apache-tomcat-7.0.37/webapps/ROOT
Mar 31, 2013 9:10:13 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /home/harisda/appservers/apache-tomcat-7.0.37/webapps/docs
Mar 31, 2013 9:10:13 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /home/harisda/appservers/apache-tomcat-7.0.37/webapps/examples
Mar 31, 2013 9:10:13 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-apr-11314"]
Mar 31, 2013 9:10:13 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-apr-11178"]
Mar 31, 2013 9:10:13 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 5358 ms

更新:

异常解决方案:org.hibernate.exception.JDBCConnectionException: could not execute querysql-error-0-sqlstate-08s01.html

4

1 回答 1

1

您可以按照文档中的建议使用 JTA:http: //docs.jboss.org/hibernate/orm/3.3/reference/en/html/architecture.html#architecture-current-session

如果您正在寻找“更多企业”的东西,我建议您使用 SessionManager 和连接池。这将为您的应用程序提供更多选择和灵活性。Spring 在这方面提供了一些不错的特性。

干杯,

于 2013-04-01T03:18:35.387 回答