2017-12-27 19 views
0

Wildfly10 및 Postgres 9.6.6에서 작동하는 Java8EE 응용 프로그램을 얻으려고합니다.Postgres 9.6.6 및 Hibernate 5.2.12.final 인 Wildfly 10

어떻게 든 관계를 찾을 수 없다는 오류가 발생합니다.

내 Postgres는 localhost의 기본 포트에서 실행됩니다. 나는 사용자 포스트 그레스와 올바른 암호로 연결하고있다. 데이터베이스 (hbnac)에는 동일한 이름을 가진 스키마가 있습니다.

Wildfly가 데이터베이스를 사용하도록 구성되었으며 "연결 테스트"가 성공적으로 연결되었음을 확인합니다. pgAdmin 4 사용하기 group_member 테이블뿐만 아니라 스키마도 볼 수 있습니다.

제이 보스의 설정은 다음과 같습니다

Caused by: org.postgresql.util.PSQLException: ERROR: relation "group_member" does not exist 

의 구성 : 그러나, 내 응용 프로그램은 다음과 같은 오류의 결과로, 매우 동일한 테이블에서 레코드를 선택하지

<datasource jta="false" jndi-name="java:jboss/datasources/hbnac" pool-name="hbnac" enabled="true" use-ccm="false"> 
       <connection-url>jdbc:postgresql://localhost:5432/hbnac</connection-url> 
       <driver-class>org.postgresql.Driver</driver-class> 
       <driver>postgres</driver> 
       <pool> 
        <min-pool-size>1</min-pool-size> 
        <initial-pool-size>1</initial-pool-size> 
        <max-pool-size>10</max-pool-size> 
        <flush-strategy>Gracefully</flush-strategy> 
       </pool> 
       <security> 
        <user-name>postgres</user-name> 
        <password>password</password> 
       </security> 
       <validation> 
        <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLValidConnectionChecker"/> 
        <background-validation>true</background-validation> 
        <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLExceptionSorter"/> 
       </validation> 
      </datasource> 

내 persistence.xml은 Wildfly에서 정의 된 연결의 jndi 조회를 수행합니다.

<persistence-unit name="hbnac"> 
    <jta-data-source>java:jboss/datasources/hbnac</jta-data-source> 

    <class>hbnac.birthday.domain.groupmember.GroupMember</class> 

    <properties> 
     <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQL94Dialect" /> 
     <!--property name="hibernate.hbm2ddl.auto" value="validate"/--> 
     <!--property name="hibernate.default_schema" value="hbnac"/--> 

     <property name="hibernate.show_sql" value="true"/> 
     <property name="hibernate.format_sql" value="true" /> 
    </properties> 

</persistence-unit> 

분명히 jta-data-source는 Wildfly에서 작동하는 데이터 소스와 일치합니다. 보시다시피, 필자는 유효성 검사 (시작시 동일한 이유로 실패 함)와 스키마 이름을 사용하여 약간의 차이를 만들지 않았습니다.

엔티티 itsel는 annoted된다

@Entity 
@Table(name = "group_member") 
public class GroupMember extends AbstractEntity { 

public final static String FACEBOOK_NAME_FIELD = "facebookName"; 
public final static String BIRTHDAY_FIELD = "birthday"; 

@Id 
@GeneratedValue(strategy= GenerationType.IDENTITY) 
private long id; 

그것은 게터, 세터, 해시 코드를 가지고 있으며, 사용할 수있는 모든 필드에 대한 메도 같습니다.

나는 그것이 또한 완벽하게 작동 pgadmin에 최대 절전 모드에 의해 생성 된 쿼리를 복사하면 ...

모든 아이디어를 왼쪽?

A screenshot from the actual db in pgadmin

답변

0

outed한다! Wildfly 자체에서 Postgres 모듈의 구성으로 인해 발생했습니다.

내가 가진 무엇 전에 :

<?xml version="1.0" encoding="UTF-8"?> 
<module xmlns="urn:jboss:module:1.1" name="org.postgres"> 
    <resources> 
     <resource-root path="postgresql-42.1.4.jar" /> 
    </resources> 
    <dependencies> 
     <module name="javax.api"/> 
     <module name="javax.transaction.api"/> 
     <module name="javax.servlet.api" optional="true" /> 
    </dependencies> 

와 독립이다.XML : 데이터 소스 자체에 대한

<driver name="postgres" module="org.postgres"> 
    <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class> 
    <datasource-class>org.postgresql.ds.PGSimpleDataSource</datasource-class> 
</driver> 

는 :

<datasource jta="false" jndi-name="java:jboss/datasources/hbnac" pool-name="hbnac" enabled="true" use-ccm="false"> 
       <connection-url>jdbc:postgresql://localhost:5432/hbnac</connection-url> 
       <driver-class>org.postgresql.Driver</driver-class> 
       <driver>postgres</driver> 
       ... 

이 구성은 성공적으로 연결하지만 관계를 찾을 수 없다는 오류를했다.

다음과 같은 구성으로 대체함으로써

, 모든 것이 잘 작동 :

<?xml version="1.0" encoding="UTF-8"?> 
<module xmlns="urn:jboss:module:1.1" name="org.postgres"> 
<resources> 
    <resource-root path="postgresql-42.1.4.jar"/> 
</resources> 
<dependencies> 
    <module name="javax.api"/> 
    <module name="javax.transaction.api"/> 
    <module name="javax.servlet.api" optional="true"/> 
</dependencies> 

standalone.xml에서 드라이버의 경우 :

을 Module.xml를 들어

<driver name="postgresql" module="org.postgres"> 
    <driver-class>org.postgresql.Driver</driver-class> 
</driver> 

마지막으로 db 연결의 경우 :

나는 또한 데이터베이스 수준에서 검색 경로를 변경, 설정을 시도
0

성공은 아마도 스키마 설정이 올바르게 정의되지 않은, 표시 테이블 를 찾을 수 없습니다에도 연결을 테스트 만합니다. 다음,이

<connection-url>jdbc:postgresql://localhost:5432/hbnac?currentSchema=hbnac</connection-url> 

같은 currentSchema를 넣어 활성화해야 쿼리를 실행하는 최대 절전 모드를 사용하는 경우이 댓글이 나는 많은 시도 후 오류를 발견 코드

<!--property name="hibernate.default_schema" value="hbnac"/--> 
+0

<datasource jta="true" jndi-name="java:/PostgresDS" pool-name="PostgresDS" enabled="true" use-java-context="true"> <connection-url>jdbc:postgresql://localhost:5432/hbnac</connection-url> <driver>postgresql</driver> <security> ... 
(hbnac있어서 데이터베이스 hbnac 세트 search_path의 ALTER),하지만 아무것도 할 수 없다 ... 난 정말 일부의 피해자임을 생각하고 버그 종류 ... – zip4ever