문제

I am new to OpenShift and created my first application with JBoss AS7 and PostgreSQL 9.2 gears. I created the DB successfully and tried to deploy an existing WAR, following the directions I found on these two pages:

https://www.openshift.com/kb/kb-e1088-how-to-deploy-pre-compiled-java-applications-war-and-ear-files-onto-your-openshift-gear

http://openshift.github.io/documentation/oo_cartridge_guide.html#jbossas

When I do my git push, I get the following:

Counting objects: 130, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (118/118), done.
Writing objects: 100% (125/125), 1.17 MiB | 0 bytes/s, done.
Total 125 (delta 15), reused 0 (delta 0)
remote: Stopping jbossas cartridge
remote: Sending SIGTERM to jboss:139169 ...
remote: Stopping Postgres cartridge
remote: Building git ref 'master', commit 193ff43
remote: Skipping Maven build due to absence of pom.xml
remote: Preparing build for deployment
remote: Deployment id is 57ba6341
remote: Activating deployment
remote: Starting Postgres cartridge
remote: Postgres started
remote: Deploying JBoss
remote: Starting jbossas cartridge
remote: Found 127.4.111.129:8080 listening port
remote: Found 127.4.111.129:9999 listening port
remote: /var/lib/openshift/535e75ffe0b8cd39b600043f/jbossas/standalone/deploymen
ts /var/lib/openshift/535e75ffe0b8cd39b600043f/jbossas
remote: /var/lib/openshift/535e75ffe0b8cd39b600043f/jbossas
remote: Failed deployments: ./tradelite.war
remote: -------------------------
remote: Git Post-Receive Result: success
remote: Activation status: success
remote: Deployment completed with status: success
To ssh://535e75ffe0b8cd39b600043f@jbossas-tradelite1.rhcloud.com/~/git/jbossas.g
it/
   862add8..193ff43  master -> master

Using rhc tail I see the following:

==> app-root/logs/jbossas.log  ["jboss.naming.context.java.module.tradelite.tradelite.env.jdbc.TradeDataSourcejboss.naming.context.java.jboss.resources.jdbc.TradeDataSourceMissing[jboss.naming.context.java.module.tradelite.tradelite.env.jdbc.TradeDataSourcejboss.naming.context.java.jboss.resources.jdbc.TradeDataSource]"]}
2014/04/30 08:45:49,609 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015877: Stopped deployment tradelite.war in 95ms
2014/04/30 08:45:49,613 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
JBAS014775:    New missing/unsatisfied dependencies:
      service jboss.naming.context.java.jboss.resources.jdbc.TradeDataSource (missing) dependents: [service jboss.naming.context.java.module.tradelite.tradelite.env.jdbc.TradeDataSource]
2014/04/30 08:45:49,615 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.naming.context.java.module.tradelite.tradelite.env.jdbc.TradeDataSourcejboss.naming.context.java.jboss.resources.jdbc.TradeDataSourceMissing[jboss.naming.context.java.module.tradelite.tradelite.env.jdbc.TradeDataSourcejboss.naming.context.java.jboss.resources.jdbc.TradeDataSource]"]}}}

Can anyone help explain why I'm getting this and how to fix it?

Thanks very much.

Here is the datasources section from my standalone.xml:

        <datasources>
            <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>${env.OPENSHIFT_POSTGRESQL_DB_USERNAME}</user-name>
                  <password>${env.OPENSHIFT_POSTGRESQL_DB_PASSWORD}</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="postgresql" module="org.postgresql.jdbc">
                    <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
                </driver>
            </drivers>
        </datasources>

And here is my context.xml from my META-INF directory in my WAR:

<?xml version='1.0' encoding='utf-8'?>
<Context>
    <Resource name="jdbc/TradeDataSource" auth="Container" type="javax.sql.DataSource"
        username="xxxxx"
        password="xxxxx"
        driverClassName="org.postgresql.Driver"
        url="jdbc:postgresql://127.4.111.132:5432/jbossas"
        maxActive="20"
        maxIdle="10" />
</Context>
도움이 되었습니까?

해결책 2

The solution I found was to create a proprietary jboss-web.xml file in my WEB-INF directory in my WAR.

In the WAR, WEB-INF/jboss-web.xml contains:

<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
  <resource-ref>
    <res-ref-name>jdbc/TradeDataSource</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <jndi-name>java:jboss/datasources/PostgreSQLDS</jndi-name>
  </resource-ref>
</jboss-web>

In the WAR, WEB-INF/web.xml contains:

...
<resource-ref id="ResourceRef_1">
  <res-ref-name>jdbc/TradeDataSource</res-ref-name>
  <res-type>javax.sql.DataSource</res-type>
  <res-auth>Container</res-auth>
  <res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
...

And in the .openshift/config directory, standalone.xml contains

...
<subsystem xmlns="urn:jboss:domain:datasources:1.0">
  <datasources>
    <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>${env.OPENSHIFT_POSTGRESQL_DB_USERNAME}</user-name>
        <password>${env.OPENSHIFT_POSTGRESQL_DB_PASSWORD}</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="postgresql" module="org.postgresql.jdbc">
        <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
      </driver>
    </drivers>
  </datasources>
</subsystem>
...

With these file (and the JNDI name matching in standalone.xml and jboss-web.xml), the WAR deploys successfully.

다른 팁

Every OpenShift JBoss application has three datasource(H2, MySQL, and PostgreSQL) configured in standalone.xml JBoss configuration file. In your persistence.xml make sure you are using java:jboss/datasources/PostgreSQLDS JNDI datasource otherwise you get exception.You can find standalone.xml inside .openshift/config directory.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top