Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Gemini » Gemini JPA and Spring(How to inject EntityManager?)
Gemini JPA and Spring [message #1001421] Wed, 16 January 2013 12:03 Go to next message
Simon Watson is currently offline Simon Watson
Messages: 30
Registered: September 2011
Member
I'm migrating an application which uses Spring DM & Virgo 3.05 to Gemini Blueprint & Virgo 3.6. I have it working but I would like to use Gemini DBAccess (with MySQL) and Gemini JPA.

Currently, my DB access is achieved with 3 of my OSGi bundles:

1. Datasource, providing a javax.sql.DataSource service (also uses a properties file to store DB connection params).
2. Domain model, which defines a persistence unit.
3. DAO, which consumes the datasource service and injects an EntityManager into various @Repository POJOs.

I've looked through all the Gemini JPA docs but I'm unclear how I should modify my bundle-context.xml. Previously I had this:

<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" p:dataSource-ref="dataSource">
		<property name="jpaVendorAdapter">
			<bean id="jpaVendorAdapter" class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter"
					p:databasePlatform="org.eclipse.persistence.platform.database.MySQLPlatform" 
					p:showSql="true"/>
		</property>
</bean>

<osgi:reference id="dataSource" interface="javax.sql.DataSource"/>


How can I use the Gemini JPA EntityManagerFactory service to inject an EntityManager into my Spring POJOs, e.g.:

@PersistenceContext
private EntityManager em;


I've tried the following:

<osgi:reference id="entityManagerFactory"
	    interface="javax.persistence.EntityManagerFactory"
     filter="(osgi.unit.name=MyPU)"
     />


but I'm unsure whether this should work, and where best to configure the DB connection params. I'd rather reference these from my DAO bundle than the persistence unit if possible.

Any pointers, ideas, suggestions gratefully received.

Thanks,

Simon.
Re: Gemini JPA and Spring [message #1001488 is a reply to message #1001421] Wed, 16 January 2013 15:17 Go to previous messageGo to next message
Sebastian Lorenz is currently offline Sebastian Lorenz
Messages: 36
Registered: November 2010
Member
Hi Simon,

as far as I know with Gemini JPA and Gemini DB Access all connection settings have to be configured in the persistence.xml file. E.g:

<persistence xmlns="http://java.sun.com/xml/ns/persistence"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
	version="2.0">
	<persistence-unit name="my.persistence.unit" transaction-type="RESOURCE_LOCAL">
        <class>com.example.persistence.MyEntity</class>
		<properties>
			<property name="javax.persistence.jdbc.user" value="user" />
			<property name="javax.persistence.jdbc.password" value="user_password" />
			<property name="javax.persistence.jdbc.driver" value="org.h2.Driver"/>
			
			<property name="eclipselink.logging.level" value="FINE"/>
		 
		 </properties>
	</persistence-unit>
</persistence>


The MANIFEST.MF of the bundle that contains the persistence.xml must contain the following entry for the bundle to be recognized as a persistence bundle by Gemini JPA:

Meta-Persistence: META-INF/persistence.xml


The Spring configuration for your service bundle may look like this:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:osgi="http://www.springframework.org/schema/osgi" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns:aop="http://www.springframework.org/schema/aop"
	xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
        http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
        
    <osgi:reference id="entityManagerFactory"
		interface="javax.persistence.EntityManagerFactory" filter="(osgi.unit.name=my.persistence.unit)" />
		
	<osgi:reference id="transactionManager" interface="org.springframework.transaction.support.ResourceTransactionManager" />
	
	<tx:annotation-driven />
	
	<bean
		class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />

	<bean id="myService"
        class="com.example.impl.MyServiceImpl"/>
		
	<osgi:service ref="myService"
		interface="com.example.impl.MyService" />
	
</beans>


The PersistenceAnnotationBeanPostProcessor will make sure that the PersistenceContext is injected in your service and <tx:annotation-driven /> will make sure that all methods that are annotated with @Transactional will be executed within a transaction. Hope this helps.
Re: Gemini JPA and Spring [message #1001906 is a reply to message #1001421] Thu, 17 January 2013 09:40 Go to previous messageGo to next message
Simon Watson is currently offline Simon Watson
Messages: 30
Registered: September 2011
Member
Thanks for your reply, that makes sense. Are you using Gemini DBAccess/JPA? Also, what app server do you use?

So far, on Virgo 3.6 I'm seeing a strange problem when I deploy a simple Virgo plan with the required Gemini bundles and a test bundle with a persistence unit. Virgo goes into a loop, starting and stopping my plan hundreds of times:

[2013-01-17 14:33:48.481] startup-tracker              <KE0001I> Kernel starting. 
[2013-01-17 14:33:50.207] startup-tracker              <KE0002I> Kernel started. 
[2013-01-17 14:33:50.402] system-artifacts             <DE0000I> Installing plan 'org.eclipse.virgo.kernel.userregion.blueprint' version '3.6.0'. 
[2013-01-17 14:33:50.524] system-artifacts             <DE0000I> Installing bundle 'org.eclipse.gemini.blueprint.core' version '1.0.2.RELEASE'. 
[2013-01-17 14:33:50.555] system-artifacts             <DE0000I> Installing bundle 'org.eclipse.gemini.blueprint.extender' version '1.0.2.RELEASE'. 
[2013-01-17 14:33:50.570] system-artifacts             <DE0000I> Installing bundle 'org.eclipse.gemini.blueprint.io' version '1.0.2.RELEASE'. 
[2013-01-17 14:33:50.589] system-artifacts             <DE0000I> Installing bundle 'org.eclipse.virgo.kernel.agent.dm' version '3.6.0.RELEASE'. 
[2013-01-17 14:33:50.595] system-artifacts             <DE0000I> Installing bundle 'org.eclipse.virgo.kernel.deployer.dm' version '3.6.0.RELEASE'. 
[2013-01-17 14:33:50.616] system-artifacts             <DE0000I> Installing bundle 'org.eclipse.equinox.ds' version '1.4.0.v20120112-1400'. 
[2013-01-17 14:33:50.637] system-artifacts             <DE0000I> Installing bundle 'org.eclipse.equinox.util' version '1.0.300.v20111010-1614'. 
[2013-01-17 14:33:50.640] system-artifacts             <DE0000I> Installing configuration 'osgi.console' version '0.0.0'. 
[2013-01-17 14:33:51.764] system-artifacts             <DE0001I> Installed bundle 'org.eclipse.gemini.blueprint.core' version '1.0.2.RELEASE'. 
[2013-01-17 14:33:51.766] system-artifacts             <DE0001I> Installed bundle 'org.eclipse.gemini.blueprint.extender' version '1.0.2.RELEASE'. 
[2013-01-17 14:33:51.767] system-artifacts             <DE0001I> Installed bundle 'org.eclipse.gemini.blueprint.io' version '1.0.2.RELEASE'. 
[2013-01-17 14:33:51.767] system-artifacts             <DE0001I> Installed bundle 'org.eclipse.virgo.kernel.agent.dm' version '3.6.0.RELEASE'. 
[2013-01-17 14:33:51.768] system-artifacts             <DE0001I> Installed bundle 'org.eclipse.virgo.kernel.deployer.dm' version '3.6.0.RELEASE'. 
[2013-01-17 14:33:51.769] system-artifacts             <DE0001I> Installed bundle 'org.eclipse.equinox.ds' version '1.4.0.v20120112-1400'. 
[2013-01-17 14:33:51.771] system-artifacts             <DE0001I> Installed bundle 'org.eclipse.equinox.util' version '1.0.300.v20111010-1614'. 
[2013-01-17 14:33:51.771] system-artifacts             <DE0001I> Installed configuration 'osgi.console' version '0.0.0'. 
[2013-01-17 14:33:51.772] system-artifacts             <DE0001I> Installed plan 'org.eclipse.virgo.kernel.userregion.blueprint' version '3.6.0'. 
[2013-01-17 14:33:51.798] system-artifacts             <DE0004I> Starting plan 'org.eclipse.virgo.kernel.userregion.blueprint' version '3.6.0'. 
[2013-01-17 14:33:51.804] system-artifacts             <DE0004I> Starting bundle 'org.eclipse.gemini.blueprint.core' version '1.0.2.RELEASE'. 
[2013-01-17 14:33:51.808] start-signalling-1           <DE0005I> Started bundle 'org.eclipse.gemini.blueprint.core' version '1.0.2.RELEASE'. 
[2013-01-17 14:33:51.809] system-artifacts             <DE0004I> Starting bundle 'org.eclipse.gemini.blueprint.extender' version '1.0.2.RELEASE'. 
[2013-01-17 14:33:52.459] system-artifacts             <DE0004I> Starting bundle 'org.eclipse.gemini.blueprint.io' version '1.0.2.RELEASE'. 
[2013-01-17 14:33:52.464] system-artifacts             <DE0004I> Starting bundle 'org.eclipse.virgo.kernel.agent.dm' version '3.6.0.RELEASE'. 
[2013-01-17 14:33:52.470] start-signalling-2           <DE0005I> Started bundle 'org.eclipse.gemini.blueprint.io' version '1.0.2.RELEASE'. 
[2013-01-17 14:33:52.472] system-artifacts             <DE0004I> Starting bundle 'org.eclipse.virgo.kernel.deployer.dm' version '3.6.0.RELEASE'. 
[2013-01-17 14:33:52.474] start-signalling-1           <DE0005I> Started bundle 'org.eclipse.gemini.blueprint.extender' version '1.0.2.RELEASE'. 
[2013-01-17 14:33:52.477] start-signalling-3           <DE0005I> Started bundle 'org.eclipse.virgo.kernel.agent.dm' version '3.6.0.RELEASE'. 
[2013-01-17 14:33:52.480] system-artifacts             <DE0004I> Starting bundle 'org.eclipse.equinox.ds' version '1.4.0.v20120112-1400'. 
[2013-01-17 14:33:52.626] start-signalling-3           <DE0005I> Started bundle 'org.eclipse.equinox.ds' version '1.4.0.v20120112-1400'. 
[2013-01-17 14:33:52.635] system-artifacts             <DE0004I> Starting bundle 'org.eclipse.equinox.util' version '1.0.300.v20111010-1614'. 
[2013-01-17 14:33:52.682] system-artifacts             <DE0004I> Starting configuration 'osgi.console' version '0.0.0'. 
[2013-01-17 14:33:52.693] start-signalling-3           <DE0005I> Started bundle 'org.eclipse.equinox.util' version '1.0.300.v20111010-1614'. 
[2013-01-17 14:33:52.700] system-artifacts             <DE0005I> Started configuration 'osgi.console' version '0.0.0'. 
[2013-01-17 14:33:52.735] start-signalling-3           <DE0005I> Started bundle 'org.eclipse.virgo.kernel.deployer.dm' version '3.6.0.RELEASE'. 
[2013-01-17 14:33:52.737] start-signalling-3           <DE0005I> Started plan 'org.eclipse.virgo.kernel.userregion.blueprint' version '3.6.0'. 
[2013-01-17 14:33:52.884] system-artifacts             <DE0000I> Installing plan 'org.eclipse.virgo.web.tomcat' version '3.6.0'. 
[2013-01-17 14:33:52.886] system-artifacts             <DE0000I> Installing configuration 'org.eclipse.virgo.web' version '0.0.0'. 
[2013-01-17 14:33:52.893] system-artifacts             <DE0000I> Installing bundle 'org.eclipse.virgo.web.spring.integration' version '3.6.0.RELEASE'. 
[2013-01-17 14:33:52.922] system-artifacts             <DE0000I> Installing bundle 'org.eclipse.gemini.web.core' version '2.2.0.RELEASE'. 
[2013-01-17 14:33:52.963] system-artifacts             <DE0000I> Installing bundle 'org.eclipse.gemini.web.tomcat' version '2.2.0.RELEASE'. 
[2013-01-17 14:33:52.974] system-artifacts             <DE0000I> Installing bundle 'org.eclipse.virgo.web.core' version '3.6.0.RELEASE'. 
[2013-01-17 14:33:52.979] system-artifacts             <DE0000I> Installing bundle 'org.eclipse.virgo.web.dm' version '3.6.0.RELEASE'. 
[2013-01-17 14:33:52.987] system-artifacts             <DE0000I> Installing bundle 'org.eclipse.virgo.web.tomcat.support' version '3.6.0.RELEASE'. 
[2013-01-17 14:33:52.991] system-artifacts             <DE0000I> Installing bundle 'org.eclipse.virgo.web.servlet.adapter' version '3.6.0.RELEASE'. 
[2013-01-17 14:33:53.585] system-artifacts             <DE0001I> Installed configuration 'org.eclipse.virgo.web' version '0.0.0'. 
[2013-01-17 14:33:53.586] system-artifacts             <DE0001I> Installed bundle 'org.eclipse.virgo.web.spring.integration' version '3.6.0.RELEASE'. 
[2013-01-17 14:33:53.587] system-artifacts             <DE0001I> Installed bundle 'org.eclipse.gemini.web.core' version '2.2.0.RELEASE'. 
[2013-01-17 14:33:53.588] system-artifacts             <DE0001I> Installed bundle 'org.eclipse.gemini.web.tomcat' version '2.2.0.RELEASE'. 
[2013-01-17 14:33:53.589] system-artifacts             <DE0001I> Installed bundle 'org.eclipse.virgo.web.core' version '3.6.0.RELEASE'. 
[2013-01-17 14:33:53.590] system-artifacts             <DE0001I> Installed bundle 'org.eclipse.virgo.web.dm' version '3.6.0.RELEASE'. 
[2013-01-17 14:33:53.591] system-artifacts             <DE0001I> Installed bundle 'org.eclipse.virgo.web.tomcat.support' version '3.6.0.RELEASE'. 
[2013-01-17 14:33:53.592] system-artifacts             <DE0001I> Installed bundle 'org.eclipse.virgo.web.servlet.adapter' version '3.6.0.RELEASE'. 
[2013-01-17 14:33:53.593] system-artifacts             <DE0001I> Installed plan 'org.eclipse.virgo.web.tomcat' version '3.6.0'. 
[2013-01-17 14:33:53.606] system-artifacts             <DE0004I> Starting plan 'org.eclipse.virgo.web.tomcat' version '3.6.0'. 
[2013-01-17 14:33:53.606] system-artifacts             <DE0004I> Starting configuration 'org.eclipse.virgo.web' version '0.0.0'. 
[2013-01-17 14:33:53.609] system-artifacts             <DE0005I> Started configuration 'org.eclipse.virgo.web' version '0.0.0'. 
[2013-01-17 14:33:53.611] system-artifacts             <DE0005I> Started bundle 'org.eclipse.virgo.web.spring.integration' version '3.6.0.RELEASE'. 
[2013-01-17 14:33:53.613] system-artifacts             <DE0004I> Starting bundle 'org.eclipse.gemini.web.core' version '2.2.0.RELEASE'. 
[2013-01-17 14:33:53.627] start-signalling-3           <DE0005I> Started bundle 'org.eclipse.gemini.web.core' version '2.2.0.RELEASE'. 
[2013-01-17 14:33:53.628] system-artifacts             <DE0004I> Starting bundle 'org.eclipse.gemini.web.tomcat' version '2.2.0.RELEASE'. 
[2013-01-17 14:33:54.444] system-artifacts             <TC0000I> Starting Tomcat. 
[2013-01-17 14:33:54.490] system-artifacts             <TC0010I> Creating HTTP/1.1 connector with scheme http on port 8080. 
[2013-01-17 14:33:54.508] system-artifacts             <TC0010I> Creating HTTP/1.1 connector with scheme https on port 8443. 
[2013-01-17 14:33:54.516] system-artifacts             <TC0010I> Creating AJP/1.3 connector with scheme http on port 8009. 
[2013-01-17 14:33:54.519] system-artifacts             <TC0001I> Started Tomcat. 
[2013-01-17 14:33:54.544] system-artifacts             <DE0004I> Starting bundle 'org.eclipse.virgo.web.core' version '3.6.0.RELEASE'. 
[2013-01-17 14:33:54.566] system-artifacts             <DE0004I> Starting bundle 'org.eclipse.virgo.web.dm' version '3.6.0.RELEASE'. 
[2013-01-17 14:33:54.572] system-artifacts             <DE0005I> Started bundle 'org.eclipse.virgo.web.tomcat.support' version '3.6.0.RELEASE'. 
[2013-01-17 14:33:54.574] system-artifacts             <DE0004I> Starting bundle 'org.eclipse.virgo.web.servlet.adapter' version '3.6.0.RELEASE'. 
[2013-01-17 14:33:54.577] start-signalling-3           <DE0005I> Started bundle 'org.eclipse.virgo.web.dm' version '3.6.0.RELEASE'. 
[2013-01-17 14:33:54.578] start-signalling-1           <DE0005I> Started bundle 'org.eclipse.virgo.web.servlet.adapter' version '3.6.0.RELEASE'. 
[2013-01-17 14:33:54.696] start-signalling-1           <DE0005I> Started bundle 'org.eclipse.gemini.web.tomcat' version '2.2.0.RELEASE'. 
[2013-01-17 14:33:54.718] start-signalling-1           <DE0005I> Started bundle 'org.eclipse.virgo.web.core' version '3.6.0.RELEASE'. 
[2013-01-17 14:33:54.720] start-signalling-1           <DE0005I> Started plan 'org.eclipse.virgo.web.tomcat' version '3.6.0'. 
[2013-01-17 14:33:54.788] system-artifacts             <DE0000I> Installing configuration 'org.eclipse.virgo.apps.repository' version '0.0.0'. 
[2013-01-17 14:33:54.802] system-artifacts             <DE0001I> Installed configuration 'org.eclipse.virgo.apps.repository' version '0.0.0'. 
[2013-01-17 14:33:54.806] system-artifacts             <DE0004I> Starting configuration 'org.eclipse.virgo.apps.repository' version '0.0.0'. 
[2013-01-17 14:33:54.810] system-artifacts             <DE0005I> Started configuration 'org.eclipse.virgo.apps.repository' version '0.0.0'. 
[2013-01-17 14:33:54.889] system-artifacts             <DE0000I> Installing plan 'org.eclipse.virgo.management' version '3.6.0'. 
[2013-01-17 14:33:54.958] system-artifacts             <DE0000I> Installing bundle 'osgi.enterprise' version '4.2.0.v201108120515'. 
[2013-01-17 14:33:54.981] system-artifacts             <DE0000I> Installing bundle 'org.eclipse.gemini.management' version '1.0.5.RELEASE'. 
[2013-01-17 14:33:54.988] system-artifacts             <DE0000I> Installing bundle 'org.eclipse.virgo.management.fragment' version '3.6.0.RELEASE'. 
[2013-01-17 14:33:55.079] system-artifacts             <DE0001I> Installed bundle 'osgi.enterprise' version '4.2.0.v201108120515'. 
[2013-01-17 14:33:55.081] system-artifacts             <DE0001I> Installed bundle 'org.eclipse.gemini.management' version '1.0.5.RELEASE'. 
[2013-01-17 14:33:55.083] system-artifacts             <DE0001I> Installed bundle 'org.eclipse.virgo.management.fragment' version '3.6.0.RELEASE'. 
[2013-01-17 14:33:55.085] system-artifacts             <DE0001I> Installed plan 'org.eclipse.virgo.management' version '3.6.0'. 
[2013-01-17 14:33:55.098] system-artifacts             <DE0004I> Starting plan 'org.eclipse.virgo.management' version '3.6.0'. 
[2013-01-17 14:33:55.101] system-artifacts             <DE0004I> Starting bundle 'osgi.enterprise' version '4.2.0.v201108120515'. 
[2013-01-17 14:33:55.103] start-signalling-1           <DE0005I> Started bundle 'osgi.enterprise' version '4.2.0.v201108120515'. 
[2013-01-17 14:33:55.105] system-artifacts             <DE0004I> Starting bundle 'org.eclipse.gemini.management' version '1.0.5.RELEASE'. 
[2013-01-17 14:33:55.123] start-signalling-1           <DE0005I> Started bundle 'org.eclipse.gemini.management' version '1.0.5.RELEASE'. 
[2013-01-17 14:33:55.126] system-artifacts             <DE0005I> Started bundle 'org.eclipse.virgo.management.fragment' version '3.6.0.RELEASE'. 
[2013-01-17 14:33:55.128] system-artifacts             <DE0005I> Started plan 'org.eclipse.virgo.management' version '3.6.0'. 
[2013-01-17 14:33:55.131] sync Event Dispatcher Thread <UR0001I> User region ready. 
[2013-01-17 14:33:55.134] startup-readiness            <KE0007I> Virgo ready. Started for 8.406s. 
[2013-01-17 14:33:56.136] fs-watcher                   <HD0001I> Hot deployer processing 'INITIAL' event for file 'demo.plan'. 
[2013-01-17 14:33:56.200] fs-watcher                   <DE0000I> Installing plan 'my-test.plan' version '1.0.0'. 
[2013-01-17 14:33:56.278] fs-watcher                   <DE0000I> Installing bundle 'my-test.plan-1-com.springsource.com.mysql.jdbc' version '5.1.6'. 
[2013-01-17 14:33:56.287] fs-watcher                   <DE0000I> Installing bundle 'my-test.plan-1-org.eclipse.gemini.dbaccess.mysql' version '1.1.0.RC1'. 
[2013-01-17 14:33:56.313] fs-watcher                   <DE0000I> Installing bundle 'my-test.plan-1-org.eclipse.gemini.jpa' version '1.1.0.RELEASE'. 
[2013-01-17 14:33:56.319] fs-watcher                   <DE0000I> Installing bundle 'my-test.plan-1-foo.test.pu' version '1.0.1'. 
[2013-01-17 14:33:56.465] fs-watcher                   <DE0001I> Installed bundle 'my-test.plan-1-com.springsource.com.mysql.jdbc' version '5.1.6'. 
[2013-01-17 14:33:56.466] fs-watcher                   <DE0001I> Installed bundle 'my-test.plan-1-org.eclipse.gemini.dbaccess.mysql' version '1.1.0.RC1'. 
[2013-01-17 14:33:56.471] fs-watcher                   <DE0001I> Installed bundle 'my-test.plan-1-org.eclipse.gemini.jpa' version '1.1.0.RELEASE'. 
[2013-01-17 14:33:56.476] fs-watcher                   <DE0001I> Installed bundle 'my-test.plan-1-foo.test.pu' version '1.0.1'. 
[2013-01-17 14:33:56.478] fs-watcher                   <DE0001I> Installed bundle 'my-test.plan-1-synthetic.context' version '1.0.0'. 
[2013-01-17 14:33:56.480] fs-watcher                   <DE0001I> Installed plan 'my-test.plan' version '1.0.0'. 
[2013-01-17 14:33:56.498] fs-watcher                   <DE0004I> Starting plan 'my-test.plan' version '1.0.0'. 
[2013-01-17 14:33:56.502] fs-watcher                   <DE0004I> Starting bundle 'my-test.plan-1-com.springsource.com.mysql.jdbc' version '5.1.6'. 
[2013-01-17 14:33:56.505] start-signalling-1           <DE0005I> Started bundle 'my-test.plan-1-com.springsource.com.mysql.jdbc' version '5.1.6'. 
[2013-01-17 14:33:56.510] fs-watcher                   <DE0004I> Starting bundle 'my-test.plan-1-org.eclipse.gemini.dbaccess.mysql' version '1.1.0.RC1'. 
[2013-01-17 14:33:56.521] start-signalling-1           <DE0005I> Started bundle 'my-test.plan-1-org.eclipse.gemini.dbaccess.mysql' version '1.1.0.RC1'. 
[2013-01-17 14:33:56.521] fs-watcher                   <DE0004I> Starting bundle 'my-test.plan-1-org.eclipse.gemini.jpa' version '1.1.0.RELEASE'. 
[2013-01-17 14:33:56.565] start-signalling-1           <DE0005I> Started bundle 'my-test.plan-1-org.eclipse.gemini.jpa' version '1.1.0.RELEASE'. 
[2013-01-17 14:33:56.577] fs-watcher                   <DE0004I> Starting bundle 'my-test.plan-1-foo.test.pu' version '1.0.1'. 
[2013-01-17 14:33:56.587] Refresh Packages             <DE0010I> Stopping bundle 'my-test.plan-1-foo.test.pu' version '1.0.1'. 
[2013-01-17 14:33:56.589] start-signalling-1           <DE0005I> Started bundle 'my-test.plan-1-foo.test.pu' version '1.0.1'. 
[2013-01-17 14:33:56.590] Refresh Packages             <DE0010I> Stopping plan 'my-test.plan' version '1.0.0'. 
[2013-01-17 14:33:56.593] Refresh Packages             <DE0010I> Stopping bundle 'my-test.plan-1-com.springsource.com.mysql.jdbc' version '5.1.6'. 
[2013-01-17 14:33:56.594] Refresh Packages             <DE0011I> Stopped bundle 'my-test.plan-1-com.springsource.com.mysql.jdbc' version '5.1.6'. 
[2013-01-17 14:33:56.597] Refresh Packages             <DE0010I> Stopping bundle 'my-test.plan-1-org.eclipse.gemini.dbaccess.mysql' version '1.1.0.RC1'. 
[2013-01-17 14:33:56.599] Refresh Packages             <DE0011I> Stopped bundle 'my-test.plan-1-org.eclipse.gemini.dbaccess.mysql' version '1.1.0.RC1'. 
[2013-01-17 14:33:56.602] Refresh Packages             <DE0010I> Stopping bundle 'my-test.plan-1-org.eclipse.gemini.jpa' version '1.1.0.RELEASE'. 
[2013-01-17 14:33:56.607] Refresh Packages             <DE0011I> Stopped bundle 'my-test.plan-1-org.eclipse.gemini.jpa' version '1.1.0.RELEASE'. 
[2013-01-17 14:33:56.609] Refresh Packages             <DE0011I> Stopped plan 'my-test.plan' version '1.0.0'. 
[2013-01-17 14:33:56.610] Refresh Packages             <DE0011I> Stopped bundle 'my-test.plan-1-foo.test.pu' version '1.0.1'. 
[2013-01-17 14:33:56.618] Refresh Packages             <DE0004I> Starting bundle 'my-test.plan-1-foo.test.pu' version '1.0.1'. 
[2013-01-17 14:33:56.623] start-signalling-1           <DE0005I> Started bundle 'my-test.plan-1-foo.test.pu' version '1.0.1'. 
[2013-01-17 14:33:56.626] fs-watcher                   <DE0004I> Starting plan 'my-test.plan' version '1.0.0'. 
[2013-01-17 14:33:56.629] fs-watcher                   <DE0004I> Starting bundle 'my-test.plan-1-com.springsource.com.mysql.jdbc' version '5.1.6'. 
[2013-01-17 14:33:56.637] start-signalling-1           <DE0005I> Started bundle 'my-test.plan-1-com.springsource.com.mysql.jdbc' version '5.1.6'. 
[2013-01-17 14:33:56.647] fs-watcher                   <DE0004I> Starting bundle 'my-test.plan-1-org.eclipse.gemini.dbaccess.mysql' version '1.1.0.RC1'. 
[2013-01-17 14:33:56.650] start-signalling-1           <DE0005I> Started bundle 'my-test.plan-1-org.eclipse.gemini.dbaccess.mysql' version '1.1.0.RC1'. 
[2013-01-17 14:33:56.653] fs-watcher                   <DE0004I> Starting bundle 'my-test.plan-1-org.eclipse.gemini.jpa' version '1.1.0.RELEASE'. 
[2013-01-17 14:33:56.665] start-signalling-1           <DE0005I> Started bundle 'my-test.plan-1-org.eclipse.gemini.jpa' version '1.1.0.RELEASE'. 
[2013-01-17 14:33:56.669] fs-watcher                   <DE0004I> Starting bundle 'my-test.plan-1-synthetic.context' version '1.0.0'. 
[2013-01-17 14:33:56.672] Refresh Packages             <DE0010I> Stopping bundle 'my-test.plan-1-synthetic.context' version '1.0.0'. 
[2013-01-17 14:33:56.674] fs-watcher                   <HD0001I> Hot deployer processing 'INITIAL' event for file 'org.eclipse.virgo.apps.repository_3.6.0.RELEASE.par'. 
[2013-01-17 14:33:56.674] start-signalling-3           <DE0005I> Started bundle 'my-test.plan-1-synthetic.context' version '1.0.0'. 
[2013-01-17 14:33:56.677] start-signalling-1           <DE0005I> Started bundle 'my-test.plan-1-synthetic.context' version '1.0.0'. 
[2013-01-17 14:33:56.677] Refresh Packages             <DE0010I> Stopping plan 'my-test.plan' version '1.0.0'. 
[2013-01-17 14:33:56.678] start-signalling-1           <DE0005I> Started plan 'my-test.plan' version '1.0.0'. 
[2013-01-17 14:33:56.679] Refresh Packages             <DE0010I> Stopping bundle 'my-test.plan-1-com.springsource.com.mysql.jdbc' version '5.1.6'. 
[2013-01-17 14:33:56.681] Refresh Packages             <DE0010I> Stopping plan 'my-test.plan' version '1.0.0'. 
[2013-01-17 14:33:56.684] Refresh Packages             <DE0010I> Stopping bundle 'my-test.plan-1-org.eclipse.gemini.dbaccess.mysql' version '1.1.0.RC1'. 
[2013-01-17 14:33:56.694] Refresh Packages             <DE0011I> Stopped bundle 'my-test.plan-1-org.eclipse.gemini.dbaccess.mysql' version '1.1.0.RC1'. 
[2013-01-17 14:33:56.696] Refresh Packages             <DE0010I> Stopping bundle 'my-test.plan-1-org.eclipse.gemini.jpa' version '1.1.0.RELEASE'. 
[2013-01-17 14:33:56.700] Refresh Packages             <DE0011I> Stopped bundle 'my-test.plan-1-org.eclipse.gemini.jpa' version '1.1.0.RELEASE'. 
[2013-01-17 14:33:56.702] Refresh Packages             <DE0010I> Stopping bundle 'my-test.plan-1-foo.test.pu' version '1.0.1'. 
[2013-01-17 14:33:56.704] Refresh Packages             <DE0011I> Stopped bundle 'my-test.plan-1-foo.test.pu' version '1.0.1'. 
[2013-01-17 14:33:56.706] Refresh Packages             <DE0011I> Stopped plan 'my-test.plan' version '1.0.0'. 
[2013-01-17 14:33:56.707] Refresh Packages             <DE0011I> Stopped bundle 'my-test.plan-1-com.springsource.com.mysql.jdbc' version '5.1.6'. 
[2013-01-17 14:33:56.708] Refresh Packages             <DE0011I> Stopped bundle 'my-test.plan-1-synthetic.context' version '1.0.0'. 


My plan is:

<?xml version="1.0" encoding="UTF-8"?>
<plan name="my-test.plan" version="1.0.0" scoped="true" atomic="true"
        xmlns="http://www.eclipse.org/virgo/schema/plan"
		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xsi:schemaLocation="
		        http://www.eclipse.org/virgo/schema/plan
		        http://www.eclipse.org/virgo/schema/plan/eclipse-virgo-plan.xsd">

    <artifact type="bundle" name="com.springsource.com.mysql.jdbc" />
    <artifact type="bundle" name="org.eclipse.gemini.dbaccess.mysql" />
    <artifact type="bundle" name="org.eclipse.gemini.jpa" />
     
     <artifact type="bundle" name="foo.test.pu" />
</plan> 



My test PU bundle manifest:

Manifest-Version: 1.0
Bundle-Version: 1.0.1
Bundle-Name: PayLiquid Domain Model
Bundle-ManifestVersion: 2
Bundle-SymbolicName: foo.test.pu
Meta-Persistence: 
Export-Package: model.configadmin;version="1.1.0"
Import-Package: javax.persistence;version="[2.0.4,2.0.4]";jpa="2.0",
 javax.persistence.criteria;version="[2.0.4,2.0.4]";jpa="2.0",
 javax.persistence.metamodel;version="[2.0.4,2.0.4]";jpa="2.0",
 org.osgi.framework;version="[1.7.0,1.7.0]",
 org.osgi.service.jpa;version="[1.0.0,1.0.0]"


and persistence.xml (based on org.eclipse.gemini.jpa.sample.configadmin.pu-1.1.0.RELEASE):

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" 
    xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">

    <persistence-unit name="Library" transaction-type="RESOURCE_LOCAL">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>

        <class>model.configadmin.Library</class>
        <class>model.configadmin.Book</class>

        <exclude-unlisted-classes>true</exclude-unlisted-classes>
        <properties>
			<property name="eclipselink.weaving" value="static"/>
			<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
			<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/test" />
			<property name="javax.persistence.jdbc.user" value="test" />
			<property name="javax.persistence.jdbc.password" value="test" />
		</properties>
    </persistence-unit>
</persistence>
Re: Gemini JPA and Spring [message #1001934 is a reply to message #1001906] Thu, 17 January 2013 10:27 Go to previous messageGo to next message
Sebastian Lorenz is currently offline Sebastian Lorenz
Messages: 36
Registered: November 2010
Member
I'm using Gemini JPA and DBAccess with Blueprint in a standalone eclipse rcp application. I've no concept of Virgo. Did you try the Virgo forum?
Re: Gemini JPA and Spring [message #1001979 is a reply to message #1001906] Thu, 17 January 2013 11:35 Go to previous messageGo to next message
Mike Keith is currently offline Mike Keith
Messages: 207
Registered: July 2009
Senior Member
Hi Simon,

Did you try setting the NO REFRESH option?
See http://wiki.eclipse.org/Gemini/JPA/Documentation/OtherTopics#Refreshing

-Mike
Re: Gemini JPA and Spring [message #1001992 is a reply to message #1001979] Thu, 17 January 2013 12:09 Go to previous messageGo to next message
Simon Watson is currently offline Simon Watson
Messages: 30
Registered: September 2011
Member
Yes, I saw that and tried starting Virgo as "startup.sh DREFRESH_BUNDLES=FALSE" but it didn't change the behaviour. I also tried changing the eclipselink.weaving property to false.

If I remove the persistence unit bundle from the plan, then the plan starts normally.
Re: Gemini JPA and Spring [message #1002022 is a reply to message #1001992] Thu, 17 January 2013 13:59 Go to previous messageGo to next message
Mike Keith is currently offline Mike Keith
Messages: 207
Registered: July 2009
Senior Member
Not sure what command line is in startup.sh, but you may want to put -DREFRESH_BUNDLES=FALSE where you invoke java. Set the Gemini debug flag (-DGEMINI_DEBUG=true) to let you see the tracing and you can ensure that the refresh is disabled (i.e. that the bundle is not refreshed).

-Mike
Re: Gemini JPA and Spring [message #1002087 is a reply to message #1002022] Thu, 17 January 2013 17:49 Go to previous messageGo to next message
Simon Watson is currently offline Simon Watson
Messages: 30
Registered: September 2011
Member
Hi Mike, thanks for your help. I couldn't seem to get Virgo to pickup the flags from the startup script so I ended up hard-coding them into the script for testing.

The Gemini debug logging didn't give much more detail (to my eyes at least) but did regularly contain the line :
GeminiExtender.refreshBundle:  bundle=my-test.plan-1-foo.test.pu id=145 state=ACTIVE 


The good news is that now the REFRESH_BUNDLES=FALSE flag is taking effect, it behaves normally Razz

What's the downside to having the refresh turned off - that I have to use static weaving?

I've attached the log with Gemini debug output in case anyone can shed more light on the underlying cause.
Re: Gemini JPA and Spring [message #1002369 is a reply to message #1001979] Fri, 18 January 2013 08:26 Go to previous messageGo to next message
Mike Keith is currently offline Mike Keith
Messages: 207
Registered: July 2009
Senior Member
Virgo tries to make the whole plan (application) atomic, so when Gemini JPA refreshes one bundle in the app Virgo will turn around and refresh the entire application. This gets things into an infinite loop and the badness you see is the result.

Yes, static weaving is your best best if you want to turn refreshing off and be confident that weaving is happening. The only other option is if you can control the way that things get resolved and guarantee that Gemini JPA can see the persistence bundles and register the weaving hooks before any of the entity classes get loaded by another bundle.

-Mike
Re: Gemini JPA and Spring [message #1002371 is a reply to message #1002369] Fri, 18 January 2013 08:28 Go to previous messageGo to next message
Mike Keith is currently offline Mike Keith
Messages: 207
Registered: July 2009
Senior Member
BTW, the reason why there is not much debugging info from Gemini JPA is because it barely gets a chance to start up and see its first bundle, which it looks like it refreshes, before it gets restarted, itself.
Re: Gemini JPA and Spring [message #1002384 is a reply to message #1002371] Fri, 18 January 2013 08:40 Go to previous message
Simon Watson is currently offline Simon Watson
Messages: 30
Registered: September 2011
Member
Mike, thanks again for your input and shedding some light on the cause. I'm not sure how I can control the bundle resolution (other than using a plan to control bundle start order) but I can live with static weaving if there's no other impact on disabling refresh.
Previous Topic:Purpose for supporting JTA in Gemini-JPA
Next Topic:Gemini JPA / DBAccess - best way to configure JDBC properties?
Goto Forum:
  


Current Time: Wed Apr 16 09:27:28 EDT 2014

Powered by FUDForum. Page generated in 0.02824 seconds