0

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」を使用する前は機能していました。しかし、今は表示されたエラーが発生します。

4

2 に答える 2

0

このプロジェクトの問題は、さまざまな依存関係ライブラリをダウンロードするようにpom.xmlを定義したことです。しかし、log4jは2つの異なるリポジトリ(tapestryとtika)から2回ダウンロードされています。バージョンが異なっていました。だから私がしたことは、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>    
于 2012-11-08T07:30:29.407 に答える
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();
    }

    ...
}
于 2012-11-07T22:28:34.720 に答える