Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Eclipselink, Felix and PostgreSQL

Hi Sander,

I'll provide some comments now, and hopefully be able to spend more time helping you later.

I recommend using Gemini as your OSGi persistence strategy. Although this project is fairly new, it represents the OSGi-specification-approach and all future OSGi JPA development in EclipseLink is planned to be in support of that approach.

  Gemini requires a manifest tag to find persistence.xml.  Something like this:

Meta-Persistence: jpa1.xml, META-INF/jpa2.xml, jar/embeddedPunit.jar!/META-INF/embeddedJpa.xml

  Have you included that tag in your manifest?

  I'll try to find you an example soon.

-Tom

Sander de Groot wrote:
Hi,

What is the best way to implement Eclipselink into OSGi?
As far as I know there are two ways to implement it: using eclipse Gemini or using the org.eclipse.persistence.jpa.osgi bundle. However, we use PostgreSQL as DBMS and unfortunately PostgreSQL doesn't provide us with a OSGi compatible JDBC driver (org.osgi.service.jdbc for example). We tried to modify the driver so it works with the org.osgi.service.jdbc API but we haven't come far.

If we use the org.eclipse.persistence.jpa.osgi bundle than we can't get the PostgreSQL driver to work because of an exception which tells us that the driver is not found. Which actually makes sense because the PostgreSQL driver doesn't register itself anywhere but at the org.osgi.service.jdbc API and while I was looking into the Apache Derby code I found out that Derby actually uses MBeans to register itself..

The other possibility using eclipse gemini should work with the org.osgi.service.jdbc API but we get another annoying exception on which I have no idea how to fix. If we were to choose between the two possiblities than we'd definitely prefer the latter one because it uses an OSGi API instead of JMX.

My questions now actually are:
- Are these two options the only options I have to integrate Eclipselink into OSGi
 - Is it true that the first option uses JMX or did I misunderstood?
- Is it true that eclipse gemini is based on the org.osgi.service.jdbc API?
 - What should I do to integrate Eclipselink into my OSGi container?
 - Why does the exception occur with the latter option?

My log overview on the latter option:

Listening for transport dt_socket at address: 8000
DEBUG: EventAdmin: org.apache.felix.eventadmin.CacheSize=30
DEBUG: EventAdmin: org.apache.felix.eventadmin.ThreadPoolSize=20
DEBUG: EventAdmin: org.apache.felix.eventadmin.Timeout=5000
DEBUG: EventAdmin: org.apache.felix.eventadmin.RequireTopic=true
DEBUG: EventAdmin: org.apache.felix.eventadmin.CacheSize=30
DEBUG: EventAdmin: org.apache.felix.eventadmin.ThreadPoolSize=20
DEBUG: EventAdmin: org.apache.felix.eventadmin.Timeout=5000
DEBUG: EventAdmin: org.apache.felix.eventadmin.RequireTopic=true
_______________
Welcome to Apache Felix Gogo

g! Gemini DBAccess Derby starting
Gemini javax.persistence active
Sep 27, 2010 3:51:00 AM org.eclipse.gemini.naming.Activator start
INFO: Initializing Gemini Naming Factory Manager Bundle
Sep 27, 2010 3:51:00 AM org.eclipse.gemini.naming.Activator start
INFO: Installing Static Singletons
Sep 27, 2010 3:51:00 AM org.eclipse.gemini.naming.Activator start
INFO: Registering URL Context Factory for 'osgi' URL scheme
Sep 27, 2010 3:51:00 AM org.eclipse.gemini.naming.Activator start
INFO: Registering Default Runtime Builder for JRE-provided factories
Sep 27, 2010 3:51:00 AM org.eclipse.gemini.naming.Activator start
INFO: Registering ContextManager service
Sep 27, 2010 3:51:00 AM org.eclipse.gemini.naming.Activator start
INFO: Registering ProviderAdmin service
lb
START LEVEL 1
   ID|State      |Level|Name
    0|Active     |    0|System Bundle (3.0.1)
    1|Active     |    1|Apache Derby 10.6 (10.6.1000000.938214)
2|Active | 1|EclipseLink JPA Canonical Model Processing Service (2.1.1.v20100817-r8050)
    3|Active     |    1|Java Persistence API 2.0 (2.0.1.v201006031150)
    4|Active     |    1|Apache Derby JDBC (10.5.1.1)
    5|Active     |    1|Apache Felix Bundle Repository (1.6.2)
    6|Active     |    1|Apache Felix Configuration Admin Service (1.2.4)
    7|Active     |    1|Apache Felix EventAdmin (1.2.2)
    8|Active     |    1|Apache Felix File Install (3.0.0)
    9|Resolved   |    1|Apache Felix Security Provider (1.3.0.SNAPSHOT)
   10|Active     |    1|Apache Felix Gogo Command (0.6.0)
   11|Active     |    1|Apache Felix Gogo Runtime (0.6.0)
   12|Active     |    1|Apache Felix Gogo Shell (0.6.0)
   13|Active     |    1|Apache Felix Http Bundle (2.0.4)
   14|Active     |    1|Apache Felix Log Service (1.0.0)
   15|Active     |    1|Apache Felix Preferences Service (1.0.4)
   16|Active     |    1|Apache Felix Shell Service (1.4.2)
   17|Active     |    1|Apache Felix Remote Shell (1.0.4)
   18|Active     |    1|Apache Felix Web Management Console (3.1.0)
   19|Active     |    1|Gemini DBAccess (Incubation) (1.0.0.M1-incubation)
20|Active | 1|Gemini javax.persistence (Incubation) (2.0.0.M1-incubation) 21|Resolved | 1|Gemini JPA Dynamic Weaving Fragment (Incubation) (1.0.0.M1-incubation)
   22|Active     |    1|Gemini JPA (Incubation) (1.0.0.M1-incubation)
23|Active | 1|org.eclipse.gemini.naming.framework (Incubation) (1.0.0)
   24|Active     |    1|EclipseLink ANTLR (2.1.1.v20100817-r8050)
   25|Active     |    1|EclipseLink ASM (2.1.1.v20100817-r8050)
   26|Active     |    1|EclipseLink Core (2.1.1.v20100817-r8050)
   27|Active     |    1|EclipseLink JPA (2.1.1.v20100817-r8050)
   28|Active     |    1|osgi.enterprise (4.2.0.201003190513)
g! startfile:eclipselink.jar
Performing test using emm as the JPA Provider and HSQLDB as the Database Engine:

*** FATAL ERROR *** createEntityManagerFactory() called on provider, but provider has not registered the p-unit todos
An Error Occured when Running JPA Example Bundle:
java.lang.RuntimeException: createEntityManagerFactory() called on provider, but provider has not registered the p-unit todos
        at org.eclipse.gemini.jpa.GeminiUtil.fatalError(GeminiUtil.java:92)
at org.eclipse.gemini.jpa.provider.EclipseLinkOSGiProvider.createEntityManagerFactory(EclipseLinkOSGiProvider.java:299) at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source) at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
        at internal.JpaTest.run(JpaTest.java:16)
        at internal.Activator.start(Activator.java:11)
at org.apache.felix.framework.util.SecureAction$Actions.run(SecureAction.java:1254)
        at java.security.AccessController.doPrivileged(Native Method)
at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:624)
        at org.apache.felix.framework.Felix.activateBundle(Felix.java:1862)
        at org.apache.felix.framework.Felix.startBundle(Felix.java:1779)
        at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:905)
        at org.apache.felix.gogo.command.Basic.start(Basic.java:758)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.felix.gogo.runtime.Reflective.method(Reflective.java:136) at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:82)
        at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:421)
at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:335)
        at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
        at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:184)
        at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:121)
at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:78)
        at org.apache.felix.gogo.shell.Console.run(Console.java:62)
        at org.apache.felix.gogo.shell.Shell.console(Shell.java:197)
        at org.apache.felix.gogo.shell.Shell.gosh(Shell.java:123)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.felix.gogo.runtime.Reflective.method(Reflective.java:136) at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:82)
        at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:421)
at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:335)
        at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
        at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:184)
        at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:121)
at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:78)
        at org.apache.felix.gogo.shell.Activator.run(Activator.java:72)
        at java.lang.Thread.run(Thread.java:619)
g!


My example bundle (eclipselink.jar) is a very simple osgi project which only has a persistence.xml in which I tell the provider to use PostgreSQL as the driver and I define the persistence unit 'todos'. Somehow it seems that Eclipselink isn't able to find the persistence.xml... But I don't understand why it doesn't.

Any help will be greatly appreciated.

Best regards,

Sander de Groot
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top