Datasource binding problem MS SQL 2K
vkhattar Aug 27, 2003 4:17 AMI'm frustrated now...
I had JBoss 3.2.1 and was using *-ds.xml files. When I wasnt able to get Datasource working on 3.2.1, I switched to 3.0.2 and tried *-service.xml files.
Though with 3.0.2 and *-service.xml files, I was able to see the following lines at http://localhost:8080/jmx-console/index.jsp :
name=msSQLDS,service=LocalTxCM
name=msSQLDS,service=LocalTxDS
name=msSQLDS,service=LocalTxPool
These lines, according to me , indicates that my DataSource named 'msSQLDS' has been registered. But unfortunately I'm not being able to get datasource from my EJB (BMP) by saying :
javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup("java:comp/msSQLDS");
I have also tried using "java:msSQLDS" and "java:env/msSQLDS".
Also , I tried :
Enumeration enum = ctx.list("/");
while (enum.hasMoreElements())
System.out.println(" -- " + enum.nextElement() );
which prints all other namings except msSQLDS (though it is getting printed in jmx-console) :
14:30:09,655 INFO [STDOUT] -- UIL2XAConnectionFactory: org.jboss.mq.SpyXAConn
ctionFactory
14:30:09,655 INFO [STDOUT] -- topic: org.jnp.interfaces.NamingContext
14:30:09,655 INFO [STDOUT] -- jmx:vkhattar:rmi: org.jboss.jmx.adaptor.rmi.RMI
daptorImpl
14:30:09,655 INFO [STDOUT] -- queue: org.jnp.interfaces.NamingContext
14:30:09,655 INFO [STDOUT] -- ConnectionFactory: org.jboss.mq.SpyConnectionFa
tory
14:30:09,655 INFO [STDOUT] -- RMIConnectionFactory: org.jboss.mq.SpyConnectio
Factory
14:30:09,655 INFO [STDOUT] -- UserTransaction: org.jboss.tm.usertx.client.Cli
ntUserTransaction
14:30:09,655 INFO [STDOUT] -- ejb: org.jnp.interfaces.NamingContext
14:30:09,655 INFO [STDOUT] -- invokers: org.jnp.interfaces.NamingContext
14:30:09,655 INFO [STDOUT] -- jmx: org.jnp.interfaces.NamingContext
14:30:09,655 INFO [STDOUT] -- UILXAConnectionFactory: org.jboss.mq.SpyXAConne
tionFactory
14:30:09,655 INFO [STDOUT] -- AccountBean: $Proxy30
14:30:09,655 INFO [STDOUT] -- UILConnectionFactory: org.jboss.mq.SpyConnectionFactory
I'm posting relevant code here, pls. try helping...
ejb-jar.xml
<?xml version = '1.0' encoding = 'windows-1252'?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
<enterprise-beans>
Entity Bean ( BMP )
<display-name>AccountBean</display-name>
<ejb-name>AccountBean</ejb-name>
encompass.interfaces.AccountHome
encompass.interfaces.Account
<ejb-class>encompass.ejb.AccountBean</ejb-class>
<persistence-type>Bean</persistence-type>
<prim-key-class>encompass.ejb.AccountPK</prim-key-class>
False
<resource-ref>
<res-ref-name>msSQLDS</res-ref-name>
<jndi-name>msSQLDS</jndi-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</enterprise-beans>
</ejb-jar>
jboss.xml
<?xml version = '1.0' encoding = 'windows-1252'?>
<enterprise-beans>
<ejb-name>AccountBean</ejb-name>
<resource-ref>
<res-ref-name>msSQLDS</res-ref-name>
<resource-name>AccountDBResource</resource-name>
</resource-ref>
<resource-managers>
<resource-manager>
<res-name>AccountDBResource</res-name>
<res-jndi-name>msSQLDS</res-jndi-name>
</resource-manager>
</resource-managers>
</enterprise-beans>
mssqldb-service.xml
<?xml version="1.0" encoding="UTF-8"?>
<depends optional-attribute-name="ManagedConnectionFactoryName">
<!--embedded mbean-->
msSQLDS
<config-property name="ConnectionURL" type="java.lang.String">jdbc:JSQLConnect://localhost:1433/databaseName=BankAccount</config-property>
<config-property name="DriverClass" type="java.lang.String">com.jnetdirect.jsql.JSQLDriver</config-property>
<config-property name="UserName" type="java.lang.String">sa</config-property>
<config-property name="Password" type="java.lang.String">sa</config-property>
<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
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
login-config.xml
<application-policy name = "msSQLDS">
<login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule" flag = "required">
<module-option name = "principal">sa</module-option>
<module-option name = "userName">sa</module-option>
<module-option name = "password">sa</module-option>
<module-option name = "managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=msSQLDS</module-option>
</login-module>
</application-policy>
EJB (BMP)
Context ctx = new InitialContext(System.getProperties());
javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup("java:msSQLDS");
Pls. advise if I hv made anything wrong or if some additional step needs to be taken.
I must mention that on JBoss startup, I'm also getting following exceptions :1.
element; - nested throwable: (java.lang.IllegalAccessException: Class java.lang.reflect.Method can not access a member of class org.jboss.resource.RARMetaData wi
th modifiers "private"))
at org.jboss.resource.RARDeployer.init(RARDeployer.java:148)
at org.jboss.deployment.MainDeployer.init(MainDeployer.java:679)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:615)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:591)
at sun.reflect.GeneratedMethodAccessor11.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
2.
15:00:28,472 ERROR [URLDeploymentScanner] MBeanException: Exception in MBean ope
ration 'checkIncompleteDeployments()'
Cause: Incomplete Deployment listing:
Packages waiting for a deployer:
Incompletely deployed packages:
[org.jboss.deployment.DeploymentInfo@dc5d0b9a { url=file:/D:/JBoss3/server/defau
lt/deploy/jboss-local-jdbc.rar }
deployer: org.jboss.resource.RARDeployer@88
status: null
state: FAILED
watch: file:/D:/JBoss3/server/default/deploy/jboss-local-jdbc.rar
lastDeployed: 1061976625206
lastModified: 1061976625159
mbeans:
, org.jboss.deployment.DeploymentInfo@eab91e62 { url=file:/D:/JBoss3/server/defa
ult/deploy/jboss-xa-jdbc.rar }
deployer: org.jboss.resource.RARDeployer@88
status: null
state: FAILED
watch: file:/D:/JBoss3/server/default/deploy/jboss-xa-jdbc.rar
, org.jboss.deployment.DeploymentInfo@d7100093 { url=file:/D:/JBoss3/server/defa
ult/deploy/jms-ra.rar }
deployer: org.jboss.resource.RARDeployer@88
status: null
state: FAILED
watch: file:/D:/JBoss3/server/default/deploy/jms-ra.rar
lastDeployed: 1061976625425
lastModified: 1061976625409
Depends On Me: , ObjectName: jboss.jca:service=XaTxDS,name=jmsra
state: CONFIGURED
I Depend On: jboss.jca:service=RARDeployment,name=JMS Adapter
Depends On Me: jboss.jca:service=XaTxCM,name=jmsra
, ObjectName: jboss.jca:service=LocalTxCM,name=msSQLDS
state: CONFIGURED
I Depend On: jboss.jca:service=LocalTxDS,name=msSQLDS
jboss.jca:service=LocalTxPool,name=msSQLDS
jboss.jca:service=CachedConnectionManager
jboss.security:service=JaasSecurityManager
jboss.jca:service=RARDeployer
Depends On Me: , ObjectName: jboss.jca:service=LocalTxDS,name=msSQLDS
state: CONFIGURED
I Depend On: jboss.jca:service=RARDeployment,name=JBoss LocalTransaction JDBC
Wrapper
jboss:service=Hypersonic
Depends On Me: jboss.jca:service=LocalTxCM,name=msSQLDS
]
15:00:28,472 INFO [URLDeploymentScanner] Started
15:00:28,472 INFO [MainDeployer] Deployed package: file:/D:/JBoss3/server/defau
lt/conf/jboss-service.xml
--------------------