I used the rooms example by Terry Child combined with the template example from the
src
distribution to try to get Castor working with MSSQL and Jboss-3.0.3.
The rooms example was for 2.x so I modified it as best I could. The problem I am having
is that I am getting a null _jdo object back from the jndi lookup. any help would be
greatly appreciated.
**************************************************************************************************
************ The Problem ****
**************************************************************************************************
The problem is that things look like they are bound correctly,
but I get a null object back from the call to:
_jdo = (DataObjects) compEnv.lookup("jdo/modelJDO"); in CastorHelper()
*************************************************************************************************
****************************************************************************************
Cleint code from CastorHelper:
****************************************************************************************
import org.exolab.castor.jdo.DataObjects;
public class CastorHelper implements java.io.Serializable {
public DataObjects _jdo;
public CastorHelper() {
Context compEnv = (Context) iniCtx.lookup("java:comp/env");
_jdo = (DataObjects) compEnv.lookup("jdo/modelJDO");
if (_jdo = =null) {
//********************** here is the problem ************************
//_jdo is null even though I did not get any Naming exceptions or
//any other kind of exceptions
//****************************************************************
}
}
}
****************************************************************************************
******** Here are the XDoclet entries that are in the ModelServiceBean ejb class ******
****************************************************************************************
* @ejb:resource-ref res-name="jdo/modelJDO"
* res-type="org.exolab.castor.jdo.DataObjects"
* res-auth="Container"
*
* @jboss:resource-ref res-ref-name="jdo/modelJDO"
* resource-name="CastorModelJDO"
*
* @jboss:resource-manager res-man-class="org.jboss.ejb.deployment.CastorJDOResource"
* res-man-name="CastorModelJDO"
* res-man-jndi-name="java:/castorModel"
*
* @jboss:resource-manager res-man-class="org.jboss.ejb.deployment.JDBCResource"
* res-man-name="jdbc/castorJDBCModel"
* res-man-jndi-name="java:/jdbc/castorJDBCModel"
****************************************************************************************
********** ejb-jar.xml resulting from the above XDoclet tags.
****************************************************************************************
- <session>
- <description>
- <![CDATA[ Provides services related to the administration of Models ModelServiceBean
Session Bean ATTENTION: Some of the XDoclet tags are hidden from XDoclet by adding a
"--" between @ and the namespace.
]]>
</description>
<display-name>Model Service Bean</display-name>
<ejb-name>test/ModelService</ejb-name>
<home>com.myco.ejb.interfaces.ModelServiceHome</home>
<remote>com.myco.ejb.interfaces.ModelService</remote>
<ejb-class>com.myco.ejb.session.ModelServiceBean</ejb-class>
<session-type>Stateful</session-type>
<transaction-type>Container</transaction-type>
- <resource-ref>
<res-ref-name>jdo/modelJDO</res-ref-name>
<res-type>org.exolab.castor.jdo.DataObjects</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</session>
****************************************************************************************
********** jboss.xml resulting from the above XDoclet tags.
****************************************************************************************
- <jboss>
- <enterprise-beans>
- <session>
<ejb-name>test/ModelService</ejb-name>
<jndi-name>ejb/test/ModelService</jndi-name>
- <resource-ref>
<res-ref-name>jdo/modelJDO</res-ref-name>
<resource-name>CastorModelJDO</resource-name>
</resource-ref>
</session>
</enterprise-beans>
- <resource-managers>
- <resource-manager res-class="org.jboss.ejb.deployment.CastorJDOResource">
<res-name>CastorModelJDO</res-name>
<res-jndi-name>java:/castorModel</res-jndi-name>
</resource-manager>
- <resource-manager res-class="org.jboss.ejb.deployment.JDBCResource">
<res-name>jdbc/castorJDBCModel</res-name>
<res-jndi-name>java:/jdbc/castorJDBCModel</res-jndi-name>
</resource-manager>
</resource-managers>
</jboss>
****************************************************************************************
********** mssql-xa-service.xml for establishing a DBConnection Pool with the Castor
MBean at the end
****************************************************************************************
<mbean code="org.jboss.resource.connectionmanager.XATxConnectionManager"
name="jboss.jca:service=XATxCM,name=MSSQLXaDS">
<!-- For optional container managed security, include a login module
configuration named MSSQLXaDbRealm in conf/login-conf.xml.
Here is an example login module configuration for a
ConfiguredIdentityLoginModule:
<application-policy name = "MSSQLXaDbRealm">
<authentication>
<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=XATxCM,name=MSSQLXaDS</module-option>
</login-module>
</authentication>
</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 this line if you are using the MSSQLXaDbRealm above
<attribute name="SecurityDomainJndiName">MSSQLXaDbRealm</attribute>
-->
<depends optional-attribute-name="ManagedConnectionFactoryName">
<!--embedded mbean-->
<mbean code="org.jboss.resource.connectionmanager.RARDeployment"
name="jboss.jca:service=XATxDS,name=MSSQLXaDS">
<attribute name="JndiName">MSSQLXaDS</attribute>
<!--real attributes-->
<attribute name="ManagedConnectionFactoryProperties">
<properties>
<config-property name="XADataSourceProperties"
type="java.lang.String">ServerName=localhost;DatabaseName=testDB;SelectMethod=cursor</config-property>
<config-property name="XADataSourceClass"
type="java.lang.String">com.microsoft.jdbcx.sqlserver.SQLServerDataSource</config-property>
</properties>
</attribute>
<!--hack-->
<depends
optional-attribute-name="OldRarDeployment">jboss.jca:service=RARDeployment,name=Minerva
JDBC XATransaction ResourceAdapter</depends>
</mbean>
</depends>
<depends optional-attribute-name="ManagedConnectionPool">
<!--embedded mbean-->
<mbean code="org.jboss.resource.connectionmanager.JBossManagedConnectionPool"
name="jboss.jca:service=XATxPool,name=MSSQLXaDS">
<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
reauthentication)-->
<attribute name="Criteria">ByContainer</attribute>
</mbean>
</depends>
<depends
optional-attribute-name="CachedConnectionManager">jboss.jca:service=CachedConnectionManager</depends>
<depends
optional-attribute-name="JaasSecurityManagerService">jboss.security:service=JaasSecurityManager</depends>
<attribute name="TransactionManager">java:/TransactionManager</attribute>
<!--make the rar deploy! hack till better deployment-->
<depends>jboss.jca:service=RARDeployer</depends>
</mbean>
<mbean code="org.jboss.jdo.castor.CastorJDOImpl" name="jboss:service=CastorJDO">
<attribute name="Configuration">file:../server/sms3/conf/database.xml</attribute>
<attribute name="JndiName">java:/castorModel</attribute>
<attribute name="LockTimeout">10000</attribute>
<attribute name="LoggingEnabled">true</attribute>
<attribute name="CommonClassPath">false</attribute>
<attribute name="AutoStore">false</attribute>
</mbean>
****************************************************************************************
********** database.xml specified in the MBean above references the MSSQLXaDS bound
above
****************************************************************************************
<database name="mssql" engine="sql-server" >
<jndi name="java:/MSSQLXaDS"/>
<mapping href="mapping.xml" />
</database>
****************************************************************************************
********** jndi bindings printed at runtime before
********** I invoke _jdo = (DataObjects) compEnv.lookup("jdo/modelJDO"); in
CastorHelper()
****************************************************************************************
15:35:38,307 INFO [STDOUT] CastorHelper(): binding for: java
15:35:38,307 INFO [STDOUT] MSSQLXaDS:
org.jboss.resource.adapter.jdbc.JDBCDataSource:Reference Class Name:
org.jboss.resource.adapter.jdbc.JDBCDataSource
15:35:38,307 INFO [STDOUT] CastorHelper(): name: MSSQLXaDS
15:35:38,307 INFO [STDOUT] CastorHelper(): object: Reference Class Name:
org.jboss.resource.adapter.jdbc.JDBCDataSource