hibernate.cfg.xml中
<session-factory>
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.url">jdbc:postgresql://localhost:5432/thetable</property>
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="hibernate.connection.username">postgres</property>
<property name="hibernate.connection.password">postgres123</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.format_sql">true</property>
</session-factory>
的pom.xml
<dependency>
<groupId>org.apache.tapestry</groupId>
<artifactId>tapestry-hibernate</artifactId>
<version>${tapestry-release-version}</version>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901.jdbc4</version>
</dependency>
错误
HTTP ERROR 500
Problem accessing /blah/balahhh. Reason:
Exception constructing service 'ValueEncoderSource': Error invoking service contribution method org.apache.tapestry5.hibernate.HibernateModule.contributeValueEncoderSource(MappedConfiguration, boolean, HibernateSessionSource, Session, TypeCoercer, PropertyAccess, LoggerSource): Exception constructing service 'HibernateSessionSource': Error invoking constructor public org.apache.tapestry5.internal.hibernate.HibernateSessionSourceImpl(org.slf4j.Logger,java.util.List): Could not initialize class org.hibernate.annotations.common.reflection.java.JavaReflectionManager
之前我使用“hsqldb”时有效。但现在我得到了显示的错误。
答案 0 :(得分:0)
第一印象是您从类路径中缺少驱动程序类。这可能是由许多因素造成的,包括maven,您的部署等。
在您的AppModule中,使用bind
方法(如果您没有创建),请尝试以下操作:
public static void bind(ServiceBinder binder)
{
try
{
Class.forName("org.postgresql.Driver");
System.out.println("driver found in classpath");
}
catch(Throwable e)
{
System.out.println("driver not found in classpath");
e.printStackTrace();
}
...
}
答案 1 :(得分:0)
这个项目的问题是我已经定义了pom.xml来下载不同的依赖库。但是log4j已经从两个不同的存储库(tapestry&amp; tika)下载了两次。版本不同。所以我所做的就是检查maven树并为下载旧版slf4j的地方添加排除项。
<dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-parsers</artifactId>
<version>1.2</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>