繁体   English   中英

Openshift在JBoss AS7上部署失败,MYSQL依赖性错误

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM