Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » Conflicts configuring EclipseLink with Virgo
Conflicts configuring EclipseLink with Virgo [message #870388] Mon, 07 May 2012 18:05 Go to next message
taher mosbah is currently offline taher mosbah
Messages: 17
Registered: April 2012
Junior Member
Greetings,
I'm trying to configure EclipseLink OSGi Bundles[I manually upload artifacts to Virgo from the admin console as listed here wiki.eclipse.org/Gemini/JPA/Documentation/Installing] in Virgo 3.0.3(tried newest milestone too), I'm importing org.springframework.orm.jpa in order to define :
	<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">

and javax.persistence;version="2.0.3" from eclipseLink bundles, but this is causing conflicts,
I already came across this bug :
bugs.eclipse.org/bugs/show_bug.cgi?id=337827
but I don't think it's exactly my case.
Here is the stackTrace :
    Resolver report:
        Uses violation: <Import-Package: org.springframework.orm.jpa; version="0.0.0"> in bundle <com.apptivit.biztouch.models_1.0.0[1336427096122]>
            Found conflicts:
                package        'javax.persistence.spi_1.0.0' in bundle 'com.springsource.javax.persistence_1.0.0[83]' used by 'org.springframework.orm.jpa_3.0.5.RELEASE' in bundle 'org.springframework.orm_3.0.5.RELEASE[103]'
                conflicts with 'javax.persistence.spi_2.0.3' in bundle 'javax.persistence_2.0.3.v201010191057[133]' used by 'javax.persistence_2.0.3' in bundle 'javax.persistence_2.0.3.v201010191057[133]'
                package        'javax.persistence_1.0.0' in bundle 'com.springsource.javax.persistence_1.0.0[83]' used by 'org.springframework.orm.jpa_3.0.5.RELEASE' in bundle 'org.springframework.orm_3.0.5.RELEASE[103]'
                conflicts with 'javax.persistence_2.0.3' in bundle 'javax.persistence_2.0.3.v201010191057[133]' imported by bundle 'com.apptivit.biztouch.models_1.0.0[1336427096122]'
                package        'javax.persistence_1.0.0' in bundle 'com.springsource.javax.persistence_1.0.0[83]' used by 'org.springframework.orm.jpa_3.0.5.RELEASE' in bundle 'org.springframework.orm_3.0.5.RELEASE[103]'
                conflicts with 'javax.persistence_2.0.3' in bundle 'javax.persistence_2.0.3.v201010191057[133]' imported by bundle 'com.apptivit.biztouch.models_1.0.0[1336427096122]'

. org.eclipse.virgo.kernel.osgi.framework.UnableToSatisfyBundleDependenciesException: Unable to satisfy dependencies of bundle 'com.apptivit.biztouch.models' at version '1.0.0': Cannot resolve: com.apptivit.biztouch.models
    Resolver report:
        Uses violation: <Import-Package: org.springframework.orm.jpa; version="0.0.0"> in bundle <com.apptivit.biztouch.models_1.0.0[1336427096122]>
            Found conflicts:
                package        'javax.persistence.spi_1.0.0' in bundle 'com.springsource.javax.persistence_1.0.0[83]' used by 'org.springframework.orm.jpa_3.0.5.RELEASE' in bundle 'org.springframework.orm_3.0.5.RELEASE[103]'
                conflicts with 'javax.persistence.spi_2.0.3' in bundle 'javax.persistence_2.0.3.v201010191057[133]' used by 'javax.persistence_2.0.3' in bundle 'javax.persistence_2.0.3.v201010191057[133]'
                package        'javax.persistence_1.0.0' in bundle 'com.springsource.javax.persistence_1.0.0[83]' used by 'org.springframework.orm.jpa_3.0.5.RELEASE' in bundle 'org.springframework.orm_3.0.5.RELEASE[103]'
                conflicts with 'javax.persistence_2.0.3' in bundle 'javax.persistence_2.0.3.v201010191057[133]' imported by bundle 'com.apptivit.biztouch.models_1.0.0[1336427096122]'
                package        'javax.persistence_1.0.0' in bundle 'com.springsource.javax.persistence_1.0.0[83]' used by 'org.springframework.orm.jpa_3.0.5.RELEASE' in bundle 'org.springframework.orm_3.0.5.RELEASE[103]'
                conflicts with 'javax.persistence_2.0.3' in bundle 'javax.persistence_2.0.3.v201010191057[133]' imported by bundle 'com.apptivit.biztouch.models_1.0.0[1336427096122]'


	at org.eclipse.virgo.kernel.install.pipeline.stage.resolve.internal.QuasiResolveStage.process(QuasiResolveStage.java:46)
	at org.eclipse.virgo.kernel.install.pipeline.internal.StandardPipeline.doProcessGraph(StandardPipeline.java:62)
	at org.eclipse.virgo.kernel.install.pipeline.internal.CompensatingPipeline.doProcessGraph(CompensatingPipeline.java:73)
	at org.eclipse.virgo.kernel.install.pipeline.stage.AbstractPipelineStage.process(AbstractPipelineStage.java:41)
	at org.eclipse.virgo.kernel.install.pipeline.internal.StandardPipeline.doProcessGraph(StandardPipeline.java:62)
	at org.eclipse.virgo.kernel.install.pipeline.stage.AbstractPipelineStage.process(AbstractPipelineStage.java:41)
	at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.driveInstallPipeline(PipelinedApplicationDeployer.java:360)
	at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.doInstall(PipelinedApplicationDeployer.java:184)
	at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.install(PipelinedApplicationDeployer.java:139)
	at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.deploy(PipelinedApplicationDeployer.java:252)
	at org.eclipse.virgo.kernel.deployer.management.StandardDeployer.deploy(StandardDeployer.java:52)


My manifest:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: com.apptivit.biztouch.models
Bundle-SymbolicName: com.apptivit.biztouch.models
Bundle-Version: 1.0.0
Bundle-Vendor: Apptiv-IT
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: 
 org.springframework.jdbc,
 org.springframework.stereotype,
 org.springframework.beans.factory.config,
 org.springframework.jdbc.datasource,
 org.springframework.orm.jpa,
 javax.persistence;version="2.0.3"
Export-Package: com.apptivit.biztouch.dao;uses:="com.apptivit.biztouch.models,javax.persistence",
 com.apptivit.biztouch.models
Bundle-ClassPath: .,
 lib/mysql-connector-java.osgi-3.1.14.jar,
 lib/org.springframework.beans_3.0.5.RELEASE.jar,
 lib/eclipselink.jar,
 lib/javax.persistence_2.0.3.v201010191057.jar,
 lib/org.eclipse.persistence.antlr_2.3.2.v20111125-r10461.jar,
 lib/org.eclipse.persistence.asm_2.3.2.v20111125-r10461.jar,
 lib/org.eclipse.persistence.core_2.3.2.v20111125-r10461.jar,
 lib/org.eclipse.persistence.jpa_2.3.2.v20111125-r10461.jar,
 lib/org.eclipse.persistence.jpa.osgi_2.3.2.v20111125-r10461.jar


and my context.xml :
	<bean id="timeLinePostDao" class="com.apptivit.biztouch.dao.TimeLinePostDao"></bean>



	<bean id="entityManagerFactory"
		class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
		<property name="persistenceXmlLocation" value="classpath:META-INF/persistence.xml" />
		<property name="dataSource" ref="dataSource" />
		<property name="persistenceUnitName" value="BiztouchPU" />
		<property name="jpaVendorAdapter" ref="jpaVendorAdapter" />
		<property name="jpaDialect">
			<bean class="org.springframework.orm.jpa.vendor.EclipseLinkJpaDialect" />
		</property>
		<property name="jpaPropertyMap">
			<props>
				<prop key="eclipselink.weaving">false</prop>
			</props>
		</property>
	</bean>

	<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
		<property name="entityManagerFactory" ref="entityManagerFactory" />
	</bean>
	<tx:annotation-driven transaction-manager="transactionManager" />


	<context:component-scan base-package="com.apptivit.biztouch.models" />

	<context:annotation-config />

	<tx:annotation-driven transaction-manager="transactionManager" />

	<bean
		class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />

	<!-- JPA/EclipseLink properties -->
	<bean id="jpaProperties"
		class="org.springframework.beans.factory.config.PropertiesFactoryBean">
		<property name="properties">
			<props>
				<prop key="eclipselink.weaving">false</prop>
			</props>
		</property>
	</bean>

	<bean id="dataSource"
		class="org.springframework.jdbc.datasource.DriverManagerDataSource">
		<property name="driverClassName" value="com.mysql.jdbc.Driver" />
		<property name="url" value="jdbc:mysql://localhost:3306/biztouch" />
		<property name="username" value="root" />
		<property name="password" value="root" />
	</bean>

	<!-- JPA/EclipseLink Vendor -->
	<bean id="jpaVendorAdapter"
		class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter">
		<property name="database" ref="database" />
		<property name="generateDdl" value="false" />
		<property name="showSql" value="true" />
	</bean>
	<bean
		class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />
</beans>



my persistence.xml is working fine with a test class, but I know need to configure the EntityManagerFactory in order to export it as an osgi service(is that the right thing to do), I tried to just export my DAO service, but it's always null in the upper layer.

Thank you for your time.
Re: Conflicts configuring EclipseLink with Virgo [message #870476 is a reply to message #870388] Tue, 08 May 2012 07:36 Go to previous messageGo to next message
Dmitry Sklyut is currently offline Dmitry Sklyut
Messages: 271
Registered: January 2010
Senior Member
This is a chicken and egg problem Smile

The problem here is a that you are packaging bunch of libraries inside your bundle:

Bundle-ClassPath: .,
 lib/mysql-connector-java.osgi-3.1.14.jar,
 lib/org.springframework.beans_3.0.5.RELEASE.jar,
 lib/eclipselink.jar,
 lib/javax.persistence_2.0.3.v201010191057.jar,
 lib/org.eclipse.persistence.antlr_2.3.2.v20111125-r10461.jar,
 lib/org.eclipse.persistence.asm_2.3.2.v20111125-r10461.jar,
 lib/org.eclipse.persistence.core_2.3.2.v20111125-r10461.jar,
 lib/org.eclipse.persistence.jpa_2.3.2.v20111125-r10461.jar,
 lib/org.eclipse.persistence.jpa.osgi_2.3.2.v20111125-r10461.jar


When Virgo starts up it wires org.springframework.orm to the only possible javax.persistence export that it knows about, i.e. v1.0. After that it tries to deploy your bundle, that uses org.springframework.orm that is already wired to v1 of javax.persistence but tries to use it with v2 of javax.persistence. Uses constraint violation.

You should deploy eclipse link as a bundle into repository/usr or repository/ext vs. packaging it inside your own bundle. You should also import org.springframework.beans vs. emmbeding that jar in also. Not sure why you are doing that.

It also looks like you are packaging two versions of eclipselink - both osgified and eclipselink.jar.

Your manifest should look something like this:

Manifest-Version: 1.0
Import-Bundle: org.eclipse.persistence.jpa;version="[2, 3.0.0)",
 org.eclipse.persistence.core;version="[2, 3)"
Import-Package: javax.persistence;jpa="2.0";version="[1.0.0, 3.0.0)",
 javax.persistence.criteria;jpa="2.0";version="[1.0.0, 3.0.0)",
 javax.sql;version="0",
 org.springframework.context.weaving;version="[3.0, 3.1)",
 org.springframework.dao.annotation;version="[3.0, 3.1)",
 org.springframework.orm.jpa;version="[3.0, 3.1)",
 org.springframework.orm.jpa.vendor;version="[3.0,3.1)",
 org.springframework.stereotype;version="[3.0, 3.1)",
 org.springframework.transaction.annotation;version="[3.0, 3.1)",
 org.springframework.transaction.aspectj;version="[3.0, 3.1)"


Above is a snippet of generated MANIFEST.MF from https://github.com/dsklyut/virgo-samples-greenpages
Build the project (see readme) and take a look in solution/greenpages.eclipselink.jpa/src/main/resources/META-INF/MANIFEST.MF.

Depending on the where you get the eclipselink dependencies (I am using maven in the above example), you will need these in repository/usr or repository/ext:

org.eclipse.persistence.asm-2.3.2.jar
javax.persistence-2.0.3.jar
org.eclipse.persistence.core-2.3.2.jar
org.eclipse.persistence.antlr-2.3.2.jar
org.eclipse.persistence.jpa-2.3.2.jar


Dmitry

p.s. [EDIT] if you really really really want to embed eclipselink libraries into your jar - your should re-export eclipselink and javax.persistence packages so other bundles can make use of them or wire properly.

[Updated on: Tue, 08 May 2012 07:39]

Report message to a moderator

Re: Conflicts configuring EclipseLink with Virgo [message #870646 is a reply to message #870476] Wed, 09 May 2012 04:07 Go to previous messageGo to next message
Mohamed Amine Hakouna is currently offline Mohamed Amine Hakouna
Messages: 1
Registered: May 2012
Location: Tunisia
Junior Member

This link may be helpful
njbartlett.name/2011/02/09/uses-constraints.html (can't use links yet)
It explains the theory behind the OSGi "Uses" Constraint Violations


Re: Conflicts configuring EclipseLink with Virgo [message #870679 is a reply to message #870388] Wed, 09 May 2012 06:22 Go to previous messageGo to next message
taher mosbah is currently offline taher mosbah
Messages: 17
Registered: April 2012
Junior Member
Many thanks Dmitry, just followed your advice and it's working great, between greenpages is the most complete example to follow, very helpful even for starters like me.
Re: Conflicts configuring EclipseLink with Virgo [message #870680 is a reply to message #870388] Wed, 09 May 2012 06:23 Go to previous message
taher mosbah is currently offline taher mosbah
Messages: 17
Registered: April 2012
Junior Member
Many thanks Dmitry Sklyut, just followed your advice and it's working great, between greenpages is the most complete example to follow, very helpful even for starters like me.
Previous Topic:Could not use repository chain in new virgo tool
Next Topic:JCE cannot authenticate provider installed as OSGi bundle
Goto Forum:
  


Current Time: Thu Jul 24 19:05:18 EDT 2014

Powered by FUDForum. Page generated in 0.01617 seconds