Hi,
I've setup a datasource in jboss standalone.xml and trying to access the datasource. The app doesn't start siting errors from my web.xml configurations.
Have been getting this error, no matter the change in settings:
{"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014771: Services with missing/unavailable dependencies" => [
"jboss.naming.context.java.module.myapp.myapp.env.myDataSource is missing [jboss.naming.context.java.jboss.datasources.myDataSource]
]}}}
Here is my web.xml
<resource-ref>
<description>SQL Server Spring JNDI Datasource </description>
<!-- res-ref-name>jdbc/myDataSource</res-ref-name-->
<res-ref-name>myDataSource</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<lookup-name>java:jboss/datasources/myDataSource</lookup-name>
</resource-ref>
Here is my setting in standalone.xml
<datasources>
<datasource jndi-name="java:jboss/datasources/myDataSource" pool-name="myDataSource" enabled="true" use-java-context="true">
<connection-url>jdbc:sqlserver://10.0.0.0:1433;DatabaseName=my_Local</connection-url>
<driver>mssql</driver>
<security>
<user-name>user</user-name>
<password>user1</password>
</security>
</datasource>
<drivers>
<driver name="mssql" module="com.microsoft">
<xa-datasource-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</xa-datasource-class>
</driver>
</drivers>
</datasources>
I've copied the SQL server jdbc jar file to $jbosshome/modules/com/microsoft/main
and added a module.xml
<module xmlns="urn:jboss:module:1.1" name="com.microsoft"><resources>
<resource-root path="sqljdbc4.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
<module name="javax.servlet.api" optional="true"/>
</dependencies>
</module>
Any help is greatly appreciated.
-vg
Remote lookup of datasources is not supported in AS7.
Similar question has been answered here
Related
I have migrated my application from jboss5.1.2-eap to jboss-7.2-eapand java6 to java8 but after migration it is starting giving me exception while starting the server.
Caused by: java.lang.NoClassDefFoundError: Lorg/apache/commons/dbcp/BasicDataSource
we have a datasource.xml file present in the classpath of the server, having the following line of code.
<bean id="beanName" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="oracle.jdbc.OracleDriver"/>
<property name="maxActive" value="10"/>
Also we have commons-dbcp-1.2.2.jar present in the classpath but it is not working for jboss-7.2-eap.
Now I am not sure if commons-dbcp-1.2.2.jar is supported by jboss7-eap. as it is present in the classpath of the application(present in the loaded module), but still spring is not able to create the bean for datasource.
I suppose that datasource in Jboss EAP should be placed in standalone.xml configuration file and looks like here:
<datasource jndi-name="java:jboss/datasources/Altis" pool-name="Altis" enabled="true">
<connection-url>jdbc:oracle:thin:#255.255.255.255:1521:sid</connection-url>
<driver-class>oracle.jdbc.OracleDriver</driver-class>
<driver>oracle</driver>
<security>
<user-name>username</user-name>
<password>passwd</password>
</security>
</datasource>
Given module information in the jboss-deployment-structure.xml inside the WEB-INF directory of the war file.
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="com.oracle.sql" export="true"/>
<module name="org.apache.commons.dbcp" export="true"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
Also the module directories should also follow the same naming convention as per the availability of your .class files inside the jar, like in my case I have created module org.apache.commons.dbcp as while opening commons-dbcp-1.2.2.jar file, .class files are present inside org/apache/commons/dbcp folder.
Note: In case of multiple modules, you need to identify there dependency if a module is dependent on other and that information will be given inside module.xml file. like
<module xmlns="urn:jboss:module:1.1" name="org.apache.commons.dbcp">
<resources>
<resource-root path="commons-dbcp-1.2.2.jar"/>
</resources>
<dependencies>
<module name="org.apache.commons.pool"/>
<module name="com.oracle.jdbc.driver"/>
</dependencies>
</module>
I have added below profile in \standalone\configuration\Standalone-full.xml but still not done with mysql db.
I added jbpmDS as mysql data source but still jbpm not going to use this one, both datasources are valid and connect as I confirmed from admin console.
If I remove ExampleDS data source then its getting failed totally as ExampleDS is required and mandatory as I get reference from other community forum. Please suggest if anybody have configured same earlier.
<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 jndi-name="java:jboss/datasources/jbpmDS" pool-name="jbpmDS" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://localhost:3306/jbpm</connection-url>
<driver>mysql</driver>
<security>
<user-name>root</user-name>
<password>root</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.mysqldatabase.mysql">
<driver-class>com.mysql.jdbc.Driver</driver-class>
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
Add below system properties in standalone-full.xml file,
<system-properties>
<property name="org.kie.server.persistence.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect"/>
<property name="org.kie.server.persistence.ds" value="java:jboss/datasources/jbpmDS"/>
</system-properties>
I was facing the same issue.
Fixed it by adding system-properties in standalone.xml-
<system-properties>
<property name="org.kie.server.persistence.dialect"
value="org.hibernate.dialect.MySQL5Dialect"/>
<property name="org.kie.server.persistence.ds"
value="java:jboss/datasources/jbpmDS"/>
</system-properties>
Make Sure you have added mysql connector jar and module.xml in below path \modules\system\layers\base\com\mysqldatabase\mysql\main
module.xml
<module xmlns="urn:jboss:module:1.5" name="com.mysqldatabase.mysql">
<resources>
<resource-root path="mysql-connector-java-5.1.38.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
<module name="javax.servlet.api" optional="true"/>
</dependencies>
I'm using Jboss EAP 7.1 now, recently I add the Oracle datasource to the server as the datasource I correctly configured before. But I got the error message:
Services with missing/unavailable dependencies" => [
"org.wildfly.data-source.CreditDS is missing [jboss.jdbc-driver.oracle11g]"
CreditDs is my JNDI name and oracle11g is the driver name. Here are my configuration:
<!-- standalone.xml -->
<datasource jndi-name="java:jboss/datasources/CreditDS" pool-name="CreditDS" enabled="true">
<connection-url>jdbc:oracle:thin:#***</connection-url>
<driver>oracle11g</driver>
…… …… ……
</datasource>
<drivers>
<driver name="oracle11g" module="com.oracle.ojdbc14">
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
</driver>
</drivers>
Here is the modules.xml in modules/com/oracle/ojdbc14/main
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.oracle.ojdbc14">
<resources>
<resource-root path="ojdbc14-10.2.0.4.0.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
What's wrong?
I guess your oracle module is not recognized correctly.
The procedure for adding oracle JDBC module is as follows:
1 create folder com/oracle/ojdbc14/10.2.0.4.0 withing JBOSS_HOME/modules directory
2 copy your oracle jar file to the folder and add a module.xml with the following contents
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.3" name="com.oracle.ojdbc14" slot="10.2.0.4.0">
<resources>
<resource-root path="ojdbc14-10.2.0.4.0.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
3 Create driver definition in standalone.xml
<driver name="oracle14" module="com.oracle.ojdbc14:10.2.0.4.0">
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
</driver>
Couple of things to note:
Do pay attention to correct version of JBoss modules XMLNS - you tagged your questions with EAP7 - so you should use xmlns 1.3.
Note the slot value in both modules.xml and driver definition. This could be any value, but it is a good practice to use the lib version.
After adding any modules into JBoss, you need to restart it completely(restart JVM).
Lastly, you should use an up-to-date version of Oracle JDBC driver as ojdbc14 are not supported anymore, so it should be like this:
Module.xml
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.3" name="com.oracle.ojdbc7" slot="12.1.0.2">
<resources>
<resource-root path="ojdbc7-12.1.0.2.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
Folder modules/com/oracle/ojdbc7/12.1.0.2
Driver:
<driver name="oracle7" module="com.oracle.ojdbc7:12.1.0.2">
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
</driver>
I work on a Java EE web application, I use Eclipse Indigo as IDE, JBoss 7.1 as application server and Oracle 10j as Database.
I created this directory modules\oracle\jdbc\driver\main in the home folder of JBoss 7.1 and I add the Oracle driver and the file module.xml.
The contents of the module.xml file is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="oracle.jdbc.driver">
<resources>
<resource-root path="ojdbc6.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
</dependencies>
</module>
I've done all the necessary configuration on the file server standalone.xml.
The contents of the standalone.xml file is as follows:
<datasources>
<datasource jndi-name="java:jboss/datasources/EmnaDS" pool-name="11gDS" enabled="true" jta="true" use-java-context="true" use-ccm="true">
<connection-url>jdbc:oracle:thin:#//localhost:1521/XE</connection-url>
<driver>oracle</driver>
<pool>
<prefill>false</prefill>
<use-strict-min>false</use-strict-min>
<flush-strategy>FailingConnectionOnly</flush-strategy>
</pool>
<security>
<user-name>bct</user-name>
<password>emna</password>
</security>
</datasource>
<drivers>
<driver name="oracle" module="oracle.jdbc.driver">
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
</driver>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
I created an EJB project in eclipse, I add the JPA facet.
The contents of the persistence.xml file is as follows:
<?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="BCTProjet">
<jta-data-source>java:jboss/datasources/EmnaDS</jta-data-source>
<class>com.bct.entity.utilisateur</class>
<properties>
<property name="hibernate.hbm2ddl.auto" value="create" />
</properties>
</persistence-unit>
</persistence>
When I add the project on the server and I run it, I have this result:
14:17:58,198 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-6) JBAS010400: Bound data source [java:jboss/datasources/EmnaDS]
14:17:58,267 INFO [org.jboss.as] (Controller Boot Thread) JBAS015874: JBoss AS 7.1.0.Final "Thunder" started in 9404ms - Started 135 of 206 services (70 services are passive or on-demand)
But the project is not deployed on the server and I could not see generated tables for the classes in the database?
The log is too few to identify the problem. But your datasource is ok. I think something is wrong with your app. Or it doesn't deploy at all.
I run jboss in standalone mode and have set my datasource in the standalone.xml to the following:
<datasource jndi-name="MyDenaliDS" pool-name="MyDenaliDs_Pool" enabled="true" jta="true"
use-java-context="true" use-ccm="true">
<connection-url>
jdbc:sqlserver://myip:1433;databaseName=mydb;integratedSecurity=true
</connection-url>
<driver>
sqljdbc
</driver>
<security>
<user-name>
username
</user-name>
<password>
password
</password>
</security>
</datasource>
<drivers>
<driver name="sqljdbc" module="com.microsoft.sqlserver.jdbc">
<driver-class>
com.microsoft.sqlserver.jdbc.SQLServerDataSource
</driver-class>
</driver>
</drivers>
in the folder %jbosshome%\modules\com\microsoft\sqlserver\jdbc\ I have the sqljdb4.jar and the following module.xml:
<?xml version="1.0" encoding="UTF-8"?>
<module name="com.microsoft.sqlserver.jdbc" xmlns="urn:jboss:module:1.0">
<resources>
<resource-root path="sqljdbc4.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
When I start the jboss it gives me the following error:
> New missing/unsatisfied dependencies: service
> jboss.jdbc-driver.sqljdbc (missing)
Anyone know what I've done incorrect or what I'm missing?
using Jboss AS 7.1.1, as well as putting the module in %jbosshome%\modules\com\microsoft\sqlserver\jdbc\main I had to make a slight change to the xml - the driver element in standalone.xml should be :
<driver name="sqljdbc" module="com.microsoft.sqlserver.jdbc">
<driver-class>
com.microsoft.sqlserver.jdbc.SQLServerDriver
</driver-class>
</driver>
and the module.xml should be:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.microsoft.sqlserver.jdbc">
<resources>
<resource-root path="sqljdbc4.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
<module name="javax.servlet.api" optional="true"/>
</dependencies>
</module>
With Jboss 7.1.1 I managed to get it working without specifying module.
Just put sqljdbc4.jar into deployment directory:
%JBOSSHOME%\standalone\deployments
Configuration needed for datasource in standalone.xml is as follows:
<datasource jndi-name="java:jboss/datasources/myPool" pool-name="myPool" enabled="true" use-java-context="true">
<connection-url>jdbc:sqlserver://127.0.0.1:1433;databaseName=myName;</connection-url>
<driver>sqljdbc4.jar</driver>
<pool>
<min-pool-size>10</min-pool-size>
<max-pool-size>100</max-pool-size>
<prefill>true</prefill>
</pool>
<security>
<user-name>myUser</user-name>
<password>myPassword</password>
</security>
<statement>
<prepared-statement-cache-size>32</prepared-statement-cache-size>
<share-prepared-statements>true</share-prepared-statements>
</statement>
</datasource>
got the same error like you before
instead of %jbosshome%\modules\com\microsoft\sqlserver\jdbc\
try %jbosshome%\modules\com\microsoft\sqlserver\jdbc\main
and put the .jar of the jdbc driver and the module.xml overthere.
I used this configuration and it worked OK on AS7
<datasource jndi-name="java:jboss/datasources/stagingDS" pool-name="stagingDS" enabled="true" use-java-context="true">
<connection-url>jdbc:sqlserver://linp-sqlrpt-01;databaseName=pmdm</connection-url>
<driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
<driver>sqlserver</driver>
<security>
<user-name>username</user-name>
<password>password</password>
</security>
</datasource>
<drivers>
<driver name="sqlserver" module="com.microsoft.jdbc">
<xa-datasource-class>com.microsoft.sqlserver.jdbc.SQLServerXADataSource</xa-datasource-class>
</driver>
</drivers>
Of course if you're not using the distributed DataSource you can configure the regular driver class as previously defined.
The module file looks like this.
<module xmlns="urn:jboss:module:1.1" name="com.microsoft.jdbc">
<properties>
<property name="jboss.api" value="private"/>
</properties>
<resources>
<resource-root path="sqljdbc4.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
<module name="javax.servlet.api" optional="true"/>
</dependencies>
</module>
Deploying JDBC jar file (e.g. sqljdbc41.jar) by admin console should allow to select and use it when defining a new data source.
this is the work for me.
in JBOSS 7, MSSQL JDBC driver 6, type 4, file name:sqljdbc42.jar
Install the driver name:sqljdbc42.jar in [JBoss HOME]\modules\com\microsoft\main
add under the same directory module.xml with content below
<module xmlns="urn:jboss:module:1.1" name="com.microsoft">
<resources>
<resource-root path="sqljdbc42.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.xml.bind.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
insert datasource definition to standalone.xml in block <subsystem xmlns="urn:jboss:domain:datasources:4.0"> <datasources> as below
<datasource jta="true" jndi-name="java:jboss/datasources/iwebDS" pool-name="MSSQLDS" enabled="true" use-ccm="true">
<connection-url>jdbc:sqlserver://172.24.17.52:1803;DatabaseName=IWEB_IWEBSIT</connection-url>
<driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
<driver>sqlserver2008</driver>
<pool>
<min-pool-size>10</min-pool-size>
<initial-pool-size>10</initial-pool-size>
<max-pool-size>100</max-pool-size>
<flush-strategy>FailingConnectionOnly</flush-strategy>
</pool>
<security>
<user-name>[sqlserver user]</user-name>
<password>[sqlserver password]</password>
</security>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mssql.MSSQLValidConnectionChecker"/>
<background-validation>true</background-validation>
</validation>
</datasource>
insert driver definition to standalone.xml in block <subsystem xmlns="urn:jboss:domain:datasources:4.0"> <drivers> as below
<driver name="sqlserver2008" module="com.microsoft">
<driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
</driver>
ps: "sqlserver2008" is the name as you wish.