当我第一次在Glassfish上查询我的Struts应用程序时,会发生这样的错误:
Severe: Initial SessionFactory creation failed.java.lang.NoClassDefFoundError: com/mchange/v2/c3p0/DataSources
Info: 2015-07-28 13:59:17 ERROR HibernateUtil:54 - Initial SessionFactory creation failed
java.lang.NoClassDefFoundError: com/mchange/v2/c3p0/DataSources
at org.hibernate.connection.C3P0ConnectionProvider.configure(C3P0ConnectionProvider.java:176)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:143)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:84)
at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:459)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:91)
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)
[...]
我尝试使用this article解决此问题,但仍然发生同样的错误..
我用来运行此应用程序的依赖项:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.6.3.Final</version>
<type>jar</type>
</dependency>
<!-- Hibernate c3p0 connection pool -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-c3p0</artifactId>
<version>3.6.3.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-tools</artifactId>
<version>3.6.0.CR1</version>
</dependency>
<dependency>
<groupId>com.mchange</groupId>
<artifactId>mchange-commons-java</artifactId>
<version>0.2.10</version>
</dependency>
<dependency>
<groupId>c3p0</groupId>
<artifactId>c3p0-oracle-thin-extras</artifactId>
<version>0.9.0.2</version>
</dependency>
<dependency>
<groupId>com.mchange AND c3p0</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.2.1</version>
</dependency>
这个应用程序完美无需Maven ..
感谢您的帮助! :)
答案 0 :(得分:2)
在
<dependency>
<groupId>com.mchange AND c3p0</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.2.1</version>
</dependency>
AND c3p0
是多余的。
应该是
<dependency>
<groupId>com.mchange</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.2.1</version>
</dependency>
或者更好的是,使用当前的生产版本
<dependency>
<groupId>com.mchange</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.5.1</version>
</dependency>
答案 1 :(得分:0)
问题已解决 - 我必须将c3p0- [version] .jar添加到 domains / domain1 / libs
下的 Glassfish libs目录中