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!
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.
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
Related
My question is: How do I map a datasource to a specific jndi-name configured inside wildfly so that multiple deployed .war-files each can use their own specific datasource. The mapping should take place at deployment so that a configuration inside wildfly and the specific project is sufficient.
We got a project which supports multi-tenancy. The structure is as follows:
customerSpecificProject
|-- ui (generic)
|----database (generic)
|----services (generic)
|----etc...
In the database-project a standard datasource is specified which goes by a standard jndi-name java:/xyzDS. Since we migrated from tomcat to wildfly we want to make use of the ability to host multiple applications in our AS.
To achieve this we have to map the java:/xyzDS to the datasources defined in the standalone.xml:
<subsystem xmlns="urn:jboss:domain:datasources:4.0">
<datasources>
<datasource jta="true" jndi-name="java:/customer1DS" pool-name="c1DS" enabled="true" use-ccm="true">
...
</datasource>
<datasource jta="true" jndi-name="java:/customer2DS" pool-name="c2DS" enabled="true" use-ccm="true">
...
</datasource>
Therefore we tried to use the jboss-web.xml located in the WEB-INF folder of our customerProject:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web xmlns="http://www.jboss.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.jboss.com/xml/ns/javaee
http://www.jboss.org/j2ee/schema/jboss-web_5_1.xsd">
<resource-ref>
<res-ref-name>java:/xyzDS</res-ref-name>
<jndi-name>java:/customer1DS</jndi-name>
</resource-ref>
</jboss-web>
persistence.xml inside the database-Project:
<?xml version='1.0' encoding='UTF-8'?>
<persistence version="2.1"
xmlns="http://xmlns.jcp.org/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_1.xsd">
<persistence-unit name="xyzDB" transaction-type="JTA">
<jta-data-source>java:/xyzDS</jta-data-source>
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>...</class>
...
<class>...</class>
<shared-cache-mode>NONE</shared-cache-mode>
<validation-mode>NONE</validation-mode>
<properties>
<property name="eclipselink.weaving" value="static" />
</properties>
</persistence-unit>
</persistence>
It does not seem to be working. I talked to a colleague who had a similar issue and resolved it in the corresponding way for a websphere AS. I do not know if the problem resides in the structure having a nested databaseProject inside another lib (ui) for the actual customerProject or if it is caused by bad configuration.
Also we use the #Resource Annotation inside some DAOs:
#Resource(lookup = "java:/xyzDS")
private DataSource dataSource;
Maybe the mapping works but not for the annotations inside the compiled DAOs? But I do not understand why that should not work.
Current Error in Stacktrace:
11:18:20,839 ERROR [org.jboss.as.controller.management-operation] (DeploymentScanner-threads - 1) WFLYCTL0013: Operation ("full-replace-deployment") failed - address: ([]) - failure description: {
"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"xyz.war\".INSTALL" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"xyz.war\".INSTALL: WFLYSRV0153: Failed to process phase INSTALL of deployment \"xyz.war\"
Caused by: java.lang.IllegalArgumentException: WFLYEE0047: Incompatible conflicting binding at java:/xyzDS source: lookup (java:/customer1DS)"},
Edit: Already tried adding:
<property name="wildfly.jpa.twophasebootstrap" value="false"/>
To persistence.xml
Have you checked the question/answer in wildfly-development.1055759.n5.nabble.com? In this exchange, it was determined that the persistence unit needed a hint in the form of
<property name="wildfly.jpa.twophasebootstrap" value="false"/>
I don't know if this is applicable in your case, but is worth looking at.
I'm new to this, did a lot of research now and still I'm not able to develop a working Wildfly / Hibernate / MongoDB Environment.
Here is basically did so far:
Read this Guide
Download Wildfly 10
Download Hibernate OGM 5.1.0.Final and ORM 5.1.4 Modules Archive
Extract Modules into wildfly/modules
Download/Install MongoDB (i tried 2 Versions)
via Brew on Mac
via Ubuntu in an VM
Create new Maven Web Project in Netbeans
Next Step is to edit pom.xml, jboss-deployment-structure.xml, persistence.xml. And that's the Point where the trouble begins. I tried different entries and get different errors. Right now my configuration looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="org.hibernate.ogm" slot="5.1" services="export" />
<module name="org.hibernate.ogm.mongodb" slot="5.1" services="export" />
</dependencies>
</deployment>
</jboss-deployment-structure>
I saw different Versions of this file, sometimes with slot="main", sometimes with services="import".
Persitence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="comic-PU" transaction-type="JTA">
<provider>org.hibernate.ogm.jpa.HibernateOgmPersistence</provider>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="jboss.as.jpa.providerModule" value="org.hibernate:5.1"/>
<property name="hibernate.ogm.datastore.provider" value="mongodb"/>
<property name="hibernate.ogm.datastore.database" value="comicDB"/>
<property name="hibernate.ogm.datastore.host" value="localhost"/>
<property name="hibernate.ogm.datastore.port" value="27017"/>
<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
</properties>
I'am pretty sure here is something wrong. When deploying the Project, Wildfly tries to read persistence.xml, then stuck for a moment and:
20:58:33,255 INFO [org.jboss.as.jpa] (MSC service thread 1-6) WFLYJPA0002: Read persistence.xml for comic-PU
21:03:32,767 ERROR [org.jboss.as.controller.management-operation] (DeploymentScanner-threads - 1) WFLYCTL0348: Timeout after [300] seconds waiting for service container stability. Operation will roll back. Step that first updated the service container was 'deploy' at address '[("deployment" => "MYAPP.war")]'
21:03:32,772 ERROR [org.jboss.as.server] (DeploymentScanner-threads - 1) WFLYSRV0022: Deploy of deployment "ComicFeeder-1.0.war" was rolled back with no failure message
Pom.xml is mostly auto-generated, i added
<dependency>
<groupId>org.hibernate.ogm</groupId>
<artifactId>hibernate-ogm-mongodb</artifactId>
<version>5.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.ogm</groupId>
<artifactId>hibernate-ogm-core</artifactId>
<version>5.1.0.Final</version>
</dependency>
<archive>
<manifestEntries>
<mode>development</mode>
<url>${project.url}</url>
<Dependencies>org.hibernate.ogm:5.1 services, org.hibernate.ogm.mongodb:5.1 services</Dependencies>
</manifestEntries>
</archive>
Is the manifest entry necessary?
An Errors I got:
Wildfly: org.hibernate.search.engine 5.6.1.Final not found
in wildfly/modules/org/hibernate/search/engine the modules name is "5.6.1.Final-orm51" -> renamed it to 5.6.1.Final, edit the Entry in 5.6.1.Final/modules.xml
Wildfly then starts without that error
This looks like a bug to me
Where is my mistake? What's your "workflow" when you start a new project with hibernate, wildfly and mongodb?
Would it be easier to use Glassfish or any other Server?
Some Tutorials I found are outdated or just did not work (for me).
im trying to create a new datasource and "lookup" from java code.
First i created folder, jboss-as-7.1.0.Final\modules\com\mysql\main and copy to there 2 files.
mysql-connector-java-5.1.14-bin and module.xml
My module.xml contains
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-5.1.14-bin.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
Second i added in file standalone.xml,this..
<datasource jndi-name="java:jboss/datasources/MySqlDS" pool-name="MySqlDS" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://127.0.0.1:3306/myTable</connection-url>
<driver>mysql</driver>
<security>
<user-name>root</user-name>
<password>root</password>
</security>
</datasource>
<drivers>
<driver name="mysql" module="com.mysql">
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
</driver>
And last, i tried to call it from java code like this:
DataSource ds = (DataSource) ctx.lookup("jboss/datasources/MySqlDS");
connection = ds.getConnection();
But got this error..
javax.naming.NameNotFoundException: jboss/datasources/MySqlDS -- service jboss.naming.context.java.jboss.datasources.MySqlDS
Anyway,when i started my jboss server i got and error,too
New missing/unsatisfied dependencies:
service jboss.jdbc-driver.mysql (missing) dependents: [service jboss.data-source.java:/MySqlDS]
Please try using
DataSource ds = (DataSource) ctx.lookup("java:jboss/datasources/MySqlDS");
It's probably happened because the Data Source is not configured properly. I had a similar issue but when I configured it using JBoss Admin Console, it worked. Also try to check if you have .jar extension in your module.xml.
Try following this link step by step. It works perfectly.
I am trying to learn the new technologies CDI + JPA + EJB + JTA + JSF so, i have downloaded the sample project from JBoss-Community--> jboss-as-kitchensink(from JBoss in my Eclipse juno).
I am Trying to connect the kitchen with my PostgreSQL database:
My database name is : sampledb
My Table(Member) Structure is : Database name :QUICKSTART_DATABASENAME
CREATE TABLE member
(
id integer,
name text,
email text,
phone_number numeric
);
I have edited this files in my kitchen Project :
persistence.xml
<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/PostgreSQLDS</jta-data-source>
<properties>
<!-- Properties for Hibernate -->
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
<property name="hibernate.show_sql" value="true"/>
</properties>
</persistence-unit>
</persistence>
I Added the Dependency in pom.xml:
<!-- PostgreSQL Dependency -->
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901.jdbc4</version>
</dependency>
But i'm getting error:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.554s
[INFO] Finished at: Sat Sep 21 14:01:48 IST 2013
[INFO] Final Memory: 20M/175M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.jboss.as.plugins:jboss-as-maven-plugin:7.2.Final:deploy (default-cli) on project jboss-as-kitchensink: Deployment f
ailed and was rolled back. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
C:\Users\mypc\java\workspace\jboss-as-kitchensink>
What should i do so that i can run this application with my database to insert the data.
Do i need to change any code in .java files or any .xml file to make it work?
EDITED after Comments: By Following this link,I have configured my PostgreSQL into JBoss manually
by setting up the standalone-full.xml file of JBoss..
----///---- <datasources>
<datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">
<connection-url>jdbc:h2:mem: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/PostgreSQLDS" pool-name="PostgreSQLpool" enabled="true" use-java-context="true">
<connection-url>jdbc:postgresql://localhost:5432/QUICKSTART_DATABASENAME</connection-url>
<driver>org.postgresql.Driver</driver>
<security>
<user-name>postgres</user-name>
<password>postgres</password>
</security>
</datasource>
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
<driver name="postgresql" module="org.postgresql">
<xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
----////---
Answer :
Install the PostgreSQL driver and use the XML so that u can make it work.
Follow The Steps : (Suggested By #Craig Ringer) is Very HelpFull
Download PgJDBC. I'm assuming you're using postgresql-9.2-1003.jdbc4.jar, the current version at time of writing. Adjust any filenames to match if you need a different version.
Now deploy the JDBC driver to JBoss AS 7 by putting it in the deployments folder or using the deploy command in jboss-cli. This will work for most, but not all, purposes.
Alternately, you an define a PostgreSQL JDBC driver module:
Create the path $JBOSS_HOME/modules/org/postgresql/main. The modules/org part should already exist, make directories for the rest.
In $JBOSS_HOME/modules/org/postgresql/main/modules.xml with the following content, changing the resource-root entry for the PgJDBC driver to refer to the driver you wish to use.
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="org.postgresql">
<resources>
<resource-root path="postgresql-9.2-1003.jdbc4.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
<module name="javax.servlet.api" optional="true"/>
</dependencies>
</module>
Into the same directory as modules.xml place postgresql-9.2-1003.jdbc4.jar
Open jboss-cli by running $JBOSS_HOME/bin/jboss-cli --connect
Run the command:
/subsystem=datasources/jdbc-driver=postgresql-driver:add(driver-name=postgresql-driver, driver-class-name=org.postgresql.Driver, driver-module-name=org.postgresql)
Now create any required data sources, etc, using postgresql-driver as the driver name.
You can create a datasource via the web ui, with jboss-cli with the data-source create command (see data-source --help, data-source add --help), or by deploying a -ds.xml file like this:
<?xml version="1.0" encoding="UTF-8"?>
<datasources>
<datasource jndi-name="java:/datasources/PostgresqlDS" enabled="true" use-java-context="true"
pool-name="PostgresqlDS">
<connection-url>jdbc:postgresql:dbname</connection-url>
<driver>postgresql-driver</driver>
<security>
<user-name>username</user-name>
<password>password</password>
</security>
</datasource>
</datasources>
For KitchenSink Example: I Tried With These, It Worked till Connection and All the Things.Still It Should be updated After Later...
Follow this link Till Creating a database and a user & continue the rest from here !
Change Persistance To :
persitance.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/KitchenQuickStartDS</jta-data-source>
<properties>
<!-- Properties for Hibernate -->
<property name="hibernate.show_sql" value="true" />
</properties>
</persistence-unit>
</persistence>
test-persistance.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/KitchensinkQuickstartTestDS</jta-data-source>
<properties>
<!-- Properties for Hibernate -->
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="hibernate.show_sql" value="false" />
</properties>
</persistence-unit>
</persistence>
test-ds.xml
<?xml version="1.0" encoding="UTF-8"?>
<datasources xmlns="http://www.jboss.org/ironjacamar/schema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jboss.org/ironjacamar/schema http://docs.jboss.org/ironjacamar/schema/datasources_1_0.xsd">
<datasource jndi-name="java:jboss/datasources/KitchenQuickStartTestDS"
pool-name="KitchenQuickStartTestDS" enabled="true"
use-java-context="true">
<connection-url>jdbc:postgresql://localhost:5432/QUICKSTART_DATABASENAME</connection-url>
<driver>postgresql-driver</driver>
<security>
<user-name>username</user-name>
<password>password</password>
</security>
</datasource>
</datasources>
kitchensink-quickstart-ds.xml
<?xml version="1.0" encoding="UTF-8"?>
<datasources xmlns="http://www.jboss.org/ironjacamar/schema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jboss.org/ironjacamar/schema http://docs.jboss.org/ironjacamar/schema/datasources_1_0.xsd">
<!-- The datasource is bound into JNDI at this location. We reference
this in META-INF/persistence.xml -->
<datasource jndi-name="java:jboss/datasources/KitchenQuickStartDS"
pool-name="KitchenQuickStartDS" enabled="true"
use-java-context="true">
<connection-url>jdbc:postgresql://localhost:5432/QUICKSTART_DATABASENAME</connection-url>
<driver>postgresql-driver</driver>
<security>
<user-name>username</user-name>
<password>password</password>
</security>
</datasource>
</datasources>
But Where i'm Stuck is :
I'm Unable to insert the Data Inot the Database! It is raising an error as
ERROR: relation "hibernate_sequence" does not exist Position: 17
I need A Help To Configure It .. I tried in MANY ways
I dont know if you still need help with this but I encounted similar error when deploying my application to the Openshift.
First I connected over SSH to openshift console. Then I ran psql (you can run psql on your host from $POSTGRES_HOME/bin/psql) with credentials for my postgres connection and used \ds and \dt to determine that hibernate_sequence was a table and not a sequence.
So I dropped it: DROP TABLE hibernate_sequence;
And recreated it as a sequence: CREATE SEQUENCE hibernate_sequence;
For the Error Raised as: ERROR: relation "hibernate_sequence" does not exist Position: 17
i had created a SEQUENCE as Suggested by #Martin Nuc.
To Check Whether there is a Sequence in the Database or not use \ds : Lists the Sequences in the database.
CREATE SEQUENCE hibernate_sequence;
Then i had raised with few more errors like -> Type Cast like things then after Clearing those Errors It Worked ! Finally :-)
Thanks for the Support Every1 :)
Alternatively you can also add #Generator instead of being auto, you can add sequence and specify a sequence generator that is used by PostGre which is ${table_name}_${pk}_seq.
Nevertheless, One draw back of doing this is to making your app tightly coupled to sequences.
Another strategy is to make hibernate create that hibernate_sequence if you force it to create DDL.
I'm trying to run an ear on jboss 7 and everytime I run the ear I get this error:
"Services with missing/unavailable dependencies" =>
["jboss.persistenceunit.\"PROJECTNAME.jar#PROJECTNAMEPU\" missing [
jboss.naming.context.java.PROJECTNAME ]"]
Also before this error I get this feedback for every session/entity bean;
INFO
[org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor]
(MSC service thread 1-8) JNDI bindings for session bean named
SESSIONBEAN in deployment unit subdeployment "PROJECTNAME.war" of
deployment "PROJECTNAME.ear" are as follows:
I tried looking it up and idk what I'm missing, any suggestions or help??
UPDATE:
In my standalone.xml for jboss
<datasource jndi-name="java:jboss/datasources/PROJECTNAME" enabled="true" use-java-context="true" pool-name="PROJECTNAME" use-ccm="false">
<connection-url>jdbc:oracle:thin:#SERVER:PORT:support</connection-url>
<driver>ojdbc14.jar</driver>
<pool>
<min-pool-size>10</min-pool-size>
<max-pool-size>20</max-pool-size>
<prefill>true</prefill>
</pool>
<security>
<user-name>USERNAME</user-name>
<password>PASS</password>
</security>
</datasource>
<xa-datasource jndi-name="java:jboss/datasources/PROJECTNAME" pool-name="PROJECTNAME">
<driver>ojdbc14.jar</driver>
<xa-datasource-property name="URL">jdbc:oracle:thin:#SERVER</xa-datasource-property>
<xa-pool>
<min-pool-size>10</min-pool-size>
<max-pool-size>20</max-pool-size>
<prefill>true</prefill>
</xa-pool>
<security>
<user-name>USERNAME</user-name>
<password>PASS</password>
</security>
</xa-datasource>
<drivers>
<driver name="oracle" module="com.oracle.ojdbc14">
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
</driver>
</drivers>
My persitence.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="PROJECTNAMEPU" transaction-type="JTA">
<jta-data-source>java:jboss/datasources/PROJECTNAME</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties/>
</persistence-unit>
</persistence>
Looks like your EAR requires some JNDI bindings to be configured in JBoss, likely DataSources for use by JPA. Java EE applications can have dependencies on services provided by the container and those are usually looked up using the naming service (JNDI).
Check the deploy/install instructions that come with the EAR you're trying to deploy, or refer back to whoever provides the application. Unfortunately it's not possible to provide much more help without much more info.