Announcement Announcement Module
Collapse
No announcement yet.
Hot deployment in WAS4.0 failing with TypeMismatchException Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hot deployment in WAS4.0 failing with TypeMismatchException

    I'm wondering whether anyone has had any joy with hot deployment with WAS4.0. When deploying a new JAR into a running application, the application context (re-)initialisation fails when trying to create the data source bean. We retrieve our data source from JNDI, and a TypeMismatchException is thrown, saying that it fails to convert the JndiObjectFactoryBean into a DataSource.

    Here is the relevant part of my applicationContext.xml file:
    Code:
    	<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    		<property name="location"><value>/WEB-INF/db.properties</value></property>
    	</bean>
    
    	<bean id="targetDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    		<property name="jndiName"><value>${db.jndiname}</value></property>
    	</bean>
    
    	<bean id="dataSource" class="org.springframework.jdbc.datasource.UserCredentialsDataSourceAdapter">
    		<property name="targetDataSource"><ref local="targetDataSource"/></property>
    		<property name="username"><value>${db.username}</value></property>
    		<property name="password"><value>${db.password}</value></property>
    	</bean>
    The exception looks like this:
    Code:
    ERROR [org.springframework.web.context.ContextLoader] - Context initialization failedorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyAccessExceptionsException: PropertyAccessExceptionsException (1 errors); nested propertyAccessExceptions are: [org.springframework.beans.TypeMismatchException: Failed to convert property value of type [org.springframework.jndi.JndiObjectFactoryBean] to required type [javax.sql.DataSource] for property 'targetDataSource']
    PropertyAccessExceptionsException (1 errors)
    org.springframework.beans.TypeMismatchException: Failed to convert property value of type [org.springframework.jndi.JndiObjectFactoryBean] to required type [javax.sql.DataSource] for property 'targetDataSource'
    	at org.springframework.beans.BeanWrapperImpl.doTypeConversionIfNecessary(BeanWrapperImpl.java:1040)
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:803)
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:716)
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:850)
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:877)
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:866)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:901)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:707)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:316)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:222)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:146)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:277)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:310)
    	at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:133)
    	at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:230)
    	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:156)
    	at org.springframework.web.context.ContextLoaderServlet.init(ContextLoaderServlet.java:81)
    	at javax.servlet.GenericServlet.init(GenericServlet.java:258)
    	at com.ibm.servlet.engine.webapp.StrictServletInstance.doInit(ServletManager.java:802)
    	at com.ibm.servlet.engine.webapp.StrictLifecycleServlet._init(StrictLifecycleServlet.java:141)
    	at com.ibm.servlet.engine.webapp.PreInitializedServletState.init(StrictLifecycleServlet.java:254)
    	at com.ibm.servlet.engine.webapp.StrictLifecycleServlet.init(StrictLifecycleServlet.java:107)
    	at com.ibm.servlet.engine.webapp.ServletInstance.init(ServletManager.java:388)
    	at javax.servlet.GenericServlet.init(GenericServlet.java:258)
    	at com.ibm.servlet.engine.webapp.ServletManager.addServlet(ServletManager.java:84)
    	at com.ibm.servlet.engine.webapp.WebAppServletManager.loadServlet(WebAppServletManager.java:211)
    	at com.ibm.servlet.engine.webapp.WebAppServletManager.loadAutoLoadServlets(WebAppServletManager.java:350)
    	at com.ibm.servlet.engine.webapp.WebApp.loadServletManager(WebApp.java:1217)
    	at com.ibm.servlet.engine.webapp.WebApp.init(WebApp.java:145)
    	at com.ibm.servlet.engine.srt.WebGroup.loadWebApp(WebGroup.java:259)
    	at com.ibm.servlet.engine.srt.WebGroup.reload(WebGroup.java:1107)
    	at com.ibm.servlet.engine.srt.ClassChangeWatcher.classChanged(ClassChangeWatcher.java:55)
    	at com.ibm.ws.classloader.ClassLoaderManager.checkAndNotify(ClassLoaderManager.java:405)
    	at com.ibm.ws.classloader.ClassLoaderManager.access$100(ClassLoaderManager.java:46)
    	at com.ibm.ws.classloader.ClassLoaderManager$ReloadTimerTask.run(ClassLoaderManager.java:463)
    	at java.util.TimerThread.mainLoop(Timer.java:445)
    	at java.util.TimerThread.run(Timer.java:395)
    It appears that someone else has experienced this problem:
    http://forum.springframework.org/showthread.php?t=10080

    I did some rudimentary examination and found a couple of interesting points. I set a breakpoint at BeanWrapperImpl:872, just after the
    'PropertyValue[] pvs = propertyValues.getPropertyValues()' statement (by the way, this is Spring 1.2). The first time that the application context is initialised (when the server is first started), the PropertyValue array noted above for the 'dataSource' bean contains three objects: firstly a DataSource implementation, and then two strings representing the username and password for the connection. The PropertyPlaceholderConfigurer has correctly replaced the placeholders for the username and password with the values from the properties file.

    With the breakpoint still in place, I'll rebuild and deploy one of the application JARs. This triggers the hot deployment, which appears to, amongst other things, re-initialise the application context. However, when creating the 'dataSource' bean this time, the PropertyValue array contains the JndiObjectFactoryBean and the two placeholders for the username and the password. Obviously, this fails.

    Does anyone have any idea what might be causing this? Does Spring do something different the second time around? Or do I chalk this up to yet another WebSphere mystery?

    Geoff
    Last edited by robyn; May 16th, 2006, 05:39 AM.
Working...
X