JBoss 7 missing jboss.naming.context.java - can't run EAR - java

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.

Related

How to switch from default H2 DB of jBPM to another Database like MariaDB?

I've installed MariaDB connector in jBPM 7.53 Final with .jar file and configured MariaDB database locally. Checked in management console and saw that datasources and JDBC connectors look good (MariaDBDS is enabled), but an error showing in runtime "Boot errors occurred during the start of server".
Failure description: {"WFLYCTL0412: Required services that are not
installed:" =>
["jboss.jdbc-driver.mariadb-java-client-2_7_1_jar"],"WFLYCTL0180:
Services with missing/unavailable dependencies" =>
["jboss.driver-demander.java:jboss/MariaDBDS is missing
[jboss.jdbc-driver.mariadb-java-client-2_7_1_jar]","org.wildfly.data-source.MariaDBDS
is missing [jboss.jdbc-driver.mariadb-java-client-2_7_1_jar]"]}
Missing dependencies: jboss.driver-demander.java:jboss/MariaDBDS is
missing [jboss.jdbc-driver.mariadb-java-client-2_7_1_jar]
org.wildfly.data-source.MariaDBDS is missing
[jboss.jdbc-driver.mariadb-java-client-2_7_1_jar]
I have configured MariaDB Java connector in the jBPM standalone.xml
<subsystem xmlns="urn:jboss:domain:datasources:5.0">
<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;DB_CLOSE_ON_EXIT=FALSE</connection-url>
<driver>h2</driver>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
</datasource>
<datasource jta="true" jndi-name="java:jboss/MariaDBDS" pool-name="MariaDBDS" enabled="true" use-java-context="true" use-ccm="true">
<connection-url>jdbc:mariadb://localhost:3306/mysql</connection-url>
<driver-class>org.mariadb.jdbc.Driver</driver-class>
<driver>mariadb-java-client-2.7.1.jar</driver>
<security>
<user-name>root</user-name>
<password>admin</password>
</security>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker"/>
<validate-on-match>true</validate-on-match>
<background-validation>false</background-validation>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter"/>
</validation>
</datasource>
<drivers>
<driver name="mariadb" module="org.mariadb">
<xa-datasource-class>org.mariadb.jdbc.MariaDbDataSource</xa-datasource-class>
</driver>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
</subsystem>
and I have copied the MariaDB Java connector to JBPM_HOME/modules/com/mariadb/main/mariadb-java-client-2.7.1.jar and configured the module.xml like this:
<module xmlns="urn:jboss:module:1.1" name="org.mariadb">
<resources>
<resource-root path="mariadb-java-client-2.7.1.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
Also, in Business-Central to new process instance appeared this attention:
enter image description here
What I am missing or change in these steps? Any idea if jBPM works with the external DB or not?
#KrenarR have you set up these properties under system-properties as well?
<property name="org.kie.server.persistence.ds" value="java:jboss/MariaDBDS"/>
<property name="org.kie.server.persistence.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
You can also add the driver as a core module by means of jboss_cli:
module add --name=org.mariadb --resources=mariadb-java-client-2.7.1.jar --dependencies=javax.api,javax.transaction.api
Also check this line in the datasource:
<driver>mariadb-java-client-2.7.1.jar</driver>
I think it should be just the driver name you have defined:
<driver>mariadb</driver>
You can refer to the documentation Switch to another database
from jbpm.org for detailed steps.

Java web service missing hibernate.dialect

I am trying to create web service with creation to oracle database. As a server I use Wildfly so I initialized JNDI connection using Administrative console in browser.
Standalone.xml
{
...
<datasource jta="false" jndi-name="java:/jdbc/ora" pool-name="ora" enabled="true" use-ccm="false">
<connection-url>jdbc:oracle:thin:#localhost:1522:maindatabase</connection-url>
<driver-class>oracle.jdbc.OracleDriver</driver-class>
<driver>ora</driver>
<security>
<user-name>C##Edgar</user-name>
<password>2301910</password>
</security>
<validation>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
</validation>
<statement>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</datasource>
...
}
But after creating the JPA project and adding <jta-data-source> in persistance.xml it throws me an exception when I try to create .ear file and deploy project.
Persistance.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="Model">
<jta-data-source>java:/jdbc/ora</jta-data-source>
</persistence-unit>
</persistence>
Exception is:
JBAS014777: Services which failed to start: service jboss.persistenceunit."App1.ear#Model"
service jboss.persistenceunit."App1.ear#Model": org.jboss.msc.service.StartException in service jboss.persistenceunit."App1.ear#Model": org.hibernate.HibernateException: Unable to determine Dial
ect to use [name=Oracle, majorVersion=12]; user must register resolver or explicitly set 'hibernate.dialect'
Maybe someone can tell me what I missed or done wrong?

Add new Datasource (mysql) wildfly

I'm trying to add new datasource mysql jdbc driver to my wildfly server
I created folder wildfly.x.x.x/modules/system/layers/base/com/mysql/main
I've got here jdbc jar file and module.xml
<module xmlns="urn:jboss:module:1.3" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-5.1.34-bin.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
</dependencies>
</module>
then added dataresource code into standalone-full.xml (under datareources tag)
<datasource jndi-name="java:jboss/datasources/MySQLDS" pool-name="MySQLDS" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://localhost:3306/test</connection-url>
<driver>MySQLDriver</driver>
<security>
<user-name>root</user-name>
<password></password>
</security>
</datasource>
but when i go to wildfly control panel http://localhost:9990/console/
dataresource doesnt appear , what did i missed?
also i'm trying to add it manually from interface i'v got this error
Unexpected HTTP response: 500
Request
{
"address" => [
("subsystem" => "datasources"),
("data-source" => "mysql")
],
"operation" => "test-connection-in-pool"
}
Response
Internal Server Error
{
"outcome" => "failed",
"failure-description" => "JBAS010440: failed to invoke operation: JBAS010447: Connection is not valid",
"rolled-back" => true
}
Did you add a driver definition? Your datasources subsystem should look something like this:
<subsystem xmlns="urn:jboss:domain:datasources:2.0">
<datasources>
<datasource jndi-name="java:/jdbc/myds" pool-name="myds" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://localhost/mydb</connection-url>
<driver>mysql</driver>
<security>
<user-name>foo</user-name>
<password>bar</password>
</security>
</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">
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
</subsystem>
The driver element in the data source definition must reference a driver element by name. The module attribute must match the name of your MySQL driver module.
Actually I meet the same problem (I could add the datasources and test connection successfully before) So I'm just confused and I find a way works for me:)
See my services and I find it stopped,and I started it then tried again,It works well again! Even though your service does not stop, maybe just restart it.
I have to say it may not work for you if you never success to connect before,good luck~
There are three ways using which you can simply create datasource into wildfly
Using admin console
Manually adding into standalone.xml
Creating datasource file that is xml file.
Go to WildFly directory/standalone/deployments
Simplest way to create datasource xml with following content
<datasources xmlns="http://www.jboss.org/ironjacamar/schema">
<datasource jndi-name="APP_DS" pool-name="APP_DS" enabled="true" use-ccm="false">
<connection-url>jdbc:mysql://localhost:3306/DB_NAME</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<driver>mysql</driver>
<!-- sql to call when connection is created -->
<new-connection-sql>SELECT 1</new-connection-sql>
<pool>
<min-pool-size>5</min-pool-size>
<max-pool-size>50</max-pool-size>
</pool>
<security>
<user-name>username</user-name>
<password>password</password>
</security>
<!-- sql to call on an existing pooled connection when it is obtained from pool -->
<validation>
<check-valid-connection-sql>SELECT 1</check-valid-connection-sql>
</validation>
<timeout>
<blocking-timeout-millis>300000</blocking-timeout-millis>
<idle-timeout-minutes>5</idle-timeout-minutes>
</timeout>
<statement>
<track-statements>true</track-statements>
</statement>
</datasource>
</datasources>
Also create the database that you will use. Sometimes the reason for this error is that the database is missing.

Openshift failed deployment on JBoss AS7, MYSQL dependency error

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

CDI + JPA + EJB + JTA + JSF --JBoss-Kitchen Example with PostgreSQL?

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.

Categories