実行中の Java Web プロジェクトを Maven ベースのプロジェクトに変換しました。Tomcat サーバーを Eclipse から起動する以外はすべて正常に動作します。奇妙な SQLException が発生します。
...
19.06.2012 17:09:08 org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: .:/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java
19.06.2012 17:09:08 org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNUNG: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:IDATService' did not find a matching property.
19.06.2012 17:09:09 org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
19.06.2012 17:09:09 org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
19.06.2012 17:09:09 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1372 ms
19.06.2012 17:09:09 org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
19.06.2012 17:09:09 org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.27
19.06.2012 17:09:09 org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(/Users/wessamkais/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/IDATService/WEB-INF/lib/servlet-api-2.4.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
2012-06-19 17:09:10,786 [pool-2-thread-1] DEBUG [pool-2-thread-1] (Ejb3Configuration.java:<clinit>:142) - Logging Provider: org.jboss.logging.Log4jLoggerProvider
2012-06-19 17:09:10,858 [pool-2-thread-1] DEBUG [pool-2-thread-1] (BasicTypeRegistry.java:register:143) - Adding type registration boolean ->
…
…
com.mchange.v2.c3p0.PoolBackedDataSource@1054f25f [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@c55aab83 [ acquireIncrement -> 5, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, debugUnreturnedConnectionStackTraces -> false, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge1d28o1gucuz1ec93hy|673a95af, idleConnectionTestPeriod -> 10, initialPoolSize -> 3, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 5000, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 25, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 5, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@28fe56fb [ description -> null, driverClass -> null, factoryClassLocation -> null, identityToken -> 1hge1d28o1gucuz1ec93hy|4599d5b, jdbcUrl -> jdbc:mysql://127.0.0.1:3306/testIDAT, properties -> {user=******, password=******, autocommit=true, release_mode=auto} ], preferredTestQuery -> null, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false; userOverrides: {} ], dataSourceName -> null, factoryClassLocation -> null, identityToken -> 1hge1d28o1gucuz1ec93hy|19e06de8, numHelperThreads -> 3 ]
2012-06-19 17:09:13,172 [pool-2-thread-1] DEBUG [pool-2-thread-1] (BasicResourcePool.java:incrementPendingAcquires:404) - incremented pending_acquires: 5
2012-06-19 17:09:13,172 [pool-2-thread-1] DEBUG [pool-2-thread-1] (BasicResourcePool.java:<init>:289) - com.mchange.v2.resourcepool.BasicResourcePool@42bc0eba config: [start -> 3; min -> 5; max -> 25; inc -> 5; num_acq_attempts -> 30; acq_attempt_delay -> 1000; check_idle_resources_delay -> 10000; mox_resource_age -> 0; max_idle_time -> 5000000; excess_max_idle_time -> 0; destroy_unreturned_resc_time -> 0; expiration_enforcement_delay -> 900000; break_on_acquisition_failure -> false; debug_store_checkout_exceptions -> false]
2012-06-19 17:09:13,173 [pool-2-thread-1] DEBUG [pool-2-thread-1] (BasicResourcePool.java:prelimCheckoutResource:538) - acquire test -- pool size: 0; target_pool_size: 5; desired target? 1
2012-06-19 17:09:13,173 [pool-2-thread-1] DEBUG [pool-2-thread-1] (BasicResourcePool.java:awaitAvailable:1291) - awaitAvailable(): [unknown]
2012-06-19 17:09:13,173 [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0] DEBUG [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0] (BasicResourcePool.java:run:1831) - An exception occurred while acquiring a poolable resource. Will retry.
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getDriver(DriverManager.java:264)
at com.mchange.v2.c3p0.DriverManagerDataSource.driver(DriverManagerDataSource.java:223)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:134)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)
at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
2012-06-19 17:09:13,174 [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1] DEBUG [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1] (BasicResourcePool.java:run:1831) - An exception occurred while acquiring a poolable resource. Will retry.
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getDriver(DriverManager.java:264)
at com.mchange.v2.c3p0.DriverManagerDataSource.driver(DriverManagerDataSource.java:223)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:134)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)
at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
2012-06-19 17:09:13,184 [pool-2-thread-1] DEBUG [pool-2-thread-1] (BasicResourcePool.java:trace:1644) - trace com.mchange.v2.resourcepool.BasicResourcePool@42bc0eba [managed: 0, unused: 0, excluded: 0]
2012-06-19 17:09:13,174 [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2] DEBUG [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2] (BasicResourcePool.java:run:1831) - An exception occurred while acquiring a poolable resource. Will retry.
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getDriver(DriverManager.java:264)
at com.mchange.v2.c3p0.DriverManagerDataSource.driver(DriverManagerDataSource.java:223)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:134)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)
at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
私はMySQL、Tomcat、Eclipseを使用しています。これは私が新しく書いた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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>eu.paedrtx.register.server</groupId>
<artifactId>IDATService</artifactId>
<packaging>war</packaging>
<version>1.7-SNAPSHOT</version>
<name>eu.paedrtx.register.server.IDATService</name>
<dependencies>
<dependency>
<groupId>eu.paedrtx</groupId>
<artifactId>Common</artifactId>
<version>1.7-SNAPSHOT</version>
</dependency>
<!-- the dependencies needed for the projekt -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>c3p0</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.1.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>1.7.1</version>
</dependency>
<!-- Update to the newest relese -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>10.0.1</version>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-persist</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-servlet</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-c3p0</artifactId>
<version>${hibernateVersion}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.2.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${hibernateVersion}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernateVersion}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>${jerseyVersion}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<version>${jerseyVersion}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-guice</artifactId>
<version>${jerseyVersion}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>${jerseyVersion}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>${jerseyVersion}</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
<!-- update to 0.11 -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombokVersion}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.20</version>
</dependency>
<!-- slf4j dependencies of our dependencies - I think we can try to delete
it -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.jadira.usertype</groupId>
<artifactId>usertype.core</artifactId>
<version>3.0.0.CR1</version>
</dependency>
<dependency>
<groupId>org.jadira.usertype</groupId>
<artifactId>usertype.spi</artifactId>
<version>3.0.0.CR1</version>
</dependency>
<dependency>
<groupId>com.jayway.restassured</groupId>
<artifactId>rest-assured</artifactId>
<version>1.6.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<!-- Generate compiled stuff in the folder used for development mode -->
<outputDirectory>src/main/webapp/WEB-INF/classes</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>false</filtering>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.22</version>
<configuration>
<webAppConfig>
<contextPath>/</contextPath>
<baseResource implementation="org.mortbay.resource.ResourceCollection">
<!-- need both the webbapp dir and location where GWT puts stuff -->
<resourcesAsCSV>
${basedir}/src/main/webapp,${project.build.directory}/${project.build.finalName}
</resourcesAsCSV>
</baseResource>
</webAppConfig>
<connectors>
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<port>8080</port>
<host>127.0.0.1</host>
</connector>
</connectors>
<!-- the stopPort and stopKey are needed for the jetty:stop goal, which is used by mvn install and the integration-test -->
<stopPort>9966</stopPort>
<stopKey>foo</stopKey>
</configuration>
</plugin>
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.7</version> <!-- Note 2.8 does not work with AspectJ aspect path -->
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
<wtpversion>2.0</wtpversion>
</configuration>
</plugin>
</plugins>
</build>
</project>
私はmavenに変換する前にすべてが正常に動作していたので、persistence.xmlとは何の関係もないと思いますが、予防的にこれは私のpersistence_unitです:
<persistence-unit name="idat_unit" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
<property name="hibernate.connection.url" value="jdbc:mysql://127.0.0.1:3306/testIDAT" />
<property name="hibernate.connection.username" value="testIDATUser" />
<property name="hibernate.connection.password" value="test" />
<property name="hibernate.hbm2ddl.auto" value="update"/>
<!-- Automatic type resolver -->
<property name="jadira.usertype.autoRegisterUserTypes" value="true"/>
<!-- C3p0 connection pooling configuration -->
<property name="hibernate.connection.provider_class" value="org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider"/>
<property name="hibernate.c3p0.acquire_increment" value="5"/>
<property name="hibernate.c3p0.idle_test_period" value="10"/>
<property name="hibernate.c3p0.timeout" value="5000"/>
<property name="hibernate.c3p0.max_size" value="25" />
<property name="hibernate.c3p0.max_statements" value="0"/>
<property name="hibernate.c3p0.min_size" value="5"/>
</properties>
</persistence-unit>