Pergunta

This is an app I have previously built and am trying to configure for deployment on Openshift. It runs fine in my local setup in a standalone Jboss AS7 instance. It builds as 3 modules: a .war, a ejb .jar, and a .ear which contains those two - pretty standard, i think.

The error in question (from '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]"]}}}

I assume there is something wrong with my configuration, but have been looking around for an answer all night to no avail. Here are a couple potential troublemakers:

[appdir]/.openshift/config/standalone.xml (the datasources section, anyway)

   <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>

and here's persistence.xml, to compare:

<?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>

Maybe my openshift profile here is totally wrong, I was having a hard time finding any kind of documentation or guides on how to do this. Anyway, if there are any other files you think might be at the root of this, let me know, i'll pull 'em up. I'm open to suggestions as to debugging strategies. Thanks!

Foi útil?

Solução

You made a small typo.

In standalone.xml the MySQL datasource JNDI name is jboss/datasources/MysqlDS

In persistence.xml you connect to a JNDI datasource called jboss/datasources/MySqlDS

That is not the same datasource. Make the names identical.

Outras dicas

i have my application running in openshift, since there are no many documentation available for openshift, there are two kind of deployment, one you can build and deploy through jenkins, or do hot deployment (deploy locally generated war, ear and deploy)

see openshift document for different deployment options

https://www.openshift.com/developers/deploying-and-building-applications

since i am not clear about your exception, seems like configuration issue, i feel the below tutorial will help you in this regard, since my application uses jboss as 7 with mysql but not persistent layer, i went through this blog , which was helpfull

http://jaitechwriteups.blogspot.com.br/2011/08/deploy-java-ee-application-on-openshift.html

above blog explains hot deployment, and if you are doing hot deployment make sure you remove src , as said in openshift documentation

Remove the src directory and the pom.xml file from your application that you cloned to your computer

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top