[ http://jira.jboss.com/jira/browse/JBAS-1269?page=comments#action_12314533 ] Michael Lipp commented on JBAS-1269: ------------------------------------
This is easy: as far as the application server is concerned, the list is empty. I think the application server must never call toString on an EJB -- simply because the contract between the EJB container and the EJB developer (as defined in the specification) does not define any restrictions for the developer about what he can may do in toString. As there are no restrictions, he can do anything he likes. On the other hand side, there is no reason for the EJB container to assume that it may call toString -- in any context --, simply because the contract does not specify that toString must be callable (and as I mentioned before: what good is calling toString for the EJB container anyway: the result is controlled by the EJB developer and thus from the EJB container's point of view unspecified). There was a simalar issue in some JBoss version one or two years ago. My EJB caused problems because it overrode "equals" and "hashCode" (not the EJB as such, but the base class of my EJB which was a POJO). JBoss, at that time, used the instantiated EJBs as keys for lookup in a HashMap. This was absolutely fatal because JBoss assumed the default behaviour of Java object, i.e. no two objects are equal unless the are the same instance, while in my case different EJBs could be equal from a business point of view (and lucky for me, my patch was accepted, because I could not avoid the re-definition of "equals" and "hashCode"). I see a simalarity here because "toString" is, just like "equals" and "hashCode", a method defined for "Object". So the EJB container can of course assume that they are implemented and can call them. But as they may be overridden in an EJB (nothing in the EJB specification prevents me from doing this) the EJB container may not make any assumption about the results or even the callability of these methods. > toString called on EJB > ---------------------- > > Key: JBAS-1269 > URL: http://jira.jboss.com/jira/browse/JBAS-1269 > Project: JBoss Application Server > Type: Bug > Components: EJBs > Versions: JBossAS-4.0.1 Final > Environment: Linux, J2SE 1.4.2_06 > Reporter: Michael Lipp > Assignee: Scott M Stark > Priority: Critical > > > org.jboss.resource.connectionmanager.CachedConnectionManager calls toString() > on EJBs (e.g. line 250, where "rawKey" is an EJB. > The "toString()" method of an EJB may, however, be overwritten, as is > appropriate for the type of EJB. Such a toString() method may use > getPrimaryKey() as it will usually be called from the business methods, i.e. > from a context where this call is legal. > CachedConnectionManager calls toString() during create, i.e. in a context > where the call to getPrimaryKey is illegal, which results in an > IllegalStateException. In order to avoid this kind of problem, the > application server should never call toString() on EJBs. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa - If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira ------------------------------------------------------- The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt _______________________________________________ JBoss-Development mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jboss-development
