[英]Openshift failed deployment on JBoss AS7, MYSQL dependency error
這是我之前構建的應用程序,我正在嘗試配置在Openshift上進行部署。 它在我的本地設置中在獨立的Jboss AS7實例中運行良好。 它構建為3個模塊:.war,ejb .jar和包含這兩個模塊的.ear - 我認為非常標准。
有問題的錯誤(來自'rhc tail'):
==> jbossas/logs/server.log <==
2014/02/26 04:06:24,571 INFO [org.jboss.ws.common.management.DefaultEndpointRegistry](MSC service thread 1-1) remove: jboss.ws:context=unihub-ejb,endpoint=SearchSession
2014/02/26 04:06:24,919 INFO [org.jboss.as.webservices] (MSC service thread 1-2) JBAS015540: Stopping service jboss.ws.port-component-link
2014/02/26 04:06:25,579 INFO [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015877: Stopped deployment unihub-ejb.jar in 1277ms
2014/02/26 04:06:25,893 INFO [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015877: Stopped deployment unihub.war in 1589ms
2014/02/26 04:06:26,181 INFO [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015877: Stopped deployment unihub-ear.ear in 1879ms
2014/02/26 04:06:26,184 INFO [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
JBAS014775: New missing/unsatisfied dependencies:
service jboss.naming.context.java.jboss.datasources.MySqlDS (missing) dependents: [service jboss.persistenceunit."unihub-ear.ear/unihub-ejb.jar#primary"]
2014/02/26 04:06:26,368 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.persistenceunit.\"unihub-ear.ear/unihub-ejb.jar#primary\"jboss.naming.context.java.jboss.datasources.MySqlDSMissing[jboss.persistenceunit.\"unihub-ear.ear/unihub-ejb.jar#primary\"jboss.naming.context.java.jboss.datasources.MySqlDS]"]}}}
我認為我的配置有問題,但整晚都在尋找答案,但無濟於事。 以下是一些潛在的麻煩制造者:
[appdir] /。openshift / config / standalone.xml(數據源部分,無論如何)
<subsystem xmlns="urn:jboss:domain:datasources:1.0">
<datasources>
<datasource jndi-name="java:jboss/datasources/ExampleDS" enabled="false" use-java-context="true" pool-name="H2DS">
<connection-url>jdbc:h2:${jboss.server.data.dir}/test;DB_CLOSE_DELAY=-1</connection-url>
<driver>h2</driver>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
</datasource>
<datasource jndi-name="java:jboss/datasources/MysqlDS" enabled="true" use-java-context="true" pool-name="MysqlDS" use-ccm="true">
<connection-url>jdbc:mysql://${env.OPENSHIFT_MYSQL_DB_HOST}:${env.OPENSHIFT_MYSQL_DB_PORT}/${env.OPENSHIFT_APP_NAME}</connection-url>
<driver>mysql</driver>
<security>
<user-name>adminsTxZQzC</user-name>
<password>cPHNsLcMRDBn</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>
<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="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>
這里是persistence.xml,比較:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="primary">
<jta-data-source>java:jboss/datasources/MySqlDS</jta-data-source>
<properties>
<!-- Properties for Hibernate -->
<property name="hibernate.hbm2ddl.auto" value="create" />
<property name="hibernate.show_sql" value="true" />
</properties>
<!--CLASSES HERE-->
<class>com.unihub.app.Stuff</class>
<class>com.unihub.app.Message</class>
<class>com.unihub.app.User</class>
</persistence-unit>
[APPDIR] /pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<name>unihub application</name>
<modelVersion>4.0.0</modelVersion>
<groupId>com.unihub.app</groupId>
<artifactId>unihub.com</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
...
<profiles>
<profile>
<!-- When built in OpenShift the 'openshift' profile will be used when invoking mvn. -->
<!-- Use this profile for any OpenShift specific customization your app will need. -->
<!-- By default that is to put the resulting archive into the 'deployments' folder. -->
<!-- http://maven.apache.org/guides/mini/guide-building-for-different-environments.html -->
<id>openshift</id>
<build>
<finalName>unihub</finalName>
<plugins>
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<version>2.7</version>
<configuration>
<outputDirectory>deployments</outputDirectory>
</configuration>
</plugin>
<!-- Compiler plugin enforces Java 1.6 compatibility and
activates annotation processors -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<!-- The JBoss AS plugin deploys your ear to a local JBoss
AS container -->
<!-- Due to Maven's lack of intelligence with EARs we need
to configure the jboss-as maven plugin to skip deployment for all modules.
We then enable it specifically in the ear module. -->
<plugin>
<groupId>org.jboss.as.plugins</groupId>
<artifactId>jboss-as-maven-plugin</artifactId>
<version>7.3.Final</version>
<inherited>true</inherited>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</profile>
也許我的openshift配置文件完全錯誤,我很難找到任何類型的文檔或指導如何執行此操作。 無論如何,如果你認為其他文件可能是其中的根源,請告訴我,我會把它們拉起來。 我對調試策略的建議持開放態度。 謝謝!
你做了一個小錯字。
在standalone.xml中,MySQL數據源JNDI名稱是jboss / datasources / MysqlDS
在persistence.xml中,您連接到名為jboss / datasources / MySqlDS的JNDI數據源
那不是相同的數據源。 使名稱相同。
我的應用程序在openshift中運行,因為沒有很多可用於openshift的文檔,有兩種部署,一種可以通過jenkins構建和部署,或者進行熱部署(部署本地生成的war,ear和deploy)
有關不同的部署選項,請參閱openshift文檔
https://www.openshift.com/developers/deploying-and-building-applications
因為我不清楚你的異常,看起來像配置問題,我覺得下面的教程將在這方面幫助你,因為我的應用程序使用jboss作為7與mysql而不是持久層,我通過這個博客,這是有幫助的
http://jaitechwriteups.blogspot.com.br/2011/08/deploy-java-ee-application-on-openshift.html
上面的博客解釋了熱部署,如果你正在進行熱部署,請確保刪除src,如openshift文檔中所述
從您克隆到計算機的應用程序中刪除src目錄和pom.xml文件
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.