Rafal,

Have you use SimpleDriverDataSource instead of SingleConnectionDataSource
because I see this remark in Spring web site ?

http://static.springsource.org/spring/docs/2.5.6/api/org/springframework/jdbc/datasource/DriverManagerDataSource.html

*NOTE: Within special class loading environments such as OSGi, this class is
effectively superseded by
SimpleDriverDataSource<http://static.springsource.org/spring/docs/2.5.6/api/org/springframework/jdbc/datasource/SimpleDriverDataSource.html>due
to general class loading issues with the JDBC DriverManager that be
resolved through direct Driver usage (which is exactly what
SimpleDriverDataSource does).*

Kind regards,

Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer

*****************************
blog : http://cmoulliard.blogspot.com
twitter : http://twitter.com/cmoulliard
Linkedlin : http://www.linkedin.com/in/charlesmoulliard

Apache Camel Group :
http://www.linkedin.com/groups?home=&gid=2447439&trk=anet_ug_hm


On Tue, Feb 2, 2010 at 3:00 PM, Rafal Rusin <[email protected]> wrote:

> Hello,
>
> I'm trying to create OSGi distro for Apache HISE.
> Until now I went quite far, however I've got a problem with running
> OpenJPA.
> It shows following problem while trying to obtain connection using
> Spring's JpaTemplate:
>
> -----------------------
> 14:20:48,774 | WARN  | 6369...@qtp0-1   | PhaseInterceptorChain
>    | ache.cxf.common.logging.LogUtils  361 | Application
> {
> http://www.insurance.example.com/claims}ClaimsHandlingService#{http://www.insurance.example.com/claims}approve<http://www.insurance.example.com/claims%7DClaimsHandlingService#%7Bhttp://www.insurance.example.com/claims%7Dapprove>
> has thrown exception, unwinding now
> org.apache.cxf.interceptor.Fault: Could not open JPA EntityManager for
> transaction; nested exception is <openjpa-0.0.0-rnull fatal user
> error> org.apache.openjpa.persistence.ArgumentException: A connection
> could not be obtained for driver class "null" and URL "null".  You may
> have specified an invalid URL.
>        at
> org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:155)
>        at
> org.apache.cxf.jaxws.AbstractJAXWSMethodInvoker.createFault(AbstractJAXWSMethodInvoker.java:85)
>        at
> org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:121)
>        at
> org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.java:60)
>        at
> org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:75)
>        at
> org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
>        at
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:417)
>        at
> java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:269)
>        at java.util.concurrent.FutureTask.run(FutureTask.java:123)
>        at
> org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
>        at
> org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:106)
>        at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:239)
>        at
> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:109)
>        at
> org.apache.cxf.transport.http_osgi.OsgiDestination.doMessage(OsgiDestination.java:79)
>        at
> org.apache.cxf.transport.http_osgi.OsgiServletController.invokeDestination(OsgiServletController.java:324)
>        at
> org.apache.cxf.transport.http_osgi.OsgiServletController.invoke(OsgiServletController.java:148)
>        at
> org.apache.cxf.transport.http_osgi.OsgiServlet.invoke(OsgiServlet.java:53)
>        at
> org.apache.cxf.transport.http_osgi.SpringOsgiServlet.invoke(SpringOsgiServlet.java:48)
>        at
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:179)
>        at
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:103)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:713)
>        at
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:159)
>        at
> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
>        at
> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:363)
>        at
> org.ops4j.pax.web.service.internal.HttpServiceServletHandler.handle(HttpServiceServletHandler.java:64)
>        at
> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
>        at
> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
>        at
> org.ops4j.pax.web.service.internal.HttpServiceContext.handle(HttpServiceContext.java:111)
>        at
> org.ops4j.pax.web.service.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:64)
>        at
> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
>        at org.mortbay.jetty.Server.handle(Server.java:324)
>        at
> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:534)
>        at
> org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:879)
>        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:741)
>        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:213)
>        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:403)
>        at
> org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
>        at
> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:522)
> Caused by:
> org.springframework.transaction.CannotCreateTransactionException:
> Could not open JPA EntityManager for transaction; nested exception is
> <openjpa-0.0.0-rnull fatal user error>
> org.apache.openjpa.persistence.ArgumentException: A connection could
> not be obtained for driver class "null" and URL "null".  You may have
> specified an invalid URL.
>        at
> org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:375)
>        at
> org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:374)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>        at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>        at java.lang.reflect.Method.invoke(Method.java:585)
>        at
> org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
>        at
> org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:58)
>        at
> org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:62)
>        at
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
>        at
> org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
>        at
> org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
>        at
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
>        at
> org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:56)
>        at
> org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:39)
>        at
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
>        at
> org.springframework.osgi.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:59)
>        at
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
>        at
> org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
>        at
> org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
>        at
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
>        at
> org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
>        at $Proxy111.getTransaction(Unknown Source)
>        at
> org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:125)
>        at
> org.apache.hise.engine.jaxws.HISEJaxWSService.invoke(HISEJaxWSService.java:88)
>        at
> org.apache.hise.engine.jaxws.HISEJaxWSService.invoke(HISEJaxWSService.java:51)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>        at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>        at java.lang.reflect.Method.invoke(Method.java:585)
>        at
> org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:173)
>        at
> org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:89)
>        ... 35 more
> Caused by: <openjpa-0.0.0-rnull fatal user error>
> org.apache.openjpa.persistence.ArgumentException: A connection could
> not be obtained for driver class "null" and URL "null".  You may have
> specified an invalid URL.
>        at
> org.apache.openjpa.jdbc.schema.DataSourceFactory.newConnectException(DataSourceFactory.java:256)
>        at
> org.apache.openjpa.jdbc.schema.DataSourceFactory.installDBDictionary(DataSourceFactory.java:242)
>        at
> org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getConnectionFactory(JDBCConfigurationImpl.java:692)
>        at
> org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDataSource(JDBCConfigurationImpl.java:790)
>        at
> org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDataSource2(JDBCConfigurationImpl.java:797)
>        at
> org.apache.openjpa.jdbc.schema.SchemaTool.<init>(SchemaTool.java:127)
>        at
> org.apache.openjpa.jdbc.meta.MappingTool.newSchemaTool(MappingTool.java:310)
>        at
> org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:490)
>        at
> org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:453)
>        at
> org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.synchronizeMappings(JDBCBrokerFactory.java:159)
>        at
> org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.newBrokerImpl(JDBCBrokerFactory.java:119)
>        at
> org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:189)
>        at
> org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:142)
>        at
> org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:192)
>        at
> org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:145)
>        at
> org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:56)
>        at
> org.springframework.orm.jpa.JpaTransactionManager.createEntityManagerForTransaction(JpaTransactionManager.java:392)
>        at
> org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:320)
>        ... 66 more
> Caused by: java.sql.SQLException: No suitable driver
>        at java.sql.DriverManager.getConnection(DriverManager.java:545)
>        at java.sql.DriverManager.getConnection(DriverManager.java:140)
>        at
> org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:174)
>        at
> org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriver(DriverManagerDataSource.java:165)
>        at
> org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnectionFromDriver(AbstractDriverBasedDataSource.java:149)
>        at
> org.springframework.jdbc.datasource.SingleConnectionDataSource.initConnection(SingleConnectionDataSource.java:241)
>        at
> org.springframework.jdbc.datasource.SingleConnectionDataSource.getConnection(SingleConnectionDataSource.java:184)
>        at
> org.apache.openjpa.lib.jdbc.DelegatingDataSource.getConnection(DelegatingDataSource.java:112)
>        at
> org.apache.openjpa.lib.jdbc.DecoratingDataSource.getConnection(DecoratingDataSource.java:93)
>        at
> org.apache.openjpa.jdbc.schema.DataSourceFactory.installDBDictionary(DataSourceFactory.java:234)
>        ... 82 more
> -----------------------
>
>
>
> Obviously those required parameters are set in following config:
>
> -----------------------
>    <bean id="htEntityManagerFactory"
> class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
>        <property name="dataSource" ref="dataSource" />
>        <property name="jpaVendorAdapter" ref="jpaVendorAdapter"/>
>        <property name="jpaPropertyMap" ref="jpaPropertyMap"/>
>        <property name="persistenceXmlLocation"
> value="classpath:/org/apache/hise/persistence.xml" />
>        <property name="persistenceUnitName" value="org.apache.hise"/>
>    </bean>
>
>    <util:map id="jpaPropertyMap">
>    </util:map>
>
>    <!-- OpenJPA H2 Driver -->
>    <bean id="jpaVendorAdapter"
> class="org.apache.hise.dao.vendor.OpenJpaVendorAdapter">
>    <property name="database" value="H2"/>
>    <property name="databasePlatform"
> value="org.apache.openjpa.jdbc.sql.H2Dictionary"/>
>    <property name="generateDdl"    value="true" />
>    <property name="showSql"      value="false" />
>    <property name="extProperties">
>      <util:map>
>        <entry key="openjpa.jdbc.SynchronizeMappings"
> value="buildSchema(ForeignKeys=true,SchemaAction='add')"/>
>      </util:map>
>    </property>
>  </bean>
>
>
>    <bean id="dataSource"
> class="org.springframework.jdbc.datasource.SingleConnectionDataSource">
>        <property name="driverClassName" value="org.h2.Driver" />
>        <property name="url"
> value="jdbc:h2:file:hise-h2-db;DB_CLOSE_ON_EXIT=false"/>
>        <property name="username" value="sa" />
>        <property name="password">
>            <value></value>
>        </property>
>        <property name="autoCommit" value="false" />
>        <property name="suppressClose" value="true" />
>    </bean>
> -----------------------
>
>
> Do you have some ideas why it fails and where to look for clues?
> Maybe org.apache.servicemix.bundles.openjpa-1.2.1_2.jar bundle is
> incorrect? HISE shows "Starting OpenJPA 0.0.0" log - it's not a good
> thing I suppose.
>
> Here are logs from startup:
>
> -----------------------
> ka...@root> 99  org.apache.hise  WARN   [SpringOsgiExtenderThread-39]
> openjpa.Runtime - An error occurred while registering a
> ClassTransformer with PersistenceUnitInfo: name 'org.apache.hise',
> root URL [bundleresource://42.fwk22730182/]. The error has been
> consumed. To see it, set your openjpa.Runtime log level to TRACE.
> Load-time class transformation will not be available.
> 5338  org.apache.hise  INFO   [pool-5-thread-1] openjpa.Runtime -
> Starting OpenJPA 0.0.0
> 5431  org.apache.hise  INFO   [pool-5-thread-1] openjpa.jdbc.JDBC -
> Using dictionary class "org.apache.openjpa.jdbc.sql.H2Dictionary".
> Warning: external object model net.sf.saxon.dom.DOMEnvelope has been
> loaded, but is not an instance of net.sf.saxon.om.ExternalObjectModel
> Warning: external object model net.sf.saxon.dom.DOMObjectModel has
> been loaded, but is not an instance of
> net.sf.saxon.om.ExternalObjectModel
> {http://www.insurance.example.com/claims}ClaimsResolvingPort<http://www.insurance.example.com/claims%7DClaimsResolvingPort>
> -----------------------
>
> And here are versions of additional bundles I used:
>
> -----------------------
> cxf-osgi-4.1.0-psc-02-00RC1.jar
> h2-1.1.117.jar
> hise-bundle-0.1.0-SNAPSHOT.jar
> hise-test-example-osgi-0.1.0-SNAPSHOT.jar
> org.apache.servicemix.bundles.openjpa-1.2.1_2.jar
> org.apache.servicemix.bundles.serp-1.13.1_2.jar
> org.apache.servicemix.specs.java-persistence-api-1.1.1-1.4.0.jar
> spring-aspects-2.5.6.SEC01.jar
> spring-jdbc-2.5.6.SEC01.jar
> spring-orm-2.5.6.SEC01.jar
> -----------------------
>
> SMX4 version I used is from FUSE apache-servicemix-4.1.0-psc-01-00RC1.
>
>
> Regards,
> --
> RafaƂ Rusin
> http://rrusin.blogspot.com
> http://www.touk.pl
> http://top.touk.pl
>

Reply via email to