我继承了一个项目,并试图让它通过 jetty:run 运行但无济于事。使用 run-war 或 run-exploded 可以正常工作,但似乎无法确定普通旧运行的问题。它给了我以下堆栈:
2012-06-28 15:02:32.247:INFO:/:Initializing Spring root WebApplicationContext
WARN [main] JDBCExceptionReporter.logExceptions(233) | SQL Error: 0, SQLState: null
ERROR [main] JDBCExceptionReporter.logExceptions(234) | Cannot create PoolableConnectionFactory (Access denied for user 'root'@'localhost' (using password: NO))
WARN [main] SettingsFactory.buildSettings(147) | Could not obtain connection to query metadata
org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user 'root'@'localhost' (using password: NO))
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:855)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
at org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:82)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:114)
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2833)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2829)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1840)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:814)
/src/main/resources/applicationContext-resources.xml
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:jdbc.properties</value>
<value>classpath:mail.properties</value>
</list>
</property>
</bean>
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" >
<property name="driverClass" value="${jdbc.driverClassName}"/>
<property name="jdbcUrl" value="${jdbc.url}"/>
<property name="user" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
<property name="initialPoolSize" value="8"/>
<property name="minPoolSize" value="8"/>
<property name="maxPoolSize" value="32"/>
<property name="idleConnectionTestPeriod" value="600"/>
<property name="maxIdleTime" value="0"/>
<property name="maxStatements" value="0"/>
<property name="maxStatementsPerConnection" value="0"/>
<property name="acquireIncrement" value="3"/>
<property name="acquireRetryAttempts" value="3"/>
<property name="acquireRetryDelay" value="1000"/>
<property name="autoCommitOnClose" value="false"/>
<property name="maxConnectionAge" value="14400"/>
<property name="forceIgnoreUnresolvedTransactions" value="false"/>
<property name="numHelperThreads" value="20"/>
<property name="testConnectionOnCheckin" value="false"/>
<property name="testConnectionOnCheckout" value="false"/>
<property name="preferredTestQuery" value="select id from xtcirc101themes where rownum = 1"/>
<property name="maxAdministrativeTaskTime" value="0"/>
<property name="debugUnreturnedConnectionStackTraces" value="false"/>
<property name="maxIdleTimeExcessConnections" value="0"/>
<property name="breakAfterAcquireFailure" value="false"/>
<property name="checkoutTimeout" value="0"/>
<property name="unreturnedConnectionTimeout" value="0"/>
<property name="usesTraditionalReflectiveProxies" value="false"/>
</bean>
/src/main/resources/applicationContext.xml
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="annotatedClasses">
<list>
.
.
.
</list>
</property>
</bean>
/WEB-INF/web.xml 中的上下文配置
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:/applicationContext-resources.xml
classpath:/applicationContext-dao.xml
classpath:/applicationContext-service.xml
classpath*:/applicationContext.xml
/WEB-INF/applicationContext*.xml
/WEB-INF/classes/applicationContext*.xml
/WEB-INF/classes/tbmJobs*.xml
/WEB-INF/xfire-servlet.xml
/WEB-INF/security.xml
</param-value>
</context-param>
/src/main/resources/jdbc.properties
jdbc.driverClassName=${jdbc.driverClassName}
jdbc.url=${jdbc.url}
jdbc.username=${jdbc.username}
jdbc.password=${jdbc.password}
hibernate.dialect=${hibernate.dialect}
# Needed by Hibernate3 Maven Plugin defined in pom.xml
hibernate.connection.username=${jdbc.username}
hibernate.connection.password=${jdbc.password}
hibernate.connection.url=${jdbc.url}
hibernate.connection.driver_class=${jdbc.driverClassName}
在 pom.xml 中配置的属性
<properties>
<dbunit.dataTypeFactoryName>org.dbunit.ext.oracle.OracleDataTypeFactory</dbunit.dataTypeFactoryName>
<dbunit.schema>SYSTEM</dbunit.schema>
<hibernate.dialect>org.hibernate.dialect.Oracle10gDialect</hibernate.dialect>
<jdbc.groupId>com.oracle</jdbc.groupId>
<jdbc.artifactId>ojdbc14</jdbc.artifactId>
<jdbc.version>10.2.0.3.0</jdbc.version>
<jdbc.driverClassName>oracle.jdbc.OracleDriver</jdbc.driverClassName>
<jdbc.url>jdbc:oracle:thin:@${oracle.host}:1521:${oracle.sid}</jdbc.url>
<jdbc.username>*******</jdbc.username>
<jdbc.password>*******</jdbc.password>
</properties>