I am using Spring, JPA and JBoss 7 in my project.
I am getting the below error while jndi lookup of data source as below
ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/rulesUI]] (MSC service thread 1-4) StandardWrapper.Throwable: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'rulesDataSource': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Error looking up RuleDS, service service jboss.naming.context.java.RuleDS is not started
Here is my standalone.xml in JBoss where datasource is configured.
<datasource jndi-name="java:/RuleDS" pool-name="rule_poc_schema" enabled="true" use-java-context="true" spy="true">
<connection-url>jdbc:oracle:thin:#medicare-ins.cxgvce1cqpuy.us-east-1.rds.amazonaws.com:3306:MEDICARE</connection-url>
<driver>oracle</driver>
<security>
<user-name>APPLICATION_MEA_DEV</user-name>
<password>password</password>
</security>
</datasource>
In my Spring configuration file, I am accessing it using:
<jee:jndi-lookup jndi-name="java:/RuleDS" id="rulesDataSource"/>
Please help me.
Could try this way:
At Spring Context we have:
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:jboss-datasource" />
</bean>
At Jboss I have like this:
<datasources>
<local-tx-datasource>
<jndi-name>jboss-datasource</jndi-name>
<connection-url>jdbc:mysql://127.0.0.1:3306/shoppingDB</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>root</user-name>
<password>123456</password>
<exception-sorter-class-name>
org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter
</exception-sorter-class-name>
<metadata>
<type-mapping>MySql</type-mapping>
</metadata>
<check-valid-connection-sql>select 1</check-valid-connection-sql>
</local-tx-datasource>
</datasources>
make sure you have already spring-context jar
Hope this helps,
Regards
First I would check log for following line:
[org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-2) JBAS010400: Bound data source [java:/RuleDS]
I also use the full name:
java:jboss/datasources/MyDSName
Maybe this is the case?
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 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?
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
I am upgrading from JBoss AS 4.0.4.GA to JBoss 6.0.0.Final.
I have been unable to lookup a HornetQ Topic from an external Java client, so I decided to write a little test Java program that did a simple lookup of a DataSource. That lookup is failing. I can see the DataSource in the web console and it has:
Pool JNDI Name = MyDS
I used to (with JBoss 4.0.4.GA) lookup the DataSource using "java:/MyDS", but that is not working. I have seen some talk about not being able to lookup objects (Queues,Topics,DataSources,EJBs,etc) from outside the AS. I'd be surprised if that is the case, but if it is, then how do I disable that "feature"?
The DS is in server/myconf/deploy/mysql-ds.xml:
<?xml version="1.0" encoding="UTF-8"?>
<datasources>
<local-tx-datasource>
<jndi-name>MyDS</jndi-name>
<connection-url>jdbc:mysql://localhost:3306/mydb</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>xxxxxxxx</user-name>
<password>xxxxxxxx</password>
<prepared-statement-cache-size>50</prepared-statement-cache-size>
<min-pool-size>20</min-pool-size>
<max-pool-size>40</max-pool-size>
<metadata>
<type-mapping>mySQL</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>
The Java program that looks up the DS is:
env.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
env.put(javax.naming.Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
env.put(javax.naming.Context.PROVIDER_URL, "jnp://localhost:1099");
InitialContext ctx = new InitialContext(env);
Object o = ctx.lookup("java:/MyDS");
The lookup line throws a NameNotFoundException:
javax.naming.NameNotFoundException: MyDS not bound
I've tried the lookup with just "MyDS" rather than "java:/MyDS", but it still fails. I don't think the problem is the name I'm using to lookup, rather something preventing me doing any lookup from an external application - and if that is the case, I need to enable such lookups.
Update the datasource definition like:
<use-java-context>false</use-java-context>
e.g.
<?xml version="1.0" encoding="UTF-8"?>
<datasources>
<local-tx-datasource>
<jndi-name>MyDS</jndi-name>
<use-java-context>false</use-java-context>
<connection-url>jdbc:mysql://localhost:3306/mydb</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>xxxxxxxx</user-name>
<password>xxxxxxxx</password>
<prepared-statement-cache-size>50</prepared-statement-cache-size>
<min-pool-size>20</min-pool-size>
<max-pool-size>40</max-pool-size>
<metadata>
<type-mapping>mySQL</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>
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.