You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by jelramzy <Ra...@consulting-for.accor.com> on 2013/03/04 15:50:03 UTC

Trouble getting the jpa-osgi project example work with MySQL: Not supported by BasicDataSource

Hi everyone!

Well as the title of the issue mention it, i am experiencing serious
troubles to get the jpa-osgi project example functionnal by replacing the
HSQLDB with MYSQL.

Obvliously ( i hope i am not mistaking) i had to modify 2 files :
"persistence.xml" and "beans.xml" in the wsdl-first-cxfse-bundle
sub-project.
Here are the modifications i brought to the 2 files:


   - beans.xml file


<bean id="jpaAdapter"
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name=&quot;databasePlatform&quot;
value=&quot;org.hibernate.dialect.&lt;b>MySQLDialect*" />
</bean>


<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/test" />
<property name="username" value="myuser" />
<property name="password" value="mypass" />
</bean>

    - persistence.xml file:


<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0">

<persistence-unit name="smx4" transaction-type="RESOURCE_LOCAL">
<class>org.apache.servicemix.samples.wsdl_first.PersonEntity</class>


<properties>
<property name="hibernate.dialect"
value="org.hibernate.dialect.MySQLDialect" />
<property name="hibernate.hbm2ddl.auto" value="create" />
<property name="hibernate.connection.password" value="mypass" />
<property name="hibernate.connection.url"
value="jdbc:mysql://localhost:3306/test" />
<property name="hibernate.connection.username" value="myuser" />
</properties>
</persistence-unit>
</persistence>

I reinstalles the bundles via the console , as described in the readme.txt
file , but i got the following exception in the fuse console:

karaf@root> Exception in thread "SpringOsgiExtenderThread-14"
org.springframewor
k.beans.factory.BeanCreationException: Error creating bean with name
'org.apache
.servicemix.cxfse.CxfSeEndpoint#0' defined in URL
[bundle://267.0:0/META-INF/spr
ing/beans.xml]: Cannot create inner bean
'org.apache.servicemix.samples.wsdl_fir
st.PersonImpl#0' of type
http://org.apache.servicemix.samples.wsdl_first.PersonImpl w
hile setting bean property 'pojo'; nested exception is
org.springframework.beans
.factory.BeanCreationException: Error creating bean with name
'org.apache.servic
emix.samples.wsdl_first.PersonImpl#0' defined in URL
[bundle://267.0:0/META-INF/
spring/beans.xml]: Instantiation of bean failed; nested exception is
org.springf
ramework.beans.BeanInstantiationException: Could not instantiate bean class
[org
.apache.servicemix.samples.wsdl_first.PersonImpl]: Constructor threw
exception;
nested exception is java.lang.UnsupportedOperationException: Not supported
by Ba
sicDataSource
at org.springframework.beans.factory.support.BeanDefinitionValueResolver
.resolveInnerBean(BeanDefinitionValueResolver.java:281)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver
.resolveValueIfNecessary(BeanDefinitionValueResolver.java:120)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
ject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
y.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
an(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.
preInstantiateSingletons(DefaultListableBeanFactory.java:580)
at org.springframework.context.support.AbstractApplicationContext.finish
BeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.osgi.context.support.AbstractDelegatedExecutionAp
plicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:6
9)
at org.springframework.osgi.context.support.AbstractDelegatedExecutionAp
plicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355)
at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCus
tomTCCL(PrivilegedUtils.java:85)
at org.springframework.osgi.context.support.AbstractDelegatedExecutionAp
plicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.ja
va:320)
at org.springframework.osgi.extender.internal.dependencies.startup.Depen
dencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterAp
plicationContextExecutor.java:132)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.springframework.beans.factory.BeanCreationException: Error
creati
ng bean with name 'org.apache.servicemix.samples.wsdl_first.PersonImpl#0'
define
d in URL bundle://267.0:0/META-INF/spring/beans.xml: Instantiation of bean
fai
led; nested exception is
org.springframework.beans.BeanInstantiationException: C
ould not instantiate bean class
[org.apache.servicemix.samples.wsdl_first.Person
Impl]: Constructor threw exception;
at org.springframework.beans.factory.support.ConstructorResolver.autowir
eConstructor(ConstructorResolver.java:288)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1003)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:907)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver
.resolveInnerBean(BeanDefinitionValueResolver.java:270)
... 17 more
Caused by: org.springframework.beans.BeanInstantiationException: Could not
insta
ntiate bean class
http://org.apache.servicemix.samples.wsdl_first.PersonImpl: Constru
ctor threw exception; nested exception is
java.lang.UnsupportedOperationExceptio
n: Not supported by BasicDataSource
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:1
41)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy
.instantiate(SimpleInstantiationStrategy.java:108)
at org.springframework.beans.factory.support.ConstructorResolver.autowir
eConstructor(ConstructorResolver.java:280)
... 22 more
Caused by: java.lang.UnsupportedOperationException: Not supported by
BasicDataSo
urce
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource
.java:900)
at org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.get
Connection(InjectedDataSourceConnectionProvider.java:43)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager
.java:446)
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.
java:167)
at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:142)
at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:
85)
at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1354
)
at org.hibernate.ejb.TransactionImpl.begin(TransactionImpl.java:38)
at org.apache.servicemix.samples.wsdl_first.PersonImpl.<init>(PersonImpl
.java:36)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
orAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
onstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:1
26)
... 24 more


 I am using "apache-servicemix-4.4.1-fuse-08-15<" from the FUSE ESB site and
wanted to test Apache ServiceMix, moreover i should say that  the hsqld
worked fine for me and did not have any trouble to test it but just
switching to MYSQL ( in my example) seems not working: did i miss something
?

I have the MYSQL database running locally and i don't really see where is
the problem? is it related to the driver? is there a step by step tutorial
in that case showing how to deploy it ( if it si the problem) ?


I am discovering Fuse ESB so please any help or explanation will be more
than welcome here.

Regrads





--
View this message in context: http://servicemix.396122.n5.nabble.com/Trouble-getting-the-jpa-osgi-project-example-work-with-MySQL-Not-supported-by-BasicDataSource-tp5716020.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Trouble getting the jpa-osgi project example work with MySQL: Not supported by BasicDataSource

Posted by jelramzy <Ra...@consulting-for.accor.com>.
One more thing...since the getConnection in the DBCP package does not support
using ( login, password) signature..than why did the  Fuse / Apache
ServiceMix team  provide us with that example using this configuration ?

-  
- <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
*  <property name="driverClassName" value="org.hsqldb.jdbcDriver" /> *
  <property name="url" value="jdbc:hsqldb:mem:smx4_jpa" /> 
*  <property name="username" value="sa" /> *
*  <property name="password" value="" /> *
  </bean>

I don't really understand! 




--
View this message in context: http://servicemix.396122.n5.nabble.com/Trouble-getting-the-jpa-osgi-project-example-work-with-MySQL-Not-supported-by-BasicDataSource-tp5716020p5716056.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Trouble getting the jpa-osgi project example work with MySQL: Not supported by BasicDataSource

Posted by jchurch <Ji...@segmint.com>.
Hi.

The DBCP BasicDataSource does not support the getConnection(String user,
String password) method, at least not DBCP 1.4 and apparently whatever
version you have in your environment.  I have no knowledge of the jpa-osgi
example or what its pratcical constraints are.  Can't you just replace dbcp
and still meet your purposes?  Replace it with something like
org.springframework.jdbc.datasource.SimpleDriverDataSource?

Regards,
Jim



--
View this message in context: http://servicemix.396122.n5.nabble.com/Trouble-getting-the-jpa-osgi-project-example-work-with-MySQL-Not-supported-by-BasicDataSource-tp5716020p5716042.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Trouble getting the jpa-osgi project example work with MySQL: Not supported by BasicDataSource

Posted by jelramzy <Ra...@consulting-for.accor.com>.
Hi,

Thank you for your reply! well i will try to apply your suggestion and keep
you updated..
Meanwhile , is there a workaround to still use DBCP and inject the login
/password in a different way? 




--
View this message in context: http://servicemix.396122.n5.nabble.com/Trouble-getting-the-jpa-osgi-project-example-work-with-MySQL-Not-supported-by-BasicDataSource-tp5716020p5716055.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.