JNDI-Name of DataSource
tdang Jul 16, 2002 12:53 PMHi!
I am using JBoss 3.0.
<?xml version="1.0" encoding="UTF-8"?>
<!-- ==================================================================== -->
<!-- ConnectionManager setup for default IBM DB2 -->
<!-- Build jmx-api (build/build.sh all) and view for config documentation -->
<!-- ==================================================================== -->
<!-- Include a login module configuration named DB2DbRealm.
Update your login-conf.xml, here is an example for a
ConfiguredIdentityLoginModule:
<application-policy name = "DB2DbRealm">
<login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule" 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=DB2DS</module-option>
</login-module>
</application-policy>
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 DB2DbRealm above
DB2DbRealm
-->
<depends optional-attribute-name="ManagedConnectionFactoryName">
<!--embedded mbean-->
Sales
<config-property name="ConnectionURL" type="java.lang.String">jdbc:db2:salesDB</config-property>
<config-property name="DriverClass" type="java.lang.String">COM.ibm.db2.jdbc.app.DB2Driver</config-property>
<!--set these only if you want only default logins, not through JAAS -->
<config-property name="UserName" type="java.lang.String"></config-property>
<config-property name="Password" type="java.lang.String"></config-property>
<!--Below here are advanced properties -->
<!--hack-->
<depends optional-attribute-name="OldRarDeployment">jboss.jca:service=RARDeployment,name=JBoss LocalTransaction JDBC Wrapper
<depends optional-attribute-name="ManagedConnectionPool">
<!--embedded mbean-->
0
50
5000
15
<!--
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
reauthentication)-->
ByContainer
<depends optional-attribute-name="CachedConnectionManager">jboss.jca:service=CachedConnectionManager
<!-- <depends optional-attribute-name="JaasSecurityManagerService">jboss.security:service=JaasSecurityManager -->
java:/TransactionManager
<!--make the rar deploy! hack till better deployment-->
jboss.jca:service=RARDeployer
-----------------------------------------------------
I have configured my datasource in the above kursvs-service.xml file. I copied it to %JBOSS_INST%\server\default\deploy.
In the server.log file there are the following lines:
2002-07-16 17:31:13,484 DEBUG [org.jboss.deployment.MainDeployer] create step for deployment file:/C:/Programme/jboss 3.0/server/default/deploy/kursvs-service.xml
2002-07-16 17:31:13,484 DEBUG [org.jboss.deployment.SARDeployer] Deploying SAR, create step: url file:/C:/Programme/jboss 3.0/server/default/deploy/kursvs-service.xml
2002-07-16 17:31:13,484 DEBUG [org.jboss.system.ServiceCreator] About to create bean: jboss.jca:service=LocalTxCM,name=DB2DS
2002-07-16 17:31:13,484 DEBUG [org.jboss.system.ServiceCreator] code: org.jboss.resource.connectionmanager.LocalTxConnectionManager
...
2002-07-16 17:31:13,531 DEBUG [org.jboss.system.ServiceConfigurator] JndiName set to Sales in jboss.jca:service=LocalTxDS,name=DB2DS
...
2002-07-16 17:31:13,609 WARN [org.jboss.system.ServiceController] jboss.jca:service=LocalTxDS,name=DB2DS does not implement any Service methods
...
2002-07-16 17:31:13,609 DEBUG [org.jboss.deployment.SARDeployer] Deploying SAR, start step: url file:/C:/Programme/jboss 3.0/server/default/deploy/kursvs-service.xml
2002-07-16 17:31:13,609 DEBUG [org.jboss.system.ServiceController] waiting in start jboss.jca:service=LocalTxCM,name=DB2DS on jboss.jca:service=LocalTxDS,name=DB2DS
2002-07-16 17:31:13,609 DEBUG [org.jboss.system.ServiceController] waiting in start jboss.jca:service=LocalTxDS,name=DB2DS on jboss.jca:service=RARDeployment,name=JBoss LocalTransaction JDBC Wrapper
2002-07-16 17:31:13,609 INFO [org.jboss.resource.connectionmanager.JBossManagedConnectionPool] Starting
2002-07-16 17:31:13,625 INFO [org.jboss.resource.connectionmanager.JBossManagedConnectionPool] Started
2002-07-16 17:31:13,625 DEBUG [org.jboss.system.ServiceController] waiting in start jboss.jca:service=LocalTxCM,name=DB2DS on jboss.jca:service=LocalTxDS,name=DB2DS
2002-07-16 17:31:13,625 DEBUG [org.jboss.deployment.MainDeployer] Final (start) deployment step successfully completed on package: kursvs-service.xml
2002-07-16 17:31:13,625 INFO [org.jboss.deployment.MainDeployer] Successfully completed deployment of package: file:/C:/Programme/jboss 3.0/server/default/deploy/kursvs-service.xml
As you have seen, JBoss deployed the service correctly .
But when I look up in the jboss:service=JNDIView\java: Namespace, I did not find the jndi-name of the datasource. So when my client runs like this:
...
public class Client {
public static void main(String[] args) {
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
p.put(Context.PROVIDER_URL, "jnp://localhost:1099");
p.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
InitialContext ctx = new InitialContext(p);
DataSource ds = (DataSource) ctx.lookup("java:/Sales");
Connection con = ds.getConnection();
}
}
I got the exception the datasource was not found.
What is wrong with my service.xml file? What must I do?
Regards