1

私はこの問題を 1 週間以上抱えていますが、それを解決する手がかりが見つかりません。

「JBoss Forge -- Build and Deploy Java EE 6 AngularJS Applications using JBoss Forge and OpenShift」というタイトルの OpenShift の Web サイトのガイドに従って、最初は jBoss Tools Forge を使用してビルドされた Java EE Web アプリケーションがあります。

アプリケーションは OpenShift でホストされ、JBoss Application Server 7 と PostgreSQL 9.2 をメインおよびセカンダリ カートリッジとして使用します。正常に実行され、データベース接続に関するエラーは発生しませんが、インターフェイスを介して入力されたデータはアプリケーションの再起動時に失われ、持続性が非常に重要です。

以下は、postgresql 接続の詳細を説明する必要があるファイルの関連部分です。

Persistence.xml:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
  <persistence-unit name="forge-default" transaction-type="JTA">
    <description>Forge Persistence Unit</description>
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <jta-data-source>java:jboss/datasources/PostgreSQLDS</jta-data-source>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <properties>
      <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
      <property name="hibernate.show_sql" value="true"/>
      <property name="hibernate.format_sql" value="true"/>
      <property name="hibernate.transaction.flush_before_completion" value="true"/>
      <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
    </properties>
  </persistence-unit>
</persistence>

Standalone.xml:

<datasource jndi-name="java:jboss/datasources/PostgreSQLDS" enabled="${postgresql.enabled}" use-java-context="true" pool-name="PostgreSQLDS" use-ccm="true">
                <connection-url>jdbc:postgresql://${env.OPENSHIFT_POSTGRESQL_DB_HOST}:${env.OPENSHIFT_POSTGRESQL_DB_PORT}/${env.OPENSHIFT_APP_NAME}</connection-url>
                <driver>postgresql</driver>
                <security>
                  <user-name>adminpielw4l</user-name>
                  <password>Fy7dRZirzc7Y</password>
                </security>
                <validation>
                    <check-valid-connection-sql>SELECT 1</check-valid-connection-sql>
                    <background-validation>true</background-validation>
                    <background-validation-millis>60000</background-validation-millis>
                    <!--<validate-on-match>true</validate-on-match>-->
                </validation>
                <pool>
                                            <flush-strategy>IdleConnections</flush-strategy>
                                    </pool>
            </datasource>
            <drivers>
                <driver name="h2" module="com.h2database.h2">
                    <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
                </driver>
                <driver name="mysql" module="com.mysql.jdbc">
                    <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
                </driver>
                <driver name="postgresql" module="org.postgresql.jdbc">
                    <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
                </driver>
            </drivers>
        </datasources>

次のようなエンティティを定義する .java ファイルが 1 つあります。

@Entity
@XmlRootElement
public class wugMember implements Serializable
{

   @Id
   @GeneratedValue(strategy = GenerationType.AUTO)
   @Column(name = "id", updatable = false, nullable = false)
   private Long id = null;
   @Version
   @Column(name = "version")
   private int version = 0;

   @Column
   private String firstName;

そして、それを使用しようとしているように見える別のもの:

@Stateless
@Path("/wugmembers")
public class wugMemberEndpoint
{
   @PersistenceContext(unitName = "forge-default")
   private EntityManager em;

   @POST
   @Consumes("application/json")
   public Response create(wugMember entity)
   {
      em.persist(entity);
      return Response.created(UriBuilder.fromResource(wugMemberEndpoint.class).path(String.valueOf(entity.getId())).build()).build();
   }

前回の起動以降の posgresql ログ:

    FATAL:  the database system is starting up
LOG:  database system is ready to accept connections
ERROR:  sequence "hibernate_sequence" does not exist
STATEMENT:  
            drop sequence hibernate_sequence

drop ステートメントが時々そのように失敗して害がないので、それが問題の原因だとは思いませんか? Web アプリとデータベースに関する私の知識は非常に限られているため、明らかな何かを見落としている可能性が非常に高いです。うまくいけば、より経験豊富な人がそれを見つけることができますか?

4

0 に答える 0