Getting "java.lang.IllegalStateException: Cannot convert value of type" exception when setting up datasource in openejb - spring

I'm using OpenEJB 4.0.0, Spring 3.1.0.RELEASE, and JUnit 4.8.1. I'm trying to use OpenEJB to setup a datasource, which I do like so …
final Properties props = loadMyProjectProps();
final String dsJndiName = props.getProperty("DATASOURCE_JNDI_PREFIX") + "MySqlDS";
System.out.println("ds jndi name:" + dsJndiName);
p.put(dsJndiName, "new://Resource?type=DataSource");
p.put(dsJndiName + ".JdbcDriver", "com.mysql.jdbc.Driver");
final String url = "jdbc:mysql://" + props.getProperty("DB_SERVER") + ":" + props.getProperty("DB_PORT") + "/" + props.getProperty("DB_NAME");
p.put(dsJndiName + ".JdbcUrl", url);
p.put(dsJndiName + ".Username", props.getProperty("DB_USER"));
p.put(dsJndiName + ".Password", props.getProperty("DB_PASSWORD"));
final InitialContext initialContext = new InitialContext(p);
but upon initializing my Spring text application, which sets up the session factory and datasource like so …
<bean id="myprojSessionFactory" lazy-init="true" scope="singleton"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="mappingResources">
<ref bean="_hibernate_config_list"/>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.connection.release_mode">auto</prop>
<prop key="hibernate.dialect">${HIBERNATE_DIALECT}</prop>
<prop key="hibernate.transaction.factory.class">${HIBERNATE_TRANSACTION_FACTORY}</prop>
<prop key="hibernate.current_session_context_class">jta</prop>
<prop key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>
<prop key="hibernate.show.sql">true</prop>
<prop key="hibernate.transaction.flush_before_completion">true</prop>
<prop key="hibernate.transaction.auto_close_session">true</prop>
</props>
</property>
<property name="dataSource">
<ref bean="myproj.ds.${DS_PREFIX}${DB_DATASOURCE}"/>
</property>
</bean>
…
<bean id="myproj.ds.jndi-MySqlDS" class="org.springframework.jndi.JndiObjectFactoryBean" lazy-init="true">
<property name="jndiName"><value>${DATASOURCE_JNDI_PREFIX}MySqlDS</value></property>
</bean>
I'm getting the exception that follows. Any idea how I fix this annoying "Cannot convert value of type [org.apache.openejb.core.ivm.naming.IvmContext] to required type [javax.sql.DataSource] for property 'dataSource'" exception?
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myprojSessionFactory' defined in class path resource [myproj/spring/config/db/hibernate/Hibernate-config.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'org.apache.openejb.core.ivm.naming.IvmContext' to required type 'javax.sql.DataSource' for property 'dataSource'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.apache.openejb.core.ivm.naming.IvmContext] to required type [javax.sql.DataSource] for property 'dataSource': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
... 113 more
Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'org.apache.openejb.core.ivm.naming.IvmContext' to required type 'javax.sql.DataSource' for property 'dataSource'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.apache.openejb.core.ivm.naming.IvmContext] to required type [javax.sql.DataSource] for property 'dataSource': no matching editors or conversion strategy found
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:485)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:516)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:510)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1406)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1365)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
... 119 more
Caused by: java.lang.IllegalStateException: Cannot convert value of type [org.apache.openejb.core.ivm.naming.IvmContext] to required type [javax.sql.DataSource] for property 'dataSource': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:241)
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:470)
... 125 more

the datasource property is looking for a datasource and you've passed it a String (because you used value=). You need to pass it the reference to your bean instead:

Related

Getting : java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [javax.sql.DataSource]

I am using Spring 3.2.13 jars and ibatis 2.3.4.726 version to set up a dataSource as below
I am getting the below Exception
Caused by: java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [javax.sql.DataSource] for property 'dataSource': no matching editors or conversion strategy found
My xml Spring Configurations are as below :
<bean id="commonDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="jdbc/ds_GOLD" />
<property name="defaultObject" value="jdbc/ds_SILVERR" />
</bean>
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation">
<value>
classpath:com/dav/dao/config/sqlMapConfig.xml
</value>
</property>
<property name="dataSource">
<ref bean="commonDataSource" />
</property>
<property name="transactionConfigClass">
<value>com.ibatis.sqlmap.engine.transaction.external.ExternalTransactionConfig
</value>
</property>
<property name="transactionConfigProperties">
<props>
<prop key="DefaultAutoCommit">false</prop>
<prop key="SetAutoCommitAllowed">false</prop>
</props>
</property>
</bean>
The Configurations seems good for me but getting exception
only if the "jdbc/ds_GOLD" is not configured in App server. In this case it should get picked the defaultObject JNDI. If the "jdbc/ds_GOLD" is configured in App server i don't see any error in logs. But Failover case it is not working.
[5/1/16 3:32:51:329 EDT] 00000098 webapp I com.ibm.ws.webcontainer.webapp.WebApp log SRVE0296E: [glow#glow.war][/glow][Servlet.LOG]:.StrutsServlet: null:.org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gcdSqlMapClient' defined in ServletContext resource [/WEB-INF/config/common-dao.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.lang.String' to required type 'javax.sql.DataSource' for property 'dataSource'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [javax.sql.DataSource] for property 'dataSource': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:529)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:191)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:618)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:934)
.
.
.
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1862)
Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.lang.String' to required type 'javax.sql.DataSource' for property 'dataSource'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [javax.sql.DataSource] for property 'dataSource': no matching editors or conversion strategy found
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:464)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:495)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:489)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1465)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1424)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1160)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
... 114 more
Caused by: java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [javax.sql.DataSource] for property 'dataSource': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:267)
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:449)
... 120 more
``
Forget to keep the defaultObject as property reference to the dataSource. I wrongly configured it as property value.

Error creating bean with name 'messageSource': Injection of autowired dependencies failed;

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageSource':
Injection of autowired dependencies failed;
nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private xx.services.MessageSourceService xx.controllers.DatabaseDrivenMessageSource.messageSourceService;
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageSourceService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private xx.dao.MessageSourceDAO xx.services.MessageSourceService.messageSourceDao;
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageSourceDAO': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory
xx.dao.MessageSourceDAO.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]:
Invocation of init method failed; nested exception is java.lang.NullPointerException
APPLICATION CONTEXT.XML
<tx:annotation-driven transaction-manager="transactionManager" />
<bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager"
p:sessionFactory-ref="sessionFactory" />
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
</props>
</property>
<property name="packagesToScan" value="com.abc.cmtglobal"></property>
</bean>
<context:annotation-config />
<bean id="messageSource" class="com.abc.cmtglobal.controllers.DatabaseDrivenMessageSource"></bean>
<context:component-scan base-package="com.abc.cmtglobal" >
The root cause is
Error creating bean with name 'sessionFactory' defined in class path
resource [applicationContext.xml]
So it looks like you are having a problem with your hibernate configuration.
The last line of your stacktrace shows a NullPointerException.
In eclipse or InteliJ you can set Exception breakpoints.
Set one for NullPointerException and debug the startup. You may see some NullPointerExceptions not related to your problem, but finally you will see the one that is terminating startup. Once you found the location where it happens its mostly easy to find a solution..

How do I use the spring jars in my liferay portlet instead of the spring jars in the ROOT\WEB-INF\lib?

I have a portlet that I've created and I'm trying to use spring jpa in it for data retrieval. I'm using Spring version 3.2.14 and the spring jars that I need are deployed in my portlet's WEB-INF/lib folder.
On tomcat start up I keep getting the following exception:
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'packagesToScan' of bean class [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean]: Bean property 'packagesToScan' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:1052)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:921)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:76)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360)
... 39 more
If I attach a debugger to Tomcat I can see that it is using spring-beans.jar(version 3.0.7.RELEASE) that is in ROOT/WEB-INF/lib which has a know issue with 'packageToScan' in LocalContainerEntityManagerFactoryBean in my bean definition:
<bean id="reportingEntityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan">
<list>
<value>org.preptoolkit.exercise.reporting.model</value>
</list>
</property>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="true" />
<property name="databasePlatform" value="org.hibernate.dialect.MySQL5Dialect"/>
</bean>
</property>
</bean>
I have tried putting spring-beans-3.2.14.RELEASE.jar in $tomcat_home/lib/ext and liferay still uses the 3.0.7 verion.
Liferay Version: 6.2-ce-ga4
So how do I get Liferay to use spring-beans-3.2.14.RELEASE.jar instead of the one ROOT for my portlet?
(I've been pounding my head on this wall for 3 days now)
UPDATE
Here is the full stacktrace:
13:26:55,702 ERROR [localhost-startStop-1][ContextLoader:206] Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'reportingEntityManagerFactory' defined in ServletContext resource [/WEB-INF/classes/persistenceContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'packagesToScan' of bean class [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean]: Bean property 'packagesToScan' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1363)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1085)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:516)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:567)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:282)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:204)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at com.liferay.portal.spring.context.PortletContextLoaderListener.contextInitialized(PortletContextLoaderListener.java:85)
at com.liferay.portal.deploy.hot.SpringHotDeployListener.doInvokeDeploy(SpringHotDeployListener.java:85)
at com.liferay.portal.deploy.hot.SpringHotDeployListener.invokeDeploy(SpringHotDeployListener.java:41)
at com.liferay.portal.deploy.hot.HotDeployImpl.doFireDeployEvent(HotDeployImpl.java:227)
at com.liferay.portal.deploy.hot.HotDeployImpl.fireDeployEvent(HotDeployImpl.java:96)
at com.liferay.portal.kernel.deploy.hot.HotDeployUtil.fireDeployEvent(HotDeployUtil.java:28)
at com.liferay.portal.kernel.servlet.PluginContextListener.fireDeployEvent(PluginContextListener.java:164)
at com.liferay.portal.kernel.servlet.PluginContextListener.doPortalInit(PluginContextListener.java:154)
at com.liferay.portal.kernel.util.BasePortalLifecycle.portalInit(BasePortalLifecycle.java:44)
at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(PortalLifecycleUtil.java:74)
at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(PortalLifecycleUtil.java:58)
at com.liferay.portal.kernel.util.BasePortalLifecycle.registerPortalLifecycle(BasePortalLifecycle.java:54)
at com.liferay.portal.kernel.servlet.PluginContextListener.contextInitialized(PluginContextListener.java:116)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1113)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1671)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'packagesToScan' of bean class [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean]: Bean property 'packagesToScan' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:1052)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:921)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:76)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360)
... 39 more
There is a SpringHotDeployListener that tries to initialize Spring (with the library from Liferay) for every portlet app.
To turn that off for your webapp you will have to remove com.liferay.portal.deploy.hot.SpringHotDeployListener in the property hot.deploy.listeners in your portal-ext.properties.
If you use other portlet apps which make use of the Spring environment of Liferay, you will need to create an Ext Plugin and extend SpringHotDeployListener in ext-impl:
public class MySpringHotDeployListener extends SpringHotDeployListener {
protected void doInvokeDeploy(HotDeployEvent hotDeployEvent) throws Exception {
if (!hotDeployEvent.getServletContext().getServletContextName().equals("MyContextName")) {
super.doInvokeDeploy(hotDeployEvent);
}
}
// Same for doInvokeUndeploy
}
Use MySpringHotDeployListener insteand of SpringHotDeployListener in portal-ext.properties then.

Google App Engine error while using Spring and Hibernate

I am using Spring 2.0 and hibernate, but I am getting following error when I am trying to port my application to GAE.
javax.servlet.ServletContext log: Exception while dispatching incoming RPC call com.google.gwt.user.client.rpc.SerializationException:
Type 'org.springframework.beans.factory.BeanCreationException' was not included in the set of types which can be serialized by this SerializationPolicy or its Class object could not be loaded.
For security purposes, this type will not be serialized.:
instance = org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'ManagerAdmin' defined in class path resource [applicationContext.xml]:
Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory';
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]:
Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource';
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'dataSource' defined in class path resource [applicationContext.xml]:
Error setting property values;
nested exception is org.springframework.beans.NotWritablePropertyException:
Invalid property 'hibernate.dialect' of bean class [org.springframework.jdbc.datasource.DriverManagerDataSource]:
Nested property in path 'hibernate.dialect' does not exist;
nested exception is org.springframework.beans.NotReadablePropertyException: Invalid property 'hibernate' of bean class [org.springframework.jdbc.datasource.DriverManagerDataSource]:
Bean property 'hibernate' is not readable or has an invalid getter method:
Does the return type of the getter match the parameter type of the setter
Here is the application.xml that I am using:
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
<property name="driverClassName" value="com.google.appengine.api.rdbms.AppEngineDriver"/>
<property name="url" value="jdbc:google:rdbms://cloudsql/XXXXX:XXXX/XXXXdb?user=XXXX" />
<property name="username" value="XXXXX" />
<property name="password" value="XXXXX" />
Any help is appreciated.
Thanks
Raja.
After following Ean's, recommendation on correcting applicationContext.xml. I am now getting following error.
javax.servlet.ServletContext log: Exception while dispatching incoming RPC call
com.google.gwt.user.client.rpc.SerializationException: Type 'org.hibernate.exception.DataException' was not included in the set of types which can be serialized by this SerializationPolicy or its Class object could not be loaded. For security purposes, this type will not be serialized.: instance = org.hibernate.exception.DataException: Cannot open connection
at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:665)
at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:126)
at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter$ValueWriter$8.write(ServerSerializationStreamWriter.java:153)
at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeValue(ServerSerializationStreamWriter.java:585)
at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeClass(ServerSerializationStreamWriter.java:755)
at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeImpl(ServerSerializationStreamWriter.java:794)
at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:667)
at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:126)
at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter$ValueWriter$8.write(ServerSerializationStreamWriter.java:153)
at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeValue(ServerSerializationStreamWriter.java:585)
at com.google.gwt.user.server.rpc.RPC.encodeResponse(RPC.java:605)
at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:393)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:579)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:125)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:35)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.JdbcMySqlConnectionCleanupFilter.doFilter(JdbcMySqlConnectionCleanupFilter.java:60)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:266)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
at com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:76)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:146)
at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:446)
at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:437)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:444)
at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:188)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:308)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:300)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:441)
at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:251)
at java.lang.Thread.run(Thread.java:724)
The hibernate.dialect is a Hibernate property which should be passed to sessionFactory. You are passing that to dataSource bean which is not aware of such property. Follow is a sample that you should be doing something like that:
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.google.appengine.api.rdbms.AppEngineDriver"/>
<property name="url" value="jdbc:google:rdbms://cloudsql/XXXXX:XXXX/XXXXdb?user=XXXX" />
<property name="username" value="XXXXX" />
<property name="password" value="XXXXX" />
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="annotatedClasses">
<list>
<value>com.project.EntityClass</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
Notice how hibernate.dialect has been passed.

Spring, Atomikos, Tibco EMS 5.1 integration issue

I am trying to configure Atomikos in my Spring application. I am using:
Atomikos 3.7.1 (TransactionsEssentials)
Spring 3.0.2
Tibco EMS 5.1
Can some one give me the configuration details for the connection factory using JNDI for JMS and also details regarding Tibco EMS configuration?
I had tried the following:
<bean id="jmsTemplate2" class="org.springframework.jms.core.JmsTemplate" >
<property name="connectionFactory" ref="amqConnectionFactory" />
<property name="defaultDestination" ref="queue" />
<property name="sessionTransacted" value="true"/>
<property name="messageConverter" ref="messageConverter"></property>
</bean>
<bean id="amqConnectionFactory" class="com.atomikos.jms.AtomikosConnectionFactoryBean" init-method="init">
<property name="uniqueResourceName" value="XAEMS" />
<property name="xaConnectionFactory" ref="connectionFactory" />
<property name="poolSize" value="10" />
</bean>
<jee:jndi-lookup id="connectionFactory" jndi-name="emsConnectionFactory">
<jee:environment>
java.naming.factory.initial=com.tibco.tibjms.naming.TibjmsInitialContextFactory
java.naming.provider.url=tibjmsnaming://localhost:7222
</jee:environment>
</jee:jndi-lookup>
<jee:jndi-lookup id="queue" jndi-name="emsQueue">
<jee:environment>
java.naming.factory.initial=com.tibco.tibjms.naming.TibjmsInitialContextFactory
java.naming.provider.url=tibjmsnaming://localhost:7222
</jee:environment>
</jee:jndi-lookup>
But get this error:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'amqConnectionFactory' defined in file [C:\springsource\vfabric-tc-server-developer-2.6.4.RELEASE\spring-insight-instance\wtpwebapps\iRebal-Backend-Poc-Web-Integration-Final-xa\WEB-INF\classes\META-INF\spring\batch\jobs\priority-queue.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'com.tibco.tibjms.naming.TibjmsFederatedQueueConnectionFactory' to required type 'javax.jms.XAConnectionFactory' for property 'xaConnectionFactory'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [com.tibco.tibjms.naming.TibjmsFederatedQueueConnectionFactory] to required type [javax.jms.XAConnectionFactory] for property 'xaConnectionFactory': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
... 39 more
Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'com.tibco.tibjms.naming.TibjmsFederatedQueueConnectionFactory' to required type 'javax.jms.XAConnectionFactory' for property 'xaConnectionFactory'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [com.tibco.tibjms.naming.TibjmsFederatedQueueConnectionFactory] to required type [javax.jms.XAConnectionFactory] for property 'xaConnectionFactory': no matching editors or conversion strategy found
at org.springframework.beans.BeanWrapperImpl
This answer is too late for the OP, but for the sake of posterity:
The class you want is com.tibco.tibjms.TibjmsXAConnectionFactory.
It seems that in class com.atomikos.jms.AtomikosConnectionFactoryBean you have a field named xaConnectionFactory that its type (or its getter return type) is javax.jms.XAConnectionFactory. However, in Spring configuration file, you configured that field to be set with an instance of which type is com.tibco.tibjms.naming.TibjmsFederatedQueueConnectionFactory.
Apparently com.tibco.tibjms.naming.TibjmsFederatedQueueConnectionFactory is not convertible to javax.jms.XAConnectionFactory.

Resources