jboss中使用cmr的问题

03-08-19 programboy
我在把一个项目从weblogic移植到jboss中时遇到了一个非常不理解的问题就是我在一个cmp中使用另一个cmp中的方法时,通过cmr字段映射总会抛出NullPointerException,但是这个使用在weblogic中非常正确

代码如下:

我在 User,UserBean 中都申明了getOrganization()

在UserBean中的一个方法使用

public UserModel getUserModel () throws RemoteException

{

_logger.debug("into the getUserModel .");

UserModel model = new UserModel ();

//_logger.debug("the id "+this.getId());

model.setId (this.getId ());

//_logger.debug("the login "+this.getLogin());

model.setLogin (this.getLogin ());

//_logger.debug("the UserName "+this.getUserName());

model.setUserName (this.getUserName ());

//_logger.debug("the Password "+this.getPassword());

model.setPassword (this.getPassword ());

//_logger.debug("the lastmodifiendate "+this.getLastModifiedDate());

model.setLastModifiedDate (this.getLastModifiedDate ());

//_logger.debug("the createdate "+this.getCreateDate());

model.setCreateDate (this.getCreateDate ());

//model.setStatus (this.getStatus ());

//_logger.debug("the Address "+this.getAddress());

model.setAddress (this.getAddress ());

//_logger.debug("the Usercode "+this.getUserCode());

model.setUserCode (this.getUserCode ());

//_logger.debug("the sex "+this.getSex());

model.setSex (this.getSex ());

//_logger.debug("the phone "+this.getPhone());

model.setPhone (this.getPhone ());

//_logger.debug("the workcardno "+this.getWorkCardNo());

model.setWorkCardNo (this.getWorkCardNo ());

//_logger.debug("the birthday "+this.getBirthday());

model.setBirthday (this.getBirthday ());

//_logger.debug("the email "+this.getEmail());

model.setEmail (this.getEmail ());

//_logger.debug("the cardid "+this.getCardId());

model.setCardId (this.getCardId ());

//_logger.debug("the dutycode "+this.getDutyCode());

model.setDutyCode (this.getDutyCode ()); //新加 职称

//_logger.debug("the knowledgecode "+this.getKnowledgeCode());

model.setKnowledgeCode (this.getKnowledgeCode ()); //新加 文化程度

//_logger.debug("the isvalid "+this.getIsValid());

model.setIsValid (this.getIsValid ()); //是否有效 (改为字符)

//_logger.debug("the organizationcode "+this.getOrganizationCode());

model.setOrganizationCode (this.getOrganizationCode ()); //税务机构代码

//_logger.debug("the checkworkno "+this.getCheckWorkNo());

model.setCheckWorkNo (this.getCheckWorkNo ()); //税务检查证号

//_logger.debug("the rightmodify "+this.getRightModify());

model.setRightModify (this.getRightModify ()); //权限修改

if(this.getOrganization()==null)

_logger.debug("the organization is null");

else

_logger.debug("get orgid"+this.getOrganization().getId());

if (this.getOrganization () != null) model.setOrgId (this.getOrganization ().getId ());

//model.setOrgId(new Integer(41));

return model;

}

在ejb-jar中是这样定义的

<ejb-relation>

<ejb-relation-name>organization-users</ejb-relation-name>

<ejb-relationship-role>

<ejb-relationship-role-name>

organization-has-users

</ejb-relationship-role-name>

<multiplicity>One</multiplicity>

<relationship-role-source>

<ejb-name>OrganizationEJB</ejb-name>

</relationship-role-source>

<cmr-field>

<cmr-field-name>users</cmr-field-name>

<cmr-field-type>java.util.Collection</cmr-field-type>

</cmr-field>

</ejb-relationship-role>

<ejb-relationship-role>

<ejb-relationship-role-name>

users-have-organization

</ejb-relationship-role-name>

<multiplicity>Many</multiplicity>

<relationship-role-source>

<ejb-name>UserEJB</ejb-name>

</relationship-role-source>

<cmr-field>

<cmr-field-name>organization</cmr-field-name>

</cmr-field>

</ejb-relationship-role>

</ejb-relation>

在jbosscmp-jdbc中的定义是

<ejb-relation>

<ejb-relation-name>organization-users</ejb-relation-name>

<foreign-key-mapping/>

<ejb-relationship-role>

<ejb-relationship-role-name>organization-has-users</ejb-relationship-role-name>

<fk-constraint>true</fk-constraint>

<key-fields>

<key-field>

<field-name>id</field-name>

<column-name>orgid</column-name>

</key-field>

</key-fields>

</ejb-relationship-role>

<ejb-relationship-role>

<ejb-relationship-role-name>users-have-organization</ejb-relationship-role-name>

<fk-constraint>true</fk-constraint>

<key-fields/>

</ejb-relationship-role>

</ejb-relation>

当我调用user中的getUserModel()时,到getOrganization()时就会抛null,不知道在这里有什么配置的问题,是不是在jboss中对ejb有什么特别的要求?

programboy
2003-08-19 22:26
重新写一下

在ejb-jar中是这样定义的

<ejb-relation>

<ejb-relation-name>organization-users</ejb-relation-name>

<ejb-relationship-role>

<ejb-relationship-role-name>

organization-has-users

</ejb-relationship-role-name>

<multiplicity>One</multiplicity>

<relationship-role-source>

<ejb-name>OrganizationEJB</ejb-name>

</relationship-role-source>

<cmr-field>

<cmr-field-name>users</cmr-field-name>

<cmr-field-type>java.util.Collection</cmr-field-type>

</cmr-field>

</ejb-relationship-role>

<ejb-relationship-role>

<ejb-relationship-role-name>

users-have-organization

</ejb-relationship-role-name>

<multiplicity>Many</multiplicity>

<relationship-role-source>

<ejb-name>UserEJB</ejb-name>

</relationship-role-source>

<cmr-field>

<cmr-field-name>organization</cmr-field-name>

</cmr-field>

</ejb-relationship-role>

</ejb-relation>

在jbosscmp-jdbc中的定义是

<ejb-relation>

<ejb-relation-name>organization-users</ejb-relation-name>

<foreign-key-mapping/>

<ejb-relationship-role>

<ejb-relationship-role-name>organization-has-users</ejb-relationship-role-name>

<fk-constraint>true</fk-constraint>

<key-fields>

<key-field>

<field-name>id</field-name>

<column-name>orgid</column-name>

</key-field>

</key-fields>

</ejb-relationship-role>

<ejb-relationship-role>

<ejb-relationship-role-name>users-have-organization</ejb-relationship-role-name>

<fk-constraint>true</fk-constraint>

<key-fields/>

</ejb-relationship-role>

</ejb-relation>

当我调用user中的getUserModel()时,到getOrganization()时就会抛null,不知道在这里有什么配置的问题,是不是在jboss中对ejb有什么特别的要求?

猜你喜欢