From: Andy V. (JIRA) <no...@at...> - 2006-05-17 13:25:11
|
ClassCastException caused by improper casting of property value during place holder resolving of system properties. ------------------------------------------------------------------------------------------------------------------- Key: HHH-1762 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1762 Project: Hibernate3 Type: Bug Components: core Versions: 3.1.3 Environment: WebSphere 5.1, Oracle 8.1.7.1.4, Windows Server 2003 Reporter: Andy Verberne Priority: Minor During the initialization of Hibernate the method "org.hibernate.cfg.Configuration.buildSessionFactory()" calls the following method where the properties parameter contains all JVM system properties: public static void org.hibernate.util.PropertiesHelper.resolvePlaceHolders(Properties properties) { Iterator itr = properties.entrySet().iterator(); while ( itr.hasNext() ) { final Map.Entry entry = ( Map.Entry ) itr.next(); final String value = ( String ) entry.getValue(); if ( value != null ) { final String resolved = resolvePlaceHolder( value ); if ( !value.equals( resolved ) ) { if ( resolved == null ) { itr.remove(); } else { entry.setValue( resolved ); } } } } } This will cause a ClassCastException in the statement "(String)entry.getValue(); " when the following system property exists: soapconn.JMSListener={SOAPConnMQGateway$Listener:FF#001=com.ing.jms.listener.JMSListener@773a20f5, SOAPConnMQGateway$Listener:RR#001=com.ing.jms.listener.JMSListener@5d0060ff} For this property the entry.getValue() will not return a String object but a java.util.HashMap instead. Possible fixes: 1) replace "( String ) entry.getValue();" with entry.getValue().toString(); 2) Check the class type returned by entry.getValue() and only cast when it is a String. However, the fact that all system properties are resolved for placeholders is probably not a good design. Only the Hibernate properties should be resolved. System properties not belonging to Hibernate should not be read at all. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |