I have JBoss 4 with 2 Oracle datasources: CurrentDS and ArchiveDS.
But hibernate uses only scheme for CurrentDS when creates tables from annotations, and scheme for ArchiveDS stays empty. My opinion - when he starts creating tables for Archive he finds just created tables in CurrentDS and thinks that they already exist (using wrong credentials).
This works OK on Postgres, what could it be about on Oracle?
<datasources>
<local-tx-datasource>
<jndi-name>CurrentDS</jndi-name>
<connection-url>jdbc:oracle:thin:#localhost:1521:XE</connection-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<user-name>current</user-name>
<password>password</password>
<metadata>
<type-mapping>Oracle9i</type-mapping>
</metadata>
</local-tx-datasource>
<local-tx-datasource>
<jndi-name>ArchiveDS</jndi-name>
<connection-url>jdbc:oracle:thin:#localhost:1521:XE</connection-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<user-name>archive</user-name>
<password>password</password>
<metadata>
<type-mapping>Oracle9i</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>
Related
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.
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.
We are using Jboss 4.2.3 with EJBs and hibernate.
Currently we defined 3 db connections in our persistence.xml file (one for reads (tx-local), one for writes (no-tx) and one for statistics (no-tx)), and when we add a forth db connection which is also (no-tx) and map a couple of entities to it, the machine starts to show an unusual load.
If we remove this connection (no one is using it still) the load get back to normal.
I guess it is some sort of configuration problem with JBoss, but I'm not sure.
any assistance will be appreciated.
thanks.
this is the ds.xml file content:
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: feedback-ds.xml 71535 2008-04-01 07:05:03Z adrian#jboss.org $ -->
<!-- Datasource config for MySQL using 3.0.9 available from:
http://www.mysql.com/downloads/api-jdbc-stable.html
-->
<datasources>
<no-tx-datasource>
<jndi-name>FeedbackDS</jndi-name>
<connection-url>jdbc:mysql://m6sdb:3306/m6sFeedbacks?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>root</user-name>
<password>password</password>
<min-pool-size>10</min-pool-size>
<!-- The maximum connections in a pool/sub-pool -->
<max-pool-size>1000</max-pool-size>
<property name="hibernate.show.sql" value="true"></property>
<idle-timeout-minutes>10</idle-timeout-minutes>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
<!-- should only be used on drivers after 3.22.1 with "ping" support -->
<valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-class-name>
<metadata>
<type-mapping>mySQL</type-mapping>
</metadata>
</no-tx-datasource>
</datasources>
I have been looking at several examples for configuring a datasource for MySQL in Jboss 7. All references i have seen for the element looks like this:
<driver name="com.mysql" module="com.mysql">
<driver-class>com.mysql.jdbc.Driver</driver-class>
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
</driver>
I know what the <driver-class> is but what exactly is the <xa-datasource-class> what is its purpose?
When i configured a datasource on Tomcat before i did not need to specify the xa-datasource for any database. Why is it different here?
Thanks
According to jdbc 4.0 specification (12.2): XA datasources produces XA connections capable to be used in global/distributed transactions. You might need such a connection if you need a transaction to span more than one database or a JMS calls. You can find a clear explanation of the concept here: http://www.theserverside.com/discussions/thread.tss?thread_id=21385#95346
If you don't have such a distributed transactions scenario you don't need to specify a xa-datasource, a simple datasource configuration is enough. So, if you use a simple datasource there is no need to specify a xa-datasource-class when you declare your driver.
<datasources>
<datasource jndi-name="java:/myDatasource" pool-name="MyDS" enabled="true" jta="true" use-java-context="true" use-ccm="true">
<connection-url>
jdbc:mysql://localhost:3306/mydb
</connection-url>
<driver>
mysql
</driver>
<transaction-isolation>
TRANSACTION_READ_COMMITTED
</transaction-isolation>
<pool>
<min-pool-size>
5
</min-pool-size>
<max-pool-size>
10
</max-pool-size>
<prefill>
true
</prefill>
<use-strict-min>
false
</use-strict-min>
<flush-strategy>
FailingConnectionOnly
</flush-strategy>
</pool>
<security>
<user-name>
username
</user-name>
<password>
password
</password>
</security>
</datasource>
<drivers>
<driver name="mysql" module="com.mysql"/>
</drivers>
</datasources>