我是OpenShift的新手,用JBoss AS7和PostgreSQL 9.2齿轮创建了我的第一个应用程序。我成功创建了数据库并尝试按照我在这两个页面上找到的指示部署现有的WAR:
http://openshift.github.io/documentation/oo_cartridge_guide.html#jbossas
当我做我的git推送时,我得到以下内容:
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
使用rhc tail我看到以下内容:
==> 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]"]}}}
任何人都可以帮忙解释为什么我会得到这个以及如何解决它?
非常感谢。
以下是我的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>
这是我在WAR中的META-INF目录中的context.xml:
<?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>
答案 0 :(得分:0)
每个OpenShift JBoss应用程序都有standalone.xml JBoss配置文件中配置的三个数据源(H2,MySQL和PostgreSQL)。在persistence.xml中,确保使用java:jboss/datasources/PostgreSQLDS
JNDI数据源,否则会出现异常。您可以在.openshift / config目录中找到standalone.xml。
答案 1 :(得分:0)
我找到的解决方案是在我的WAR中的WEB-INF目录中创建一个专有的jboss-web.xml文件。
在WAR中,WEB-INF / jboss-web.xml包含:
<?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>
在WAR中,WEB-INF / web.xml包含:
...
<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>
...
在.openshift / config目录中,standalone.xml包含
...
<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>
...
使用这些文件(以及在standalone.xml和jboss-web.xml中匹配的JNDI名称),WAR成功部署。