以前は、ここに示すように Hibernate + c3p0 + ehcache を適切に構成しました。今は、HikariCP のようなより強力なプールを使用しようとしています。まず、Hibernate + HikariCP をこの別の投稿で示されているように構成してみます。
今まで、HikariCP で Hibernate をうまく使用できましたが、EHCache を追加すると (最初のリンクに示されているように)、アプリの起動に失敗します。エラーは発生しません。アプリが停止するだけで、セッションファクトリーを作成してみてください。
ログ(スタックオーバーフローが非常に長いため完全なログを記録できないため、同様の行をいくつか削除します)。
NetBeans: JPDA Listening Start...
JPDA Address: ******:50991
Port:50991
cd D:\****\Código; "JAVA_HOME=C:\\Program Files\\Java\\jdk1.8.0_40" cmd /c "\"\"C:\\Program Files\\NetBeans 8.0.1\\java\\maven\\bin\\mvn.bat\" -Drunfx.args=\"-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=50991 -jar ${project.build.directory}/${project.build.finalName}.jar\" -Djpda.listen=true -DskipTests=true -Djpda.address=50991 -Dmaven.ext.class.path=C:\\Users\\Marcos\\AppData\\Roaming\\NetBeans\\8.0.1\\maven-nblib\\netbeans-eventspy.jar -Dfile.encoding=UTF-8 org.codehaus.mojo:exec-maven-plugin:1.2.1:exec\""
Running NetBeans Compile On Save execution. Phase execution is skipped and output directories of dependency projects (with Compile on Save turned on) will be used instead of their jar artifacts.
Scanning for projects...
------------------------------------------------------------------------
Building **** 1.0-SNAPSHOT
------------------------------------------------------------------------
The artifact xml-apis:xml-apis:jar:2.0.2 has been relocated to xml-apis:xml-apis:jar:1.0.b2
--- exec-maven-plugin:1.2.1:exec (default-cli) @ **** ---
Logging Provider: org.jboss.logging.Log4jLoggerProvider
Adding type registration boolean -> org.hibernate.type.BooleanType@601bc59e
.....
HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
HHH000412: Hibernate Core {4.3.7.Final}
HHH000206: hibernate.properties not found
HHH000021: Bytecode provider name : javassist
Registering IdentifierGenerator strategy [uuid2] -> [org.hibernate.id.UUIDGenerator]
Registering IdentifierGenerator strategy [guid] -> [org.hibernate.id.GUIDGenerator]
Registering IdentifierGenerator strategy [uuid] -> [org.hibernate.id.UUIDHexGenerator]
Registering IdentifierGenerator strategy [uuid.hex] -> [org.hibernate.id.UUIDHexGenerator]
Registering IdentifierGenerator strategy [hilo] -> [org.hibernate.id.TableHiLoGenerator]
Registering IdentifierGenerator strategy [assigned] -> [org.hibernate.id.Assigned]
Registering IdentifierGenerator strategy [identity] -> [org.hibernate.id.IdentityGenerator]
Registering IdentifierGenerator strategy [select] -> [org.hibernate.id.SelectGenerator]
Registering IdentifierGenerator strategy [sequence] -> [org.hibernate.id.SequenceGenerator]
Registering IdentifierGenerator strategy [seqhilo] -> [org.hibernate.id.SequenceHiLoGenerator]
Registering IdentifierGenerator strategy [increment] -> [org.hibernate.id.IncrementGenerator]
Registering IdentifierGenerator strategy [foreign] -> [org.hibernate.id.ForeignGenerator]
Registering IdentifierGenerator strategy [sequence-identity] -> [org.hibernate.id.SequenceIdentityGenerator]
Registering IdentifierGenerator strategy [enhanced-sequence] -> [org.hibernate.id.enhanced.SequenceStyleGenerator]
Registering IdentifierGenerator strategy [enhanced-table] -> [org.hibernate.id.enhanced.TableGenerator]
HHH000043: Configuring from resource: /hibernate.cfg.xml
HHH000040: Configuration resource: /hibernate.cfg.xml
Trying to resolve system-id [http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd]
Recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
Located [http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd] in classpath
hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.hikari.dataSourceClassName=com.mysql.jdbc.jdbc2.optional.MysqlDataSource
hibernate.hikari.dataSource.url=jdbc:mysql://localhost:3307/****?zeroDateTimeBehavior=convertToNull
hibernate.hikari.dataSource.user=****
hibernate.hikari.dataSource.password=****1
javax.persistence.validation.mode=none
connection.release_mode=after_transaction
current_session_context_class=thread
show_sql=true
format_sql=true
hibernate.temp.use_jdbc_metadata_defaults=false
hibernate.connection.provider_class=com.zaxxer.hikari.hibernate.HikariConnectionProvider
hibernate.hikari.dataSource.cachePrepStmts=true
hibernate.hikari.dataSource.prepStmtCacheSize=250
hibernate.hikari.dataSource.prepStmtCacheSqlLimit=2048
hibernate.hikari.dataSource.useServerPrepStmts=true
hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider
hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory
hibernate.cache.use_second_level_cache=true
hibernate.cache.use_query_cache=true
net.sf.ehcache.configurationResourceName=/ehcache.xml
Session-factory config [null] named resource [com/****/mapeos/****.hbm.xml] for mapping
HHH000221: Reading mappings from resource: com/****/mapeos/****.hbm.xml
Trying to resolve system-id [http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd]
Recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
Located [http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd] in classpath
Session-factory config [null] named resource [com/****/mapeos/****.hbm.xml] for mapping
HHH000221: Reading mappings from resource: com/****/mapeos/****.hbm.xml
Trying to resolve system-id [http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd]
Recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
Located [http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd] in classpath
Session-factory config [null] named resource [com/****/mapeos/****.hbm.xml] for mapping
HHH000221: Reading mappings from resource: com/****/mapeos/****.hbm.xml
Trying to resolve system-id [http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd]
Recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
Located [http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd] in classpath
Session-factory config [null] named resource [com/****/mapeos/********.hbm.xml] for mapping
HHH000221: Reading mappings from resource: com/****/mapeos/********.hbm.xml
Trying to resolve system-id [http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd]
Recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
Located [http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd] in classpath
Session-factory config [null] named resource [com/****/mapeos/****.hbm.xml] for mapping
HHH000221: Reading mappings from resource: com/****/mapeos/****.hbm.xml
Trying to resolve system-id [http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd]
Recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
Located [http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd] in classpath
Session-factory config [null] named resource [com/****/mapeos/****.hbm.xml] for mapping
HHH000221: Reading mappings from resource: com/****/mapeos/****.hbm.xml
Trying to resolve system-id [http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd]
Recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
Located [http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd] in classpath
Session-factory config [null] named resource [com/****/mapeos/********.hbm.xml] for mapping
HHH000221: Reading mappings from resource: com/****/mapeos/********.hbm.xml
Trying to resolve system-id [http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd]
Recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
Located [http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd] in classpath
Session-factory config [null] named resource [com/****/mapeos/****.hbm.xml] for mapping
HHH000221: Reading mappings from resource: com/****/mapeos/****.hbm.xml
Trying to resolve system-id [http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd]
Recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
Located [http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd] in classpath
Session-factory config [null] named resource [com/****/mapeos/****Categoria.hbm.xml] for mapping
HHH000221: Reading mappings from resource: com/****/mapeos/****Categoria.hbm.xml
Trying to resolve system-id [http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd]
Recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
Located [http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd] in classpath
HHH000041: Configured SessionFactory: null
Properties: {java.vendor=Oracle Corporation, show_sql=true, sun.java.launcher=SUN_STANDARD, sun.management.compiler=HotSpot 64-Bit Tiered Compilers, os.name=Windows 8.1, sun.boot.class.path=C:\Program Files\Java\jdk1.8.0_40\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_40\jre\lib\rt.jar;C:\Program Files\Java\jdk1.8.0_40\jre\lib\sunrsasign.jar;C:\Program Files\Java\jdk1.8.0_40\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_40\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_40\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_40\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_40\jre\classes, hibernate.temp.use_jdbc_metadata_defaults=false, hibernate.current_session_context_class=thread, sun.desktop=windows, java.vm.specification.vendor=Oracle Corporation, java.runtime.version=1.8.0_40-ea-b11, hibernate.hikari.dataSource.cachePrepStmts=true, hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider, user.name=Marcos, javax.persistence.validation.mode=none, hibernate.connection.release_mode=after_transaction, current_session_context_class=thread, javafx.runtime.version=8.0.40-ea-b11, user.language=es, hibernate.hikari.dataSource.prepStmtCacheSqlLimit=2048, sun.boot.library.path=C:\Program Files\Java\jdk1.8.0_40\jre\bin, hibernate.hikari.dataSource.prepStmtCacheSize=250, java.version=1.8.0_40-ea, user.timezone=Europe/Paris, sun.arch.data.model=64, java.endorsed.dirs=C:\Program Files\Java\jdk1.8.0_40\jre\lib\endorsed, sun.cpu.isalist=amd64, sun.jnu.encoding=Cp1252, file.encoding.pkg=sun.io, file.separator=\, java.specification.name=Java Platform API Specification, hibernate.format_sql=true, java.class.version=52.0, user.country=ES, java.home=C:\Program Files\Java\jdk1.8.0_40\jre, java.vm.info=mixed mode, os.version=6.3, path.separator=;, java.vm.version=25.40-b15, hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory, user.variant=, java.awt.printerjob=sun.awt.windows.WPrinterJob, sun.io.unicode.encoding=UnicodeLittle, awt.toolkit=sun.awt.windows.WToolkit, hibernate.javax.persistence.validation.mode=none, user.script=, user.home=C:\Users\Marcos, java.specification.vendor=Oracle Corporation, hibernate.hikari.dataSource.user=****, java.library.path=C:\Program Files\Java\jdk1.8.0_40\jre\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\PHP\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Java\jdk1.8.0_40\bin;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Inno Setup 5;C:\Program Files (x86)\WiX Toolset v3.8\bin;C:\Program Files (x86)\MySQL\MySQL Utilities\;C:\Program Files (x86)\MySQL\MySQL Utilities\Doctrine extensions for PHP\;C:\cygwin64;D:\Servidor\bin\apache\apache2.2.22\bin;D:\Servidor\bin\php\php5.3.13;D:\Servidor\bin\php\php5.3.13\pear;D:\Servidor\bin\php\php5.3.13\imagick;D:\Servidor\tools\imagemagick\imagemagick6.8.9-7;D:\Servidor\tools\svn\svn1.7.14\bin;D:\Servidor\tools\git\git1.8.4\bin;;C:\Program Files (x86)\QuickTime\QTSystem\;., java.vendor.url=http://java.oracle.com/, java.vm.vendor=Oracle Corporation, hibernate.dialect=org.hibernate.dialect.MySQLDialect, java.runtime.name=Java(TM) SE Runtime Environment, sun.java.command=D:\****\Código\target/****-1.0-SNAPSHOT.jar, java.class.path=D:\****\Código\target/****-1.0-SNAPSHOT.jar, hibernate.net.sf.ehcache.configurationResourceName=/ehcache.xml, hibernate.bytecode.use_reflection_optimizer=false, java.vm.specification.name=Java Virtual Machine Specification, hibernate.hikari.dataSource.password=****1, java.vm.specification.version=1.8, hibernate.cache.use_query_cache=true, sun.cpu.endian=little, hibernate.hikari.dataSource.url=jdbc:mysql://localhost:3307/****?zeroDateTimeBehavior=convertToNull, sun.os.patch.level=, hibernate.connection.provider_class=com.zaxxer.hikari.hibernate.HikariConnectionProvider, java.io.tmpdir=C:\Users\Marcos\AppData\Local\Temp\, java.vendor.url.bug=http://bugreport.sun.com/bugreport/, connection.release_mode=after_transaction, os.arch=amd64, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, java.ext.dirs=C:\Program Files\Java\jdk1.8.0_40\jre\lib\ext;C:\WINDOWS\Sun\Java\lib\ext, user.dir=D:\****\Código, line.separator=
, java.vm.name=Java HotSpot(TM) 64-Bit Server VM, hibernate.hikari.dataSourceClassName=com.mysql.jdbc.jdbc2.optional.MysqlDataSource, hibernate.cache.use_second_level_cache=true, javafx.version=8.0.40-ea, file.encoding=Cp1252, format_sql=true, java.specification.version=1.8, net.sf.ehcache.configurationResourceName=/ehcache.xml, hibernate.hikari.dataSource.useServerPrepStmts=true, hibernate.show_sql=true}
Adding Integrator [org.hibernate.cfg.beanvalidation.BeanValidationIntegrator].
Adding Integrator [org.hibernate.secure.spi.JaccIntegrator].
Adding Integrator [org.hibernate.cache.internal.CollectionCacheInvalidator].
Registering named strategy selector [org.hibernate.dialect.Dialect] : [MySQL5] -> [org.hibernate.dialect.MySQL5Dialect] (replacing [org.hibernate.dialect.MySQL5Dialect])
Registering named strategy selector [org.hibernate.dialect.Dialect] : [MySQL5InnoDB] -> [org.hibernate.dialect.MySQL5InnoDBDialect] (replacing [org.hibernate.dialect.MySQL5InnoDBDialect])
Overriding existing service binding [org.hibernate.secure.spi.JaccService]
Preparing to build session factory with filters : {}
HHH000130: Instantiating explicit connection provider: com.zaxxer.hikari.hibernate.HikariConnectionProvider
Configuring HikariCP
HikariCP pool HikariPool-0 configuration:
autoCommit......................true
catalog.........................
connectionCustomizer............com.zaxxer.hikari.HikariConfig$1@13fcc3f0
connectionCustomizerClassName...
connectionInitSql...............
connectionTestQuery.............
connectionTimeout...............30000
dataSource......................
dataSourceClassName.............com.mysql.jdbc.jdbc2.optional.MysqlDataSource
dataSourceJNDI..................
dataSourceProperties............{user=****, password=<masked>, url=jdbc:mysql://localhost:3307/****?zeroDateTimeBehavior=convertToNull, prepStmtCacheSqlLimit=2048, useServerPrepStmts=true, cachePrepStmts=true, prepStmtCacheSize=250}
driverClassName.................
idleTimeout.....................600000
initializationFailFast..........false
isolateInternalQueries..........false
jdbc4ConnectionTest.............true
jdbcUrl.........................
leakDetectionThreshold..........0
maxLifetime.....................1800000
maximumPoolSize.................10
metricsTrackerClassName.........com.zaxxer.hikari.metrics.CodaHaleMetricsTracker
minimumIdle.....................10
password........................<masked>
poolName........................HikariPool-0
readOnly........................false
recordMetrics...................false
registerMbeans..................false
threadFactory...................
transactionIsolation............
username........................
HikariCP pool HikariPool-0 is starting.
HikariCP Configured
HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
HHH000422: Disabling contextual LOB creation as connection was null
Processing hbm.xml files
Mapping class: com.****.modelos.**** -> ****
Mapped property: id -> Id
.........
Process annotated classes
Processing fk mappings (*ToOne and JoinedSubclass)
Processing extends queue
Processing extends queue
Processing collection mappings
Second pass for collection: com.****.modelos.****.****s
Mapping collection: com.****.modelos.****.****s -> ****
..........
Processing native query and ResultSetMapping mappings
Processing association property references
Creating tables' unique integer identifiers
Processing foreign key constraints
Resolving reference to class: com.****.modelos.****
............
No JtaPlatform was specified, checking resolver
No JtaPlatformResolver was specified, using default [org.hibernate.engine.transaction.jta.platform.internal.StandardJtaPlatformResolver]
Could not resolve JtaPlatform, using default [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
Automatic flush during beforeCompletion(): disabled
Automatic session close at end of transaction: disabled
Scrollable result sets: disabled
Wrap result sets: disabled
JDBC3 getGeneratedKeys(): disabled
multi-tenancy strategy : NONE
Connection release mode: after_transaction
Using BatchFetchStyle : LEGACY
Maximum outer join fetch depth: 2
Default batch fetch size: 1
Generate SQL with comments: disabled
Order SQL updates by primary key: disabled
Order SQL inserts for batching: disabled
Default null ordering: none
Query translator: org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory
HHH000397: Using ASTQueryTranslatorFactory
Query language substitutions: {}
JPA-QL strict compliance: disabled
Second-level cache: enabled
Query cache: enabled
Query cache factory: org.hibernate.cache.internal.StandardQueryCacheFactory
Cache region factory : org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory
Optimize cache for minimal puts: enabled
Structured second-level cache entries: disabled
Second-level cache direct-reference entries: disabled
Automatic eviction of collection cache: disabled
Statistics: disabled
Deleted entity synthetic identifier rollback: disabled
Default entity-mode: pojo
Named query checking : enabled
Check Nullability in Core (should be disabled when Bean Validation is on): enabled
Allow initialization of lazy state outside session : : disabled
JTA Track by Thread: enabled
Building session factory
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:363)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:303)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:875)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$150(LauncherImpl.java:157)
at com.sun.javafx.application.LauncherImpl$$Lambda$49/194494468.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
at com.****.dao.****DAO.obtenLista****esPorEstado(****DAO.java:92)
at com.****.controladores.MainApp.start(MainApp.java:52)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$156(LauncherImpl.java:821)
at com.sun.javafx.application.LauncherImpl$$Lambda$52/718709938.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$169(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl$$Lambda$46/863831416.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$167(PlatformImpl.java:295)
at com.sun.javafx.application.PlatformImpl$$Lambda$48/530599638.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$168(PlatformImpl.java:294)
at com.sun.javafx.application.PlatformImpl$$Lambda$47/1508395126.run(Unknown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$144(WinApplication.java:101)
at com.sun.glass.ui.win.WinApplication$$Lambda$36/2136344592.run(Unknown Source)
... 1 more
Exception running application com.****.controladores.MainApp
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 8.154s
Finished at: Sun Nov 09 16:50:23 CET 2014
Final Memory: 7M/153M
------------------------------------------------------------------------
hibernate.cfg.xml の一部
<!-- Datos de conexión a la BD -->
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3307/******?zeroDateTimeBehavior=convertToNull</property>
<property name="hibernate.connection.username">****</property>
<property name="hibernate.connection.password">****</property>
<property name="javax.persistence.validation.mode">none</property>
<!-- Configuración de sesión -->
<property name="connection.release_mode">after_transaction</property>
<property name="current_session_context_class">thread</property>
<!-- Configuración de la salida SQL y estadísticas -->>
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<property name="hibernate.temp.use_jdbc_metadata_defaults">false</property>
<!-- Pool de conexiones (works well)-->
<property name="hibernate.connection.provider_class">com.zaxxer.hikari.hibernate.HikariConnectionProvider</property>
<property name="hibernate.hikari.dataSource.cachePrepStmts">true</property>
<property name="hibernate.hikari.dataSource.prepStmtCacheSize">250</property>
<property name="hibernate.hikari.dataSource.prepStmtCacheSqlLimit">2048</property>
<property name="hibernate.hikari.dataSource.useServerPrepStmts">true</property>
<!-- Cache 2º nivel (this not work, but If disable, works)-->
<property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property>
<property name="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory</property>
<property name="hibernate.cache.use_second_level_cache">true</property>
<property name="hibernate.cache.use_query_cache">true</property>
<property name="net.sf.ehcache.configurationResourceName">/ehcache.xml</property>
何が悪いのかわからない。
HibernateUtil.java
public enum HibernateUtil {
INSTANCE;
private final SessionFactory sessionFactory;
private HibernateUtil() {
Configuration configuration;
StandardServiceRegistryBuilder builder;
configuration = new Configuration().configure();
builder = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties());
sessionFactory = configuration.buildSessionFactory(builder.build());
}
public static HibernateUtil getInstance() {
return INSTANCE;
}
public SessionFactory getSessionFactory() {
return sessionFactory;
}
}
POM
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
......
<repositories>
<repository>
<id>terracotta-releases</id>
<url>http://www.terracotta.org/download/reflector/releases</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-ehcache</artifactId>
<version>4.3.7.Final</version>
<exclusions>
<exclusion>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>2.9.0</version>
<type>jar</type>
</dependency>
<!-- MySQL -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.33</version>
</dependency>
<!-- Apache Log4j -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.1</version>
</dependency>
<!-- Hibernate -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.7.Final</version>
<scope>compile</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.3.7.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.common</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>4.0.5.Final</version>
<scope>compile</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.0.Final</version>
<scope>compile</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
<version>3.1.4.GA</version>
<scope>compile</scope>
<type>jar</type>
</dependency>
<!-- Logs -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.7</version>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
<scope>compile</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>2.0.2</version>
<scope>compile</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
<version>2.7.7</version>
<scope>compile</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.18.2-GA</version>
<scope>compile</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
<scope>compile</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging-annotations</artifactId>
<version>1.2.0.Final</version>
<scope>compile</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.transaction</groupId>
<artifactId>jboss-transaction-api_1.2_spec</artifactId>
<version>1.0.0.Final</version>
<scope>compile</scope>
<type>jar</type>
</dependency>
<!-- Pool de conexiones -->
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>2.1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.7</version>
</dependency>
</dependencies>
</project>
更新: 詳細については、ファイル構成を追加します。