Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » [Solved] Eclipselink + Karaf + Oracle JDBC(What am I missing ?)
[Solved] Eclipselink + Karaf + Oracle JDBC [message #1132665] Fri, 11 October 2013 09:52 Go to next message
Yann Perey is currently offline Yann PereyFriend
Messages: 4
Registered: October 2013
Junior Member
Hello guys,

I'm trying to create an application running on Karaf 2.3.3 with the following modules

  1. Promotion Apis
  2. Promotion Persistence
  3. Promotion Oracle Datasource

Seems quite simple huh ? but in fact I got some issues making it working.

Karaf 2.3.3 configuration

I've installed manually the following features and modules:

>features:install webconsole
>features:install jndi
>features:install transaction
>features:install jpa

Install the oracle JDBC driver uploaded on our own nexus repository:
>osgi:install -s 'wrap:mvn:com.oracle/ojdbc6/11.2.0$Bundle-SymbolicName=Oracle-JDBC-Driver&Bundle-Version=11.2.0'

Install Eclipselink needed modules
>osgi:install -s mvn:org.eclipse.persistence/javax.persistence/2.1.0
>osgi:install -s mvn:org.eclipse.persistence/org.eclipse.persistence.antlr/2.5.0
>osgi:install -s mvn:org.eclipse.persistence/org.eclipse.persistence.asm/2.5.0
>osgi:install -s mvn:org.eclipse.persistence/org.eclipse.persistence.core/2.5.0
>osgi:install -s mvn:org.eclipse.persistence/org.eclipse.persistence.jpa.jpql/2.5.0
>osgi:install -s mvn:org.eclipse.persistence/org.eclipse.persistence.jpa/2.5.0

Promotion Apis module

Sources:
-Promotion.java (interface)
-PromotionPersistenceService (interface)

pom.xml
<project xmlns="htp://maven.apache.org/POM/4.0.0" xmlns:xsi="htp://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="htp://maven.apache.org/POM/4.0.0 htp://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  
  <parent>
    <groupId>com.test.oms</groupId>
    <artifactId>OMS</artifactId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>
  
  <groupId>com.test.oms.promotion.api</groupId>
  <artifactId>promotion.apis</artifactId>
	
  <name>OMS :: PROMOTION APIS</name>
  <description>The Promotion APIs</description>
  
  <packaging>bundle</packaging>
  
  <build>
        <finalName>${project.artifactId}-${project.version}</finalName>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>${maven-compiler-plugin.version}</version>
				<configuration>
					<source>${source.java.compliancy.version}</source>
					<target>${target.java.compliancy.version}</target>
				</configuration>
			</plugin>
		
		     <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>${maven-bundle-plugin.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                        <Bundle-Name>${project.name}</Bundle-Name>
                        <Bundle-Version>${project.version}</Bundle-Version>
			<Export-Package>com.test.oms.promotion.api,com.test.oms.promotion.persistence</Export-Package>
                    </instructions>
                </configuration>
            </plugin>
		</plugins>
	</build>
  
</project>


Promotion Oracle Datasource module

Sources: None
Ressources: OSGI-INF/blueprint/blueprint.xml
<blueprint xmlns="htp://www.osgi.org/xmlns/blueprint/v1.0.0">

	<bean id="oracleDataSource" class="oracle.jdbc.pool.OracleDataSource">
		<property name="URL" value="jdbc:oracle:thin:@localhost:1521:orcl"/>
		<property name="user" value="test"/>
		<property name="password" value="test"/>
	</bean>
  
	<service interface="javax.sql.DataSource" ref="oracleDataSource">
    	<service-properties>
            <entry key="osgi.jndi.service.name" value="jdbc/oracleds"/>
            <entry key="datasource.name" value="OracleDS"/>
    	</service-properties>
  	</service>
	
</blueprint>


pom.xml
<project xmlns="htp://maven.apache.org/POM/4.0.0" xmlns:xsi="htp://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="htp://maven.apache.org/POM/4.0.0 htp://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
  
	<parent>
		<groupId>com.test.oms</groupId>
		<artifactId>OMS</artifactId>
		<version>0.0.1-SNAPSHOT</version>
	</parent>
  
	<groupId>com.test.oms.promotion.datasource</groupId>
	<artifactId>promotion.datasource.oracle</artifactId>
  
	<name>OMS :: ORACLE DATASOURCE</name>
	<description>The Oracle datasource for the OMS project</description>
  
	<packaging>bundle</packaging>
  
	<build>
        <finalName>${project.artifactId}-${project.version}</finalName>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>${maven-compiler-plugin.version}</version>
				<configuration>
					<source>${source.java.compliancy.version}</source>
					<target>${target.java.compliancy.version}</target>
				</configuration>
			</plugin>
		
		     <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>${maven-bundle-plugin.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                        <Bundle-Name>${project.name}</Bundle-Name>
                        <Bundle-Version>${project.version}</Bundle-Version>
			<Bundle-Blueprint>OSGI-INF/blueprint/*.xml</Bundle-Blueprint>
			<Import-Package>javax.sql,oracle.jdbc.pool</Import-Package>
                    </instructions>
                </configuration>
            </plugin>
		</plugins>
	</build>
	
	<dependencies>
        	<dependency>
  			<groupId>com.oracle</groupId>
  			<artifactId>ojdbc6</artifactId>
            		<version>11.2.0</version>
        	</dependency>
	</dependencies>
	
</project>


Promotion Persistence module

Sources:
- PromotionImpl.java (implementation class)
- PromotionPersistenceServiceImpl (implementation class)
Resources:
- META-INF/persistence.xml
<persistence xmlns="htp://java.sun.com/xml/ns/persistence" xmlns:xsi="htp://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="htp://java.sun.com/xml/ns/persistence htp://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" version="2.0">
	<persistence-unit name="oms" transaction-type="JTA">
		<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
		<non-jta-data-source>
			osgi:service/jdbc/oracleds
		</non-jta-data-source>
		<class>com.test.oms.promotion.impl.PromotionImpl</class>
		<exclude-unlisted-classes>true</exclude-unlisted-classes>
		<properties>
	      <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
	      <property name="eclipselink.ddl-generation.output-mode" value="database"/>
	      <property name="eclipselink.weaving" value="false"/>
	      <property name="eclipselink.logging.level" value="FINEST"/>
	      <property name="eclipselink.logging.logger" value="bt.service.persistence.jpa.eclipselink.EclipseLinkSessionLogger"/>
	    </properties>
	</persistence-unit>
</persistence>


- OSGI-INF/blueprint/blueprint.xml
<blueprint xmlns="htp://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:jpa="htp://aries.apache.org/xmlns/jpa/v1.0.0" xmlns:tx="htp://aries.apache.org/xmlns/transactions/v1.0.0" default-activation="lazy">

	<bean id="PromotionPersistenceService" class="com.test.oms.promotion.persistence.PromotionPersistenceServiceImpl">
		<tx:transaction method="*" value="Required" />
		<jpa:context property="entityManager" unitname="oms" />
	</bean>

	<service ref="PromotionPersistenceService" interface="com.test.oms.promotion.persistence.PromotionPersistenceService" />
	
</blueprint>


pom.xml:
<project xmlns="htp://maven.apache.org/POM/4.0.0" xmlns:xsi="htp://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="htp://maven.apache.org/POM/4.0.0 htp://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
  
	<parent>
		<groupId>com.test.oms</groupId>
		<artifactId>OMS</artifactId>
		<version>0.0.1-SNAPSHOT</version>
	</parent>
  
	<groupId>com.test.oms.promotion.persistence</groupId>
	<artifactId>promotion.persistence</artifactId>
  
	<name>OMS :: PROMOTION PERSISTENCE</name>
	<description>The persistence part for the promotion</description>
  
    <packaging>bundle</packaging>
    
      <build>
        <finalName>${project.artifactId}-${project.version}</finalName>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>${maven-compiler-plugin.version}</version>
				<configuration>
					<source>${source.java.compliancy.version}</source>
					<target>${target.java.compliancy.version}</target>
				</configuration>
			</plugin>
		
		     <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>${maven-bundle-plugin.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                        <Bundle-Name>${project.name}</Bundle-Name>
                        <Bundle-Version>${project.version}</Bundle-Version>
                        <Bundle-Blueprint>OSGI-INF/blueprint/*.xml</Bundle-Blueprint>
                        <Meta-Persistence>META-INF/persistence.xml</Meta-Persistence>
                       	<Import-Package>javax.persistence;version="[2.1.0,2.2.0)",
                       		com.test.oms.promotion.api,
                       		com.test.oms.promotion.persistence</Import-Package>
                    </instructions>
                </configuration>
            </plugin>
		</plugins>
		
	</build>
	
	<dependencies>
                <dependency>
  	                <groupId>com.test.oms.promotion.api</groupId>
  			<artifactId>promotion.apis</artifactId>
                        <version>${project.version}</version>
                </dependency>
        
                <dependency>
      		        <groupId>org.eclipse.persistence</groupId>
      		        <artifactId>javax.persistence</artifactId>
      		        <version>2.1.0</version>
    	        </dependency>
	</dependencies>
    
</project>


Deployment

Once the modules compiled (successfully), I'm trying to deploy them within Karaf.

>osgi:install -s mvn:com.test.oms.promotion.api/promotion.apis/0.0.1-SNAPSHOT
OK
>osgi:install -s mvn:com.test.oms.promotion.datasource/promotion.datasource.oracle/0.0.1-SNAPSHOT
OK
>osgi:install -s mvn:com.test.oms.promotion.persistence/promotion.persistence/0.0.1-SNAPSHOT
NOK

This module cannot start immediately as it is waiting on another service to be available (GracePeriod):

Quote:

2013-10-11 10:45:07,738 | INFO | l Console Thread | BlueprintExtender | nt.container.BlueprintExtender$3 282 | 7 - org.apache.aries.blueprint.core - 1.1.0 | Destroying BlueprintContai
ner for bundle promotion.persistence
2013-10-11 10:45:07,741 | WARN | l Console Thread | container | er.impl.PersistenceBundleManager 570 | 94 - org.apache.aries.jpa.container - 1.0.0 | There are no providers ava
ilable.
2013-10-11 10:45:07,741 | WARN | l Console Thread | container | er.impl.PersistenceBundleManager 570 | 94 - org.apache.aries.jpa.container - 1.0.0 | There are no providers ava
ilable.
2013-10-11 10:45:07,752 | WARN | l Console Thread | container | er.impl.PersistenceBundleManager 570 | 94 - org.apache.aries.jpa.container - 1.0.0 | There are no providers ava
ilable.
2013-10-11 10:45:19,932 | WARN | l Console Thread | container | er.impl.PersistenceBundleManager 570 | 94 - org.apache.aries.jpa.container - 1.0.0 | There are no providers ava
ilable.
2013-10-11 10:45:19,944 | WARN | l Console Thread | container | er.impl.PersistenceBundleManager 570 | 94 - org.apache.aries.jpa.container - 1.0.0 | There are no providers ava
ilable.
2013-10-11 10:45:19,945 | WARN | l Console Thread | container | er.impl.PersistenceBundleManager 570 | 94 - org.apache.aries.jpa.container - 1.0.0 | There are no providers ava
ilable.
2013-10-11 10:45:19,947 | WARN | l Console Thread | container | er.impl.PersistenceBundleManager 570 | 94 - org.apache.aries.jpa.container - 1.0.0 | There are no providers ava
ilable.
2013-10-11 10:45:19,956 | INFO | rint Extender: 3 | BlueprintContainerImpl | container.BlueprintContainerImpl 344 | 7 - org.apache.aries.blueprint.core - 1.1.0 | Bundle promotion.persisten
ce is waiting for dependencies [(&(&(org.apache.aries.jpa.proxy.factory=true)(osgi.unit.name=oms))(objectClass=javax.persistence.EntityManagerFactory))]


Does annyone has an idea on what is going on here ? What am I missing ?

I would really appreciate your help on this topic,

Regards,

[Updated on: Tue, 15 October 2013 07:57]

Report message to a moderator

Re: Eclipselink + Karaf + Oracle JDBC [message #1138620 is a reply to message #1132665] Tue, 15 October 2013 07:55 Go to previous message
Yann Perey is currently offline Yann PereyFriend
Messages: 4
Registered: October 2013
Junior Member
In fact there are several errors there. The first one is to try to use the EclipseLink 2.5.0 packages within Karaf as it would require the javax.persistence package 2.1.0 (JPA implementation) which would enter in conflict with the already existing one (Aries) which implements the 2.0 version of the JPA specification.

So first correction uninstall the specified Eclipselink needed packages:

>osgi:install -s mvn:org.eclipse.persistence/javax.persistence/2.1.0
>osgi:install -s mvn:org.eclipse.persistence/org.eclipse.persistence.antlr/2.5.0
>osgi:install -s mvn:org.eclipse.persistence/org.eclipse.persistence.asm/2.5.0
>osgi:install -s mvn:org.eclipse.persistence/org.eclipse.persistence.core/2.5.0
>osgi:install -s mvn:org.eclipse.persistence/org.eclipse.persistence.jpa.jpql/2.5.0
>osgi:install -s mvn:org.eclipse.persistence/org.eclipse.persistence.jpa/2.5.0

and install these one instead:
osgi:install -s mvn:org.eclipse.persistence/org.eclipse.persistence.asm/2.4.2
osgi:install -s mvn:org.eclipse.persistence/org.eclipse.persistence.antlr/2.4.2
osgi:install -s mvn:org.eclipse.persistence/org.eclipse.persistence.jpa.jpql/2.4.2
osgi:install -s mvn:org.eclipse.persistence/org.eclipse.persistence.jpa/2.4.2
osgi:install -s mvn:org.eclipse.persistence/org.eclipse.persistence.core/2.4.2

Then an Eclipselink adaptor has to be created to register manually an OSGI service to specify the ExclipseLink's persistence provider implementation (thanks to lbu: htp://karaf.922171.n3.nabble.com/Karaf-OSGi-Web-Service-with-EclipseLink-No-Persistence-provider-td4028199.html)

and finally I was having a package import/export issue as the API of the service was in the same package but from another bundle as the implementation class.

These three points have solved my issue.

Previous Topic:Eclipselink / RCP / Gemini with @Transactional ala Spring?
Next Topic:binding attributes from inherited interfaces
Goto Forum:
  


Current Time: Sun Dec 21 18:43:38 GMT 2014

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

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