Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Gemini » Mapping class from another plug-in
Mapping class from another plug-in [message #1016193] Tue, 05 March 2013 12:47 Go to next message
Luiz E. is currently offline Luiz E.Friend
Messages: 100
Registered: September 2010
Senior Member
Hi all
I have a plug-in, which is the core of our app. The plug-in is br.com.germantech.ecf

Now, I made a plug-in, and this plug-in will contribute to our core plug-in. This works fine, he added new menus and everything.
But turns out that this new plug-in will create new tables too...
So, I created a manifest like this

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Germantech - Industria
Bundle-SymbolicName: br.com.germantech.industria;singleton:=true
Bundle-Version: 0.0.1
Bundle-Activator: br.com.germantech.industria.ActivatorIndustria
Bundle-Vendor: German Tech Sistemas
JPA-PersistenceUnits: gtech-industria
Meta-Persistence: META-INF/persistence.xml 
Require-Bundle: org.eclipse.ui,
 org.eclipse.core.runtime,
 javax.persistence;bundle-version="2.0.4",
 org.eclipse.persistence.antlr;bundle-version="3.2.0",
 org.eclipse.persistence.asm;bundle-version="3.3.1",
 org.eclipse.persistence.core;bundle-version="2.4.1",
 org.eclipse.persistence.jpa;bundle-version="2.4.1",
 org.eclipse.persistence.jpa.jpql;bundle-version="2.0.1"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: br.com.germantech.ecf.api,
 br.com.germantech.ecf.aplicacao.helpers,
 br.com.germantech.ecf.dominio.modelo.produto,
 org.postgresql
Bundle-ActivationPolicy: lazy


and created a class like this

package br.com.germantech.industria.dominio.modelo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import br.com.germantech.ecf.dominio.modelo.produto.Produto;

@Entity
public class Producao implements Serializable {
	private static final long serialVersionUID = -4643897338650864928L;
	
	@Id @GeneratedValue(strategy=GenerationType.IDENTITY)
	private Long id;
	
	@Temporal(TemporalType.DATE)
	private Date dataProducao;
	
	@OneToMany
	private List<Produto> produtosFinalizados = new ArrayList<Produto>();

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Date getDataProducao() {
		return dataProducao;
	}

	public void setDataProducao(Date dataProducao) {
		this.dataProducao = dataProducao;
	}
	
	public List<Produto> getProdutosFinalizados() {
		return produtosFinalizados;
	}
	
	public void setProdutosFinalizados(List<Produto> produtosFinalizados) {
		this.produtosFinalizados = produtosFinalizados;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Producao other = (Producao) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}
}


The class Producao is a class from our new plug-in, and the class Produto is a class from our core plug-in...
When I start the plug-ins, I see this:

Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [gtech-industria] failed.
Internal Exception: Exception [EclipseLink-7250] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345): org.eclipse.persistence.exceptions.ValidationException
Exception Description: [class br.com.germantech.industria.dominio.modelo.Producao] uses a non-entity [class br.com.germantech.ecf.dominio.modelo.produto.Produto] as target entity in the relationship attribute [field produtosFinalizados].
	at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:127)
	at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:118)
	at br.com.germantech.industria.infraestrutura.persistencia.GermantechEntityManagerIndustria.init(GermantechEntityManagerIndustria.java:50)
	at br.com.germantech.industria.infraestrutura.persistencia.GermantechEntityManagerIndustria.getEntityManager(GermantechEntityManagerIndustria.java:59)
	at br.com.germantech.industria.ActivatorIndustria.start(ActivatorIndustria.java:31)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
	... 12 more


My question is: how to map a class from one plug-in into another plug-in?
I tried to put Produto into the new plugin's persistence.xml, and that didn't worked too

thanks in advance
Re: Mapping class from another plug-in [message #1016197 is a reply to message #1016193] Tue, 05 March 2013 13:02 Go to previous messageGo to next message
Michael Keith is currently offline Michael KeithFriend
Messages: 243
Registered: July 2009
Senior Member
Hi Luiz,

Unfortunately the OSGi JPA spec does not support entities from different plugins/bundles to be in the same persistence unit, and right now neither does Gemini JPA. There is a feature request entered for it and I hope to be able to add it to the next release.

You might be able to hack around it by duplicating the class in the original bundle so it can be found by EclipseLink at p-unit processing time, and then making it substitutable so the other one is used at runtime. Let me know if this works for you.

Regards,
-Mike
Re: Mapping class from another plug-in [message #1016199 is a reply to message #1016197] Tue, 05 March 2013 13:08 Go to previous messageGo to next message
Luiz E. is currently offline Luiz E.Friend
Messages: 100
Registered: September 2010
Senior Member
Actually, they are not in the same PU. I have a EntityManagerHelper for each plug-in.

this is my MANIFEST.MF from our core plug-in
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
JPA-PersistenceUnits: gtech
Meta-Persistence: META-INF/persistence.xml 
Bundle-Vendor: Germantech Sistemas


as you can see, I have 2 PUs

I didn't understand what you want to say with `duplicating the class in the original bundle so it can be found by EclipseLink at p-unit processing time`. Should I put Producao in the core bundle? is this it?

I tried to put the Produto class into new plugin's persistence.xml, but that didn't worked too...Produto has an embedded class called Log, and EclipseLink says this

Internal Exception: Exception [EclipseLink-7246] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345): org.eclipse.persistence.exceptions.ValidationException
Exception Description: The Entity class [class br.com.germantech.ecf.dominio.modelo.produto.Produto] has an embedded attribute [log] of type [class br.com.germantech.ecf.dominio.compartilhado.Log] which is NOT an Embeddable class. Probable reason: missing @Embeddable or missing <embeddable> in orm.xml if metadata-complete = true
	at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:127)
	at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:118)
	at br.com.germantech.industria.infraestrutura.persistencia.GermantechEntityManagerIndustria.init(GermantechEntityManagerIndustria.java:50)
	at br.com.germantech.industria.infraestrutura.persistencia.GermantechEntityManagerIndustria.getEntityManager(GermantechEntityManagerIndustria.java:59)
	at br.com.germantech.industria.ActivatorIndustria.start(ActivatorIndustria.java:31)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)


but thats the Log class


@Embeddable
public class Log implements Serializable {
	
	private static final long serialVersionUID = -3528343752956930988L;

[Updated on: Tue, 05 March 2013 13:09]

Report message to a moderator

Re: Mapping class from another plug-in [message #1016203 is a reply to message #1016199] Tue, 05 March 2013 13:31 Go to previous messageGo to next message
Michael Keith is currently offline Michael KeithFriend
Messages: 243
Registered: July 2009
Senior Member
If they are in different p-units then it doesn't really matter what I meant above since they are not able to have relationships with each other in any case.

The only way that you can do anything like that is to use the native EclipseLink composite persistence unit feature. That won't work in OSGi, though. Sorry.

-Mike
Re: Mapping class from another plug-in [message #1016204 is a reply to message #1016203] Tue, 05 March 2013 13:33 Go to previous messageGo to next message
Luiz E. is currently offline Luiz E.Friend
Messages: 100
Registered: September 2010
Senior Member
Hmm, I got it Very Happy
last question, so...Is there a way to make the plug-ins share the same PU?
What is composite PU feature? Where can I find more info about this?

Thank you, you really helped me
Re: Mapping class from another plug-in [message #1016342 is a reply to message #1016204] Wed, 06 March 2013 07:04 Go to previous messageGo to next message
Michael Keith is currently offline Michael KeithFriend
Messages: 243
Registered: July 2009
Senior Member
No, that is the feature that is not standardized and not supported in Gemini JPA just yet. Take a look at the EclipseLink doc to find out more about composite p-units if you want to know more.

-Mike
Re: Mapping class from another plug-in [message #1016449 is a reply to message #1016204] Wed, 06 March 2013 13:44 Go to previous messageGo to next message
Sebastian Lorenz is currently offline Sebastian LorenzFriend
Messages: 42
Registered: November 2010
Member
You can easily share the same PU by different plugins if you refer to the same EMF in the blueprint configuration. If both plugins are referencing the EMF like this then the same persistence context will be injected into the beans.

<osgi:reference id="entityManagerFactory"
		interface="javax.persistence.EntityManagerFactory" filter="(osgi.unit.name=myPU)" />
		
	<osgi:reference id="transactionManager" interface="org.springframework.transaction.support.ResourceTransactionManager" />
	
	<bean
	class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
...
Re: Mapping class from another plug-in [message #1016495 is a reply to message #1016449] Wed, 06 March 2013 16:52 Go to previous messageGo to next message
Luiz E. is currently offline Luiz E.Friend
Messages: 100
Registered: September 2010
Senior Member
I'm not using blueprint right now...should i've been using it? is blueprint production-ready?
Can you provide an more detailed example? That would be helpful!

[Updated on: Wed, 06 March 2013 17:06]

Report message to a moderator

Re: Mapping class from another plug-in [message #1016896 is a reply to message #1016449] Fri, 08 March 2013 06:43 Go to previous messageGo to next message
Michael Keith is currently offline Michael KeithFriend
Messages: 243
Registered: July 2009
Senior Member
No, that is just going to get you the same EMF to two different consuming clients, but he is asking for entities to come from different bundles. The JPA provider cannot process a single persistence unit spanning multiple bundles.
Re: Mapping class from another plug-in [message #1016899 is a reply to message #1016896] Fri, 08 March 2013 07:21 Go to previous messageGo to next message
Sebastian Lorenz is currently offline Sebastian LorenzFriend
Messages: 42
Registered: November 2010
Member
Hi Mike,
in my Gemini JPA/Blueprint application I have entities in different (non persistence) bundles. A single persistence bundle requires these bundles and lists the entities in its persistence.xml. This way I've got a single persistence unit spanning multiple bundles.
Using Blueprint other bundles can consume the EMF.
Re: Mapping class from another plug-in [message #1016904 is a reply to message #1016899] Fri, 08 March 2013 07:53 Go to previous messageGo to next message
Michael Keith is currently offline Michael KeithFriend
Messages: 243
Registered: July 2009
Senior Member
Sorry, but I don't see how that will work since from Gemini JPA I only ever pass EclipseLink a classloader that can access a single persistence bundle. That bundle is not resolved yet so it can't see its required bundles and EclipseLink would not be able to access the classes that were not in the persistence bundle.
Re: Mapping class from another plug-in [message #1020452 is a reply to message #1016904] Mon, 18 March 2013 08:05 Go to previous messageGo to next message
Sebastian Lorenz is currently offline Sebastian LorenzFriend
Messages: 42
Registered: November 2010
Member
Hi Mike,

I don't know how it works but it works. I wrote a test application that has a bundle test.p1 containing an entity A. Additionally there is a persistence bundle test.p2 that contains entity B and the following persistence.xml:

<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="com.qualitype.persistence.unit" transaction-type="RESOURCE_LOCAL">
		<class>test.p1.A</class>
		<class>test.p2.B</class>
		<properties>
			<property name="javax.persistence.jdbc.user" value="test" />
			<property name="javax.persistence.jdbc.password" value="test" />
			<property name="javax.persistence.jdbc.driver" value="org.h2.Driver"/>
			<property name="javax.persistence.jdbc.url" value="jdbc:h2:~/test"/>
			
			<property name="eclipselink.logging.level" value="FINE"/>
			<!--  <property name="eclipselink.ddl-generation" value="create-tables"/> -->
			
		 </properties>
	</persistence-unit>
</persistence>


The following output shows that A and B are loaded and A and B entities can be persisted and loaded to/from the databse.

Mrz 18, 2013 8:58:04 AM org.eclipse.gemini.blueprint.extender.internal.boot.ChainActivator <init>
Information: Blueprint API detected; enabling Blueprint Container functionality
Mrz 18, 2013 8:58:04 AM org.eclipse.gemini.blueprint.extender.internal.activator.ContextLoaderListener start
Information: Starting [org.eclipse.gemini.blueprint.extender] bundle v.[1.0.2.RELEASE]
Mrz 18, 2013 8:58:04 AM org.eclipse.gemini.blueprint.extender.internal.support.ExtenderConfiguration <init>
Information: No custom extender configuration detected; using defaults...
Mrz 18, 2013 8:58:04 AM org.springframework.scheduling.timer.TimerTaskExecutor afterPropertiesSet
Information: Initializing Timer
Mrz 18, 2013 8:58:04 AM org.eclipse.gemini.blueprint.extender.internal.activator.ContextLoaderListener start
Information: Starting [org.eclipse.gemini.blueprint.extender] bundle v.[1.0.2.RELEASE]
Mrz 18, 2013 8:58:04 AM org.eclipse.gemini.blueprint.extender.internal.support.ExtenderConfiguration <init>
Information: No custom extender configuration detected; using defaults...
Mrz 18, 2013 8:58:04 AM org.springframework.scheduling.timer.TimerTaskExecutor afterPropertiesSet
Information: Initializing Timer
Mrz 18, 2013 8:58:04 AM org.eclipse.gemini.blueprint.extender.support.DefaultOsgiApplicationContextCreator createApplicationContext
Information: Discovered configurations {osgibundle:/META-INF/spring/*.xml} in bundle [Consumer (test.service)]
Mrz 18, 2013 8:58:04 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh
Information: Refreshing OsgiBundleXmlApplicationContext(bundle=test.service, config=osgibundle:/META-INF/spring/*.xml): startup date [Mon Mar 18 08:58:04 CET 2013]; root of context hierarchy
Mrz 18, 2013 8:58:04 AM org.eclipse.gemini.blueprint.context.support.AbstractOsgiBundleApplicationContext unpublishContextAsOsgiService
Information: Application Context service already unpublished
Mrz 18, 2013 8:58:04 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
Information: Loading XML bean definitions from URL [bundleentry://44.fwk1649854604/META-INF/spring/config.xml]
Mrz 18, 2013 8:58:04 AM org.springframework.beans.factory.support.DefaultListableBeanFactory registerBeanDefinition
Information: Overriding bean definition for bean 'transactionManager': replacing [Generic bean: class [org.eclipse.gemini.blueprint.service.importer.support.OsgiServiceProxyFactoryBean]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] with [Generic bean: class [org.springframework.orm.jpa.JpaTransactionManager]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in URL [bundleentry://44.fwk1649854604/META-INF/spring/config.xml]]
Mrz 18, 2013 8:58:04 AM org.eclipse.gemini.blueprint.extender.internal.dependencies.startup.DependencyServiceManager doFindDependencies
Information: Adding OSGi service dependency for importer [&entityManagerFactory] matching OSGi filter [(&(objectClass=javax.persistence.EntityManagerFactory)(osgi.unit.name=com.qualitype.persistence.unit))]
Mrz 18, 2013 8:58:04 AM org.eclipse.gemini.blueprint.extender.internal.dependencies.startup.DependencyServiceManager findServiceDependencies
Information: OsgiBundleXmlApplicationContext(bundle=test.service, config=osgibundle:/META-INF/spring/*.xml) is waiting for unsatisfied dependencies [[&entityManagerFactory]]
[EL Config]: metadata: 2013-03-18 08:58:04.82--ServerSession(1754576303)--Thread(Thread[Start Level Event Dispatcher,5,main])--The access type for the persistent class [class test.p2.B] is set to [FIELD].
[EL Config]: metadata: 2013-03-18 08:58:04.836--ServerSession(1754576303)--Thread(Thread[Start Level Event Dispatcher,5,main])--The access type for the persistent class [class test.p1.A] is set to [FIELD].
[EL Config]: metadata: 2013-03-18 08:58:04.837--ServerSession(1754576303)--Thread(Thread[Start Level Event Dispatcher,5,main])--The alias name for the entity class [class test.p2.B] is being defaulted to: B.
[EL Config]: metadata: 2013-03-18 08:58:04.838--ServerSession(1754576303)--Thread(Thread[Start Level Event Dispatcher,5,main])--The table name for entity [class test.p2.B] is being defaulted to: B.
[EL Config]: metadata: 2013-03-18 08:58:04.847--ServerSession(1754576303)--Thread(Thread[Start Level Event Dispatcher,5,main])--The column name for element [id] is being defaulted to: ID.
[EL Config]: metadata: 2013-03-18 08:58:04.848--ServerSession(1754576303)--Thread(Thread[Start Level Event Dispatcher,5,main])--The alias name for the entity class [class test.p1.A] is being defaulted to: A.
[EL Config]: metadata: 2013-03-18 08:58:04.848--ServerSession(1754576303)--Thread(Thread[Start Level Event Dispatcher,5,main])--The table name for entity [class test.p1.A] is being defaulted to: A.
[EL Config]: metadata: 2013-03-18 08:58:04.848--ServerSession(1754576303)--Thread(Thread[Start Level Event Dispatcher,5,main])--The column name for element [id] is being defaulted to: ID.
Mrz 18, 2013 8:58:04 AM org.eclipse.gemini.blueprint.extender.internal.dependencies.startup.DependencyServiceManager$DependencyServiceListener serviceChanged
Information: No unsatisfied OSGi service dependencies; completing initialization for OsgiBundleXmlApplicationContext(bundle=test.service, config=osgibundle:/META-INF/spring/*.xml)
Mrz 18, 2013 8:58:04 AM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
Information: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@42610e8: defining beans [entityManagerFactory,transactionManager,org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor#0,org.eclipse.gemini.blueprint.service.exporter.support.OsgiServiceFactoryBean#0,simpleBean,org.eclipse.gemini.blueprint.service.exporter.support.OsgiServiceFactoryBean#1,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor]; root of factory hierarchy
Mrz 18, 2013 8:58:04 AM org.eclipse.gemini.blueprint.service.exporter.support.OsgiServiceFactoryBean registerService
Information: Publishing service under classes [{org.springframework.transaction.support.ResourceTransactionManager}]
Mrz 18, 2013 8:58:04 AM org.eclipse.gemini.blueprint.service.exporter.support.OsgiServiceFactoryBean registerService
Information: Publishing service under classes [{test.consumer.SimpleService}]
[EL Config]: metadata: 2013-03-18 08:58:04.99--ServerSession(1915464807)--Thread(Thread[EclipseGeminiBlueprintExtenderThread-2,5,eclipse-gemini-blueprint-extender[6b9b6541]-threads])--The access type for the persistent class [class test.p2.B] is set to [FIELD].
[EL Config]: metadata: 2013-03-18 08:58:04.991--ServerSession(1915464807)--Thread(Thread[EclipseGeminiBlueprintExtenderThread-2,5,eclipse-gemini-blueprint-extender[6b9b6541]-threads])--The access type for the persistent class [class test.p1.A] is set to [FIELD].
[EL Config]: metadata: 2013-03-18 08:58:04.991--ServerSession(1915464807)--Thread(Thread[EclipseGeminiBlueprintExtenderThread-2,5,eclipse-gemini-blueprint-extender[6b9b6541]-threads])--The alias name for the entity class [class test.p2.B] is being defaulted to: B.
[EL Config]: metadata: 2013-03-18 08:58:04.991--ServerSession(1915464807)--Thread(Thread[EclipseGeminiBlueprintExtenderThread-2,5,eclipse-gemini-blueprint-extender[6b9b6541]-threads])--The table name for entity [class test.p2.B] is being defaulted to: B.
[EL Config]: metadata: 2013-03-18 08:58:04.991--ServerSession(1915464807)--Thread(Thread[EclipseGeminiBlueprintExtenderThread-2,5,eclipse-gemini-blueprint-extender[6b9b6541]-threads])--The column name for element [id] is being defaulted to: ID.
[EL Config]: metadata: 2013-03-18 08:58:04.992--ServerSession(1915464807)--Thread(Thread[EclipseGeminiBlueprintExtenderThread-2,5,eclipse-gemini-blueprint-extender[6b9b6541]-threads])--The alias name for the entity class [class test.p1.A] is being defaulted to: A.
[EL Config]: metadata: 2013-03-18 08:58:04.992--ServerSession(1915464807)--Thread(Thread[EclipseGeminiBlueprintExtenderThread-2,5,eclipse-gemini-blueprint-extender[6b9b6541]-threads])--The table name for entity [class test.p1.A] is being defaulted to: A.
[EL Config]: metadata: 2013-03-18 08:58:04.992--ServerSession(1915464807)--Thread(Thread[EclipseGeminiBlueprintExtenderThread-2,5,eclipse-gemini-blueprint-extender[6b9b6541]-threads])--The column name for element [id] is being defaulted to: ID.
[EL Info]: 2013-03-18 08:58:05.004--ServerSession(1915464807)--Thread(Thread[EclipseGeminiBlueprintExtenderThread-2,5,eclipse-gemini-blueprint-extender[6b9b6541]-threads])--EclipseLink, version: Eclipse Persistence Services - 2.4.1.v20121003-ad44345
[EL Fine]: connection: 2013-03-18 08:58:05.188--Thread(Thread[EclipseGeminiBlueprintExtenderThread-2,5,eclipse-gemini-blueprint-extender[6b9b6541]-threads])--Detected database platform: org.eclipse.persistence.platform.database.H2Platform
[EL Config]: connection: 2013-03-18 08:58:05.252--ServerSession(1915464807)--Connection(82204021)--Thread(Thread[EclipseGeminiBlueprintExtenderThread-2,5,eclipse-gemini-blueprint-extender[6b9b6541]-threads])--connecting(DatabaseLogin(
	platform=>H2Platform
	user name=> "test"
	connector=>JNDIConnector datasource name=>null
))
[EL Config]: connection: 2013-03-18 08:58:05.3--ServerSession(1915464807)--Connection(755003081)--Thread(Thread[EclipseGeminiBlueprintExtenderThread-2,5,eclipse-gemini-blueprint-extender[6b9b6541]-threads])--Connected: jdbc:h2:~/test
	User: TEST
	Database: H2  Version: 1.3.170 (2012-11-30)
	Driver: H2 JDBC Driver  Version: 1.3.170 (2012-11-30)
[EL Config]: connection: 2013-03-18 08:58:05.362--ServerSession(1915464807)--Connection(2003395891)--Thread(Thread[EclipseGeminiBlueprintExtenderThread-2,5,eclipse-gemini-blueprint-extender[6b9b6541]-threads])--connecting(DatabaseLogin(
	platform=>H2Platform
	user name=> "test"
	connector=>JNDIConnector datasource name=>null
))
[EL Config]: connection: 2013-03-18 08:58:05.407--ServerSession(1915464807)--Connection(624834612)--Thread(Thread[EclipseGeminiBlueprintExtenderThread-2,5,eclipse-gemini-blueprint-extender[6b9b6541]-threads])--Connected: jdbc:h2:~/test
	User: TEST
	Database: H2  Version: 1.3.170 (2012-11-30)
	Driver: H2 JDBC Driver  Version: 1.3.170 (2012-11-30)
[EL Info]: connection: 2013-03-18 08:58:05.481--ServerSession(1915464807)--Thread(Thread[EclipseGeminiBlueprintExtenderThread-2,5,eclipse-gemini-blueprint-extender[6b9b6541]-threads])--com.qualitype.persistence.unit_nonJtaDataSource=468112812 login successful


----------------------
Persist A with id d17ebd64-51ad-407a-9d9c-19b870919b9b 


[EL Fine]: sql: 2013-03-18 08:58:05.552--ClientSession(868453000)--Connection(1790705988)--Thread(Thread[EclipseGeminiBlueprintExtenderThread-2,5,eclipse-gemini-blueprint-extender[6b9b6541]-threads])--INSERT INTO A (ID) VALUES (?)
	bind => [d17ebd64-51ad-407a-9d9c-19b870919b9b]


----------------------
The following As could be found in the DB:

[EL Fine]: sql: 2013-03-18 08:58:05.79--ServerSession(1915464807)--Connection(1921614096)--Thread(Thread[EclipseGeminiBlueprintExtenderThread-2,5,eclipse-gemini-blueprint-extender[6b9b6541]-threads])--SELECT ID FROM A
	10a2f926-7ab1-44cc-a21d-5b8ae9f8619a
	9a238d8a-ffaf-4553-b591-fb25f00d5d53
	d17ebd64-51ad-407a-9d9c-19b870919b9b





----------------------
Persist B with id c0a9c7c2-949d-41bf-8f94-f1e924e5a999 


[EL Fine]: sql: 2013-03-18 08:58:05.869--ClientSession(1066799495)--Connection(358143662)--Thread(Thread[EclipseGeminiBlueprintExtenderThread-2,5,eclipse-gemini-blueprint-extender[6b9b6541]-threads])--INSERT INTO B (ID) VALUES (?)
	bind => [c0a9c7c2-949d-41bf-8f94-f1e924e5a999]


----------------------
The following Bs could be found in the DB:

[EL Fine]: sql: 2013-03-18 08:58:05.958--ServerSession(1915464807)--Connection(574180850)--Thread(Thread[EclipseGeminiBlueprintExtenderThread-2,5,eclipse-gemini-blueprint-extender[6b9b6541]-threads])--SELECT ID FROM B
	66f17c7c-25b9-4fa1-8b3e-f278abc807ad
	85ec8721-a1fe-4c80-8d48-efc31169802b
	c0a9c7c2-949d-41bf-8f94-f1e924e5a999



Mrz 18, 2013 8:58:06 AM org.eclipse.gemini.blueprint.context.support.AbstractOsgiBundleApplicationContext publishContextAsOsgiServiceIfNecessary
Information: Publishing application context as OSGi service with properties {org.eclipse.gemini.blueprint.context.service.name=test.service, org.springframework.context.service.name=test.service, Bundle-SymbolicName=test.service, Bundle-Version=1.0.0.qualifier}
Mrz 18, 2013 8:58:06 AM org.eclipse.gemini.blueprint.extender.internal.support.DefaultOsgiBundleApplicationContextListener onOsgiApplicationEvent
Information: Application context successfully refreshed (OsgiBundleXmlApplicationContext(bundle=test.service, config=osgibundle:/META-INF/spring/*.xml))

Re: Mapping class from another plug-in [message #1020714 is a reply to message #1020452] Mon, 18 March 2013 19:45 Go to previous messageGo to next message
Michael Keith is currently offline Michael KeithFriend
Messages: 243
Registered: July 2009
Senior Member
Okay, now you have me interested and curious Smile

1. I don't see Gemini JPA anywhere in the output log. Is it just that you don't have any logging turned on or is the EMF being put in the service registry by somebody else (e.g. BP)?

2. Do you have refreshing disabled? There is also the possibility that you are getting "lucky" and the persistence bundles just happen to have been resolved when Gemini JPA finds out about them but because refreshing is disabled Gemini JPA continues on its merry way and ends up using the resolved bundle.

Could you do me a favour and post the output with Gemini JPA debugging turned on? I would really like to know what is going on there.

Thanks,
-Mike
Re: Mapping class from another plug-in [message #1020933 is a reply to message #1020714] Tue, 19 March 2013 08:10 Go to previous messageGo to next message
Sebastian Lorenz is currently offline Sebastian LorenzFriend
Messages: 42
Registered: November 2010
Member
The attached file contains the console output. Now I have added the following parameters to my start config:

-DGEMINI_DEBUG -DGEMINI_DEBUG_WEAVING -DGEMINI_DEBUG_CLASSLOADER

I had set REFRESH_BUNDLES=FALSE before. Now I removed it and this causes the errors at the end of the log. But everything else is the same.

In the output it seems that the PU is initialized twice. The first time with only entity B which comes from the persistence bundle itself. In this case there is an output "test.p2.B woven by WeavingHookTransformer". The second time when the PU is initialized it is done with A and B but they are never woven?!
Re: Mapping class from another plug-in [message #1028203 is a reply to message #1020933] Thu, 28 March 2013 00:43 Go to previous messageGo to next message
Michael Keith is currently offline Michael KeithFriend
Messages: 243
Registered: July 2009
Senior Member
Hi Sebastian,

It looks like you are getting lucky and the class is being loaded after the bundle has been resolved (the debug shows that there is a bundle
class loader in place).
It may have to do with the fact that so much other stuff is happening (mucho Spring classes getting loaded and so forth) that delays are
being introduced, etc. You seem to be running on 1.0.0, not sure why.

-Mike
Re: Mapping class from another plug-in [message #1028427 is a reply to message #1028203] Thu, 28 March 2013 08:39 Go to previous messageGo to next message
Sebastian Lorenz is currently offline Sebastian LorenzFriend
Messages: 42
Registered: November 2010
Member
Hi, Mike,
I'm wondering if the classes are woven or not? Is ist true that first the classes in the bundle are woven and then the bundle is resolved?
In this case entities that are not in the persistence bundle can never be woven?
Re: Mapping class from another plug-in [message #1028574 is a reply to message #1028427] Thu, 28 March 2013 12:53 Go to previous messageGo to next message
Michael Keith is currently offline Michael KeithFriend
Messages: 243
Registered: July 2009
Senior Member
From the listing that you posted, the trace statements seem to indicate that A is never woven.
You can confirm it, if you like, by executing the following code in your app:

boolean weaved = false;
Class<?>[] clsArray = instanceOfA.getClass().getInterfaces();
for ( Class<?> cls : clsArray) {
    if (cls.toString().equals("org.eclipse.persistence.internal.weaving.PersistenceWeaved")) {
        weaved = true;
        break;
    }
}

The key thing to consider is that the weaving transformer should be registered before the class is accessed/loaded
either by code in the containing bundle (executed post-resolve) or code in some other bundle. The only way to guarantee
this is to cause it to be registered before the bundle is resolved. I am not sure why the double registration of the
transformer is occurring. That should only happen if there is more than one persistence unit defined within the bundle.
It was running on 1.0 and I didn't want to change my code base to use 1.0 so I didn't try to explore it any further.

However, you are correct that it would not be possible to weave the entities that are not in the persistence bundle.
(You got timing-lucky that you were even able to get them to be found at all!)

When I add the feature to permit additional entities in other bundles then it will either be a case of requiring
static weaving or having the persistence bundle reference the other bundles containing the entities and requiring
that the framework admin start them in a specific order.
Re: Mapping class from another plug-in [message #1028872 is a reply to message #1028574] Thu, 28 March 2013 21:39 Go to previous message
Sebastian Lorenz is currently offline Sebastian LorenzFriend
Messages: 42
Registered: November 2010
Member
OK, thanks for your replies.
Previous Topic: Gemini JPA: single persistence bundle too restrictive
Next Topic:ClassCastException when using reference-list ServiceReference
Goto Forum:
  


Current Time: Tue Mar 19 10:26:24 GMT 2024

Powered by FUDForum. Page generated in 0.03452 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top