Прежде всего, я могу успешно отладить приложение в Tomcat без каких-либо ошибок. Конечно, я не могу пройтись по клиентскому коду GWT в Tomcat, поэтому пытаюсь развернуть его на Jetty, что дает мне такую возможность.
Итак, я пытаюсь отладить приложение, использующее GWT (2.4.0) через Jetty в Eclipse, Hibernate 4.1.1 с использованием JPA и c3p0, и получаю следующее исключение.
Caused by: java.lang.ExceptionInInitializerError
at SOMETHING.HibernateUtil.<clinit>(HibernateUtil.java:23)
Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.service.jdbc.connections.spi.ConnectionProvider]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:186)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:150)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:223)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:89)
at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:71)
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2273)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2269)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1738)
at SOMETHING.HibernateUtil.<clinit>(HibernateUtil.java:20)
... 29 more
Caused by: org.hibernate.HibernateException: Could not instantiate connection provider [org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider]
at org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator.instantiateExplicitConnectionProvider(ConnectionProviderInitiator.java:192)
at org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator.initiateService(ConnectionProviderInitiator.java:114)
at org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator.initiateService(ConnectionProviderInitiator.java:54)
at org.hibernate.service.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:69)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:176)
... 41 more
Caused by: java.lang.ClassCastException: org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider cannot be cast to org.hibernate.service.jdbc.connections.spi.ConnectionProvider
at org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator.instantiateExplicitConnectionProvider(ConnectionProviderInitiator.java:189)
... 45 more
Я удалил информацию, такую как исключения вызовов RPC, внутри которой возникает исключение.
Мой HibernateUtil довольно ванильный:
public class HibernateUtil {
private static final SessionFactory sessionFactory;
private static ServiceRegistry serviceRegistry;
static {
try {
Configuration configuration = new Configuration();
configuration.configure();
serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();
sessionFactory = configuration.buildSessionFactory(serviceRegistry);
} catch (Throwable ex) {
// Log exception!
throw new ExceptionInInitializerError(ex);
}
}
public static Session getSession() throws HibernateException {
return sessionFactory.openSession();
}
public static SessionFactory get() {
return sessionFactory;
}
}
Мой файл hibernate.cfg.xml:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/dbname?autoReconnect=true</property>
<property name="connection.username">dbuser</property>
<property name="connection.password">dbpass</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<!-- Drop and re-create the database schema on startup -->
<property name="hibernate.hbm2ddl.auto">update</property>
<!-- hibernate.cfg.xml -->
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.timeout">1800</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.connection.provider_class">org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider</property>
<property name="hibernate.c3p0.idle_test_period">10</property>
<property name="hibernate.c3p0.acquire_increment">5</property>
<!-- no "connection.pool_size" entry! -->
<!-- JDBC connection pool (use the built-in) -->
<!-- <property name="connection.pool_size">1</property> -->
<property name="hibernate.transaction.auto_close_session">false</property>
<!-- Mapping files -->
<!-- several mapping class files here -->
</session-factory>
Библиотеки в моей папке WebContent / WEB-INF / lib:
antlr-2.7.7.jar
c3p0-0.9.1.2.jar
commons-collections-3.2.1.jar
commons-logging-1.1.1.jar
dom4j-1.6.1.jar
gwt-oauth2-0.2-alpha.jar
gwt-servlet.jar
hibernate-c3p0-4.1.1.Final.jar
hibernate-commons-annotations-4.0.1.Final.jar
hibernate-core-4.1.1.Final.jar
hibernate-jpa-2.0-api-1.0.1.Final.jar
httpclient-4.1.3.jar
httpcore-4.1.4.jar
javassist-3.15.0-GA.jar
jboss-logging-3.1.0.GA.jar
jboss-transaction-api_1.1_spec-1.0.0.Final.jar
log4j-1.2.14.jar
mysql-connector-java-5.1.18-bin.jar
В моем пути сборки Eclipse у меня hibernate-jpa-2.0-api-1.0.1.Final.jar
сверху, затем hibernate-core-4.1.1.Final.jar
. Остальные - это Apache Tomcat 6, EAR, GWT SDK 2.4.0, JRE 1.6.0.26 и библиотеки веб-приложений, указывающие на все библиотеки в моей папке lib (включая hibernate-jpa-2.0-api-1.0.1.Final
и hibernate-core-4.1.1.Final
). Я попытался включить c3p0 (гибернацию и / или реальную библиотеку) сверху безрезультатно. Та же ошибка Также пробовал несколько более старые версии библиотек Hibernate 4, но опять та же ошибка.
Есть идеи?