I have read chapter
3 and 7 of the documentation and unfortunately still can't retrieve the
datasource from JBoss naming server . I have an feeling that my
configuration is probably not setup correctly. My simple BMP bean
attempts to retrieve the datasource using the following code
but a javax.naming.NameNotFoundException exception is thrown stating
that MSSQL2000DS is not bound. I am using the sample mssql-service.xml
which I made the corresponding changes to reflect my system. Reading
previous messages I also notice that an issues of where to place these files
exists therefore I place copies in both the deploy and conf directories. Thanks
for any help..
Chris
Perren
Context ctx = new
InitialContext();
javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup("java:comp/env/jdbc/ejbPool");
javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup("java:comp/env/jdbc/ejbPool");
The ejb-jar.xml
consists of
<ejb-jar>
<enterprise-beans>
<entity>
<ejb-name>Account</ejb-name>
<home>examples.AccountHome</home>
<remote>examples.Account</remote>
<local-home>examples.AccountLocalHome</local-home>
<local>examples.AccountLocal</local>
<ejb-class>examples.AccountBean</ejb-class>
<persistence-type>Bean</persistence-type>
<prim-key-class>examples.AccountPK</prim-key-class>
<reentrant>False</reentrant>
<enterprise-beans>
<entity>
<ejb-name>Account</ejb-name>
<home>examples.AccountHome</home>
<remote>examples.Account</remote>
<local-home>examples.AccountLocalHome</local-home>
<local>examples.AccountLocal</local>
<ejb-class>examples.AccountBean</ejb-class>
<persistence-type>Bean</persistence-type>
<prim-key-class>examples.AccountPK</prim-key-class>
<reentrant>False</reentrant>
<resource-ref>
<res-ref-name>jdbc/ejbPool</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</entity>
</enterprise-beans>
<res-ref-name>jdbc/ejbPool</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</entity>
</enterprise-beans>
....
....
The jboss.xml
consist of
<?xml
version="1.0" encoding="UTF-8"?>
<jboss>
<enterprise-beans>
<entity>
<ejb-name>Account</ejb-name>
<jndi-name>AccountHome</jndi-name>
<local-jndi-name>AccountLocalHome</local-jndi-name>
<resource-ref>
<res-ref-name>jdbc/ejbPool</res-ref-name>
<jndi-name>java:/MSSQL2000DS</jndi-name>
</resource-ref>
</entity>
</enterprise-beans>
</jboss>
<jboss>
<enterprise-beans>
<entity>
<ejb-name>Account</ejb-name>
<jndi-name>AccountHome</jndi-name>
<local-jndi-name>AccountLocalHome</local-jndi-name>
<resource-ref>
<res-ref-name>jdbc/ejbPool</res-ref-name>
<jndi-name>java:/MSSQL2000DS</jndi-name>
</resource-ref>
</entity>
</enterprise-beans>
</jboss>
The
mssql-service.xml file ...
<server><mbean
code="org.jboss.resource.ConnectionFactoryLoader"
name="jboss.jca:service=ConnectionFactoryLoader,name=MSSQL2000DS">
<attribute
name="ManagedConnectionFactoryProperties">
ConnectionURL=jdbc:AvenirDriver://localhost:1433/MasteringEJB;uid=sa;pwd=sa
DriverClass=net.avenir.jdbc2.Driver
</attribute>
<attribute
name="JndiName">MSSQL2000DS</attribute>
<attribute
name="TransactionManagerName">java:/TransactionManager</attribute>
<depends
optional-attribute-name="ResourceAdapterName">jboss.jca:service=RARDeployment,name=Minerva
JDBC LocalTransaction ResourceAdapter</depends>
<depends
optional-attribute-name="ConnectionManagerFactoryLoaderName">jboss.jca:service=ConnectionManagerFactoryLoader,name=MinervaSharedLocalCMFactory</depends>
<attribute name="ConnectionManagerProperties">#
#Wed Aug 15 16:17:29 EDT 2001
BlockingTimeoutMillis=50000
IdleTimeoutMinutes=30
MaxSize=10
CleanupIntervalMinutes=10
MinSize=0
MaxIdleTimeoutPercent=1.0
</attribute>
<attribute name="PrincipalMappingClass">
org.jboss.resource.security.ManyToOnePrincipalMapping
</attribute>
<attribute
name="PrincipalMappingProperties">userName=sa
password=sa</attribute>
</mbean>
</server>
