Tomcat 7.0.26 を使用した struts フレームワーク 2.3.3 に基づくプロジェクトで hibernate 4.1.2 を使用しています。テストには mysql (および postgres) も使用しています。これは、MySql を使用した私の hibernate.cfg.xml です。
<session-factory>
<property name="c3p0.min_size">5</property>
<property name="c3p0.max_size">20</property>
<property name="c3p0.timeout">300</property>
<property name="c3p0.max_statements">50</property>
<property name="c3p0.idle_text_period">3000</property>
<property name="show_sql">true</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost/struts2</property>
<property name="connection.username">semperEst</property>
<property name="connection.password">*******</property>
<property name="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</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>
<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">create-drop</property>
<mapping class="firstname.secondname.lesson2.User"/>
</session-factory>
私のWEB-INF/libには以下が含まれています:
antlr-2.7.7.jar
asm-3.3.jar
asm-commons-3.3.jar
asm-tree-3.3.jar
commons-fileupload-1.2.2.jar
commons-io-2.0.1.jar
commons-lang-2.4.jar
commons-lang3-3.1.jar
dom4j-1.6.1.jar
freemarker-2.3.19.jar
hibernate-commons-annotations-4.0.1.Final.jar
hibernate-core-4.1.2.Final.jar
hibernate-jpa-2.0-api-1.0.1.Final.jar
javassist-3.11.0.GA.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.16.jar
mysql-connector-java-5.1.20-bin.jar
ognl-3.0.5.jar
postgresql-9.1-902.jdbc4.jar
slf4j-api-1.6.4-sources.jar
slf4j-log4j12-1.6.4.jar
struts2-core-2.3.3.jar
xwork-core-2.3.3.jar
* $CATALINA_HOME/lib に mysql-connector-java-5.1.20-bin.jar を既に追加しました*
しかし、私はまだこの例外があります:
java.sql.SQLException: java.sql.DriverManager.getConnection(DriverManager.java:604) でjdbc:mysql://localhost/struts2 に適したドライバーが見つかりません
at java.sql.DriverManager.getConnection(DriverManager.java:190)
at org.hibernate.service.jdbc.connections.internal.
DriverManagerConnectionProviderImpl.
getConnection(DriverManagerConnectionProviderImpl.java:192)
at org.hibernate.internal.
AbstractSessionImpl$NonContextualJdbcConnectionAccess.
obtainConnection(AbstractSessionImpl.java:278)
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.
obtainConnection(LogicalConnectionImpl.java:297)
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.
getConnection(LogicalConnectionImpl.java:169)
at org.hibernate.engine.transaction.internal.
jdbc.JdbcTransaction.doBegin(JdbcTransaction.java:67)
at org.hibernate.engine.transaction.spi.
AbstractTransactionImpl.begin(AbstractTransactionImpl.java:160)
at org.hibernate.internal.SessionImpl.
beginTransaction(SessionImpl.java:1363)
at firstname.lastname.lesson2.
PortfolioService.usernameExists(PortfolioService.java:122)
at firstname.lastname.lesson2.CreateUser.validate(CreateUser.java:255)
at com.opensymphony.xwork2.validator.ValidationInterceptor.
doBeforeInvocation(ValidationInterceptor.java:251)
at com.opensymphony.xwork2.validator.ValidationInterceptor.
doIntercept(ValidationInterceptor.java:263)
at org.apache.struts2.interceptor.validation.
AnnotationValidationInterceptor.
doIntercept(AnnotationValidationInterceptor.java:68)
at
.
.
.(struts activation frame...)
.
at org.apache.catalina.core.ApplicationFilterChain.
internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.
doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.
invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.
invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.
invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at org.apache.catalina.core.StandardEngineValve.
invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.
process(AbstractHttp11Processor.java:987)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.
process(AbstractProtocol.java:579)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.
run(JIoEndpoint.java:307)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
postgresでも同じ問題。ストラットや tomcat を使用せずに、すべてスタンドアロン アプリケーションで動作します。
前もって感謝します