2012-11-07 33 views
0

的hibernate.cfg.xml我在這個PostgreSQL的配置做什麼(掛毯​​)

<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

請包括完整的堆棧跟蹤,不要發佈它作爲答案,編輯您的原始帖子。 – pstanton

回答

0

的這個項目的問題是我已經定義了pom.xml來下載不同的依賴庫。但log4j已從兩個不同的存儲庫下載兩次(tapestry & 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>  
0

第一印象是您從類路徑中缺少驅動程序類。這可能是由許多因素,包括行家,您的部署等引起的..

在你的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(); 
    } 

    ... 
}