aspose file tools
The moose likes JBoss/WildFly and the fly likes MYSQL or JNDI ?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "MYSQL or JNDI ??" Watch "MYSQL or JNDI ??" New topic


Nitin Dubey
Ranch Hand

Joined: Oct 30, 2000
Posts: 126

Hello friends,
I am new to JBOSS environment. I have put all my efforts trying to configure MYSQL4.x with JBOSS 3.x. I can very well get my ejb's from the Naming Server but when I try to get any other object such as String, Datasource objects I get a exception javax.naming.NameNotFoundException.
According to me there are two possibilities :
1. Problem with JNDI : Can be. But I can get my ejbs back from JNDI. But not Datasource or any other say String object.
2. Problem with MYSQL Configuration : - no comments -

When I cut and paste the mysql-service.xml file I get the message :
JBOSS Console :
14:09:45,312 INFO [MainDeployer] Starting deployment of package: file:/E:/jboss/jboss-tomcat/server/default/deploy/mysql-service.xml
14:09:45,328 INFO [JBossManagedConnectionPool] Creating
14:09:45,328 INFO [JBossManagedConnectionPool] Created
14:09:45,328 INFO [LocalTxConnectionManager] Creating
14:09:45,328 INFO [LocalTxConnectionManager] Created
14:09:45,328 INFO [JBossManagedConnectionPool] Starting
14:09:45,328 INFO [JBossManagedConnectionPool] Started
14:09:45,343 INFO [LocalTxConnectionManager] Starting
14:09:45,359 INFO [MySqlDS] Bound connection factory for resource adapter 'JBoss LocalTransaction JDBC Wrapper' to JNDI name 'java:/MySqlDS'
14:09:45,359 INFO [LocalTxConnectionManager] Started
14:09:45,359 INFO [MainDeployer] Deployed package: file:/E:/jboss/jboss-tomcat/server/default/deploy/mysql-service.xml
Client Code :
HashtablehashTable= new Hashtable();
hashTable.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
Context context= new InitialContext(hashTable);
DataSource dataSource= (DataSource) context.lookup("java:/MySqlDS");
<!-- Testing for MYSQL Database Starts here -->
<application-policy name = "MySQLDbRealm">
<login-module code = "" flag = "required">
<module-option name = "principal">root</module-option>
<module-option name = "userName">root</module-option>
<module-option name = "password"></module-option>
<module-option name = "managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=MySqlDS</module-option>
<!-- Testing for MYSQL Database Ends here -->
<?xml version="1.0" encoding="UTF-8"?>
<!-- ===================================================================== -->
<!-- -->
<!-- JBoss Server Configuration -->
<!-- -->
<!-- ===================================================================== -->
<!-- ==================================================================== -->
<!-- New ConnectionManager setup for mysql using 2.0.11 driver -->
<!-- Build jmx-api (build/ all) and view for config documentation -->
<!-- ==================================================================== -->
<mbean code="org.jboss.resource.connectionmanager.LocalTxConnectionManager" name="jboss.jca:service=LocalTxCM,name=MySqlDS">

<!-- Include a login module configuration named MySqlDbRealm.
Update your login-conf.xml, here is an example for a
<application-policy name = "MySqlDbRealm">
<login-module code = "" flag = "required">
<module-option name = "principal">yourprincipal</module-option>
<module-option name = "userName">yourusername</module-option>
<module-option name = "password">yourpassword</module-option>
<module-option name = "managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=MySqlDS</module-option>
NOTE: the application-policy name attribute must match SecurityDomainJndiName, and the
module-option name = "managedConnectionFactoryName"
must match the object name of the ConnectionManager you are configuring here.

<!--uncomment out this line if you are using the MySqlDbRealm above -->
<attribute name="SecurityDomainJndiName">MySqlDbRealm</attribute>
<depends optional-attribute-name="ManagedConnectionFactoryName">
<!--embedded mbean-->
<mbean code="org.jboss.resource.connectionmanager.RARDeployment" name="jboss.jca:service=LocalTxDS,name=MySqlDS">
<attribute name="JndiName">MySqlDS</attribute>
<attribute name="ManagedConnectionFactoryProperties">
<config-property name="ConnectionURL" type="java.lang.String">jdbc:mysql://happy:3306/test</config-property>
<config-property name="DriverClass" type="java.lang.String"></config-property>
<!--set these only if you want only default logins, not through JAAS -->
<config-property name="UserName" type="java.lang.String">root</config-property>
<config-property name="Password" type="java.lang.String"></config-property>
<!--Below here are advanced properties -->
<depends optional-attribute-name="OldRarDeployment">jboss.jca:service=RARDeployment,name=JBoss LocalTransaction JDBC Wrapper</depends>
<depends optional-attribute-name="ManagedConnectionPool">
<!--embedded mbean-->
<mbean code="org.jboss.resource.connectionmanager.JBossManagedConnectionPool" name="jboss.jca:service=LocalTxPool,name=MySqlDS">
<attribute name="MinSize">0</attribute>
<attribute name="MaxSize">50</attribute>
<attribute name="BlockingTimeoutMillis">5000</attribute>
<attribute name="IdleTimeoutMinutes">15</attribute>
<!--criteria indicates if Subject (from security domain) or app supplied
parameters (such as from getConnection(user, pw)) are used to distinguish
connections in the pool. Choices are
ByContainerAndApplication (use both),
ByContainer (use Subject),
ByApplication (use app supplied params only),
ByNothing (all connections are equivalent, usually if adapter supports
<attribute name="Criteria">ByContainer</attribute>
<depends optional-attribute-name="CachedConnectionManager">jboss.jca:service=CachedConnectionManager</depends>
<depends optional-attribute-name="JaasSecurityManagerService"></depends>
<attribute name="TransactionManager">java:/TransactionManager</attribute>
<!--make the rar deploy! hack till better deployment-->
Andres Gonzalez
Ranch Hand

Joined: Nov 27, 2001
Posts: 1561
But not Datasource or any other say String object.
Have you tried using the JMX console to see which objects have been bound?

I'm not going to be a Rock Star. I'm going to be a LEGEND! --Freddie Mercury
Nitin Dubey
Ranch Hand

Joined: Oct 30, 2000
Posts: 126

How do I open the JMX console ??
I am using JBoss 3.x
I agree. Here's the link:
subject: MYSQL or JNDI ??